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
Use callbacks to share common setup or constraints between actions.
def set_comment @comment = Comment.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_...
[ "0.6163163", "0.6045976", "0.5946146", "0.591683", "0.5890051", "0.58349305", "0.5776858", "0.5703237", "0.5703237", "0.5652805", "0.5621621", "0.54210985", "0.5411113", "0.5411113", "0.5411113", "0.5391541", "0.53794575", "0.5357573", "0.53402257", "0.53394014", "0.53321576"...
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def comment_params params.fetch(:comment, {}).permit(:id,:comment_text,:commentable_content_id,:commentable_id,:user_id, :commentable_type,:review_status) 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 /result_items/1 GET /result_items/1.json
def show @result_item = ResultItem.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render json: @result_item } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @api_v1_items = Item.all\n render json: @api_v1_items\n end", "def index\n @items = Item.found\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @items }\n end\n end", "def show\n @items = Item.find(params[:id])\n render json: @i...
[ "0.7256978", "0.7178841", "0.69149905", "0.68478286", "0.6802956", "0.6802956", "0.6802956", "0.6802956", "0.6791882", "0.67767096", "0.67378855", "0.66636586", "0.6663495", "0.66301876", "0.6617607", "0.66098446", "0.660211", "0.6581915", "0.6554431", "0.6532568", "0.6531468...
0.73177034
0
GET /result_items/new GET /result_items/new.json
def new @result_item = ResultItem.new respond_to do |format| format.html # new.html.erb format.json { render json: @result_item } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @item = Item.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @item }\n end\n end", "def new\n @item = Item.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @item }\n end\n end", "d...
[ "0.77832484", "0.77832484", "0.77832484", "0.77832484", "0.77832484", "0.77832484", "0.77832484", "0.77832484", "0.77832484", "0.77832484", "0.77832484", "0.77832484", "0.77832484", "0.77832484", "0.77832484", "0.77832484", "0.77832484", "0.77832484", "0.77832484", "0.77832484"...
0.81728435
0
POST /result_items POST /result_items.json
def create @result_item = ResultItem.new(params[:result_item]) respond_to do |format| if @result_item.save format.html { redirect_to @result_item, notice: 'Result item was successfully created.' } format.json { render json: @result_item, status: :created, location: @result_item } else format.html { render action: "new" } format.json { render json: @result_item.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n item = list.items.create!(item_params)\n render json: item, status: 201\n end", "def createItemOfList\n results1 = checkUser(params[:target_account]) #userid user to give the money\n if results1.code == 200\n parameters={user_id: (@current_user[\"id\"]).to_i, description: (params[:...
[ "0.71484107", "0.65665394", "0.6563211", "0.6533026", "0.64969605", "0.6442387", "0.64309007", "0.63736224", "0.6370566", "0.6266414", "0.6263705", "0.62614447", "0.6240797", "0.62373006", "0.61625326", "0.6150633", "0.60792065", "0.6076213", "0.6074319", "0.6067887", "0.6053...
0.68116826
1
PUT /result_items/1 PUT /result_items/1.json
def update @result_item = ResultItem.find(params[:id]) respond_to do |format| if @result_item.update_attributes(params[:result_item]) format.html { redirect_to @result_item, notice: 'Result item was successfully updated.' } format.json { head :no_content } else format.html { render action: "edit" } format.json { render json: @result_item.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n render json: Item.update(params[\"id\"], params[\"item\"])\n end", "def update\n\n if @api_v1_item.update(api_v1_item_params)\n render json: @api_v1_item\n else\n render json: @api_v1_item.errors\n end\n end", "def update\n result_set = @current_items\n\n {:ResultSet ...
[ "0.69357157", "0.68380004", "0.6750554", "0.6614918", "0.6538623", "0.6513402", "0.64209235", "0.64145625", "0.63971514", "0.638554", "0.63730055", "0.6282093", "0.6254859", "0.6245697", "0.62317795", "0.6212336", "0.6127621", "0.6114099", "0.6106293", "0.6084752", "0.6059261...
0.6991308
0
DELETE /result_items/1 DELETE /result_items/1.json
def destroy @result_item = ResultItem.find(params[:id]) @result_item.destroy respond_to do |format| format.html { redirect_to result_items_url } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete\n render json: Item.delete(params[\"id\"])\n end", "def destroy\n @item.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def destroy\n render status: 200, json: @request_item.destroy\n end", "def destroy\n @apiv1_item.destroy\n respond...
[ "0.7366015", "0.72049916", "0.7201413", "0.71942854", "0.7187442", "0.71585053", "0.7060229", "0.7043656", "0.7014725", "0.701176", "0.7001608", "0.699855", "0.699855", "0.699855", "0.699855", "0.699855", "0.699855", "0.699855", "0.699855", "0.699855", "0.699855", "0.698759...
0.7566705
0
Use callbacks to share common setup or constraints between actions.
def set_submission @submission = Submission.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_...
[ "0.6163163", "0.6045976", "0.5946146", "0.591683", "0.5890051", "0.58349305", "0.5776858", "0.5703237", "0.5703237", "0.5652805", "0.5621621", "0.54210985", "0.5411113", "0.5411113", "0.5411113", "0.5391541", "0.53794575", "0.5357573", "0.53402257", "0.53394014", "0.53321576"...
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def submission_params params.fetch(:submission, {}) 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
Update this model using an OmniAuth auth hash
def update_from_auth_hash(auth_hash) if e_account_no && auth_hash.uid != e_account_no raise "eAccount #'s don't match! Expected #{e_account_no} but " + "got #{auth_hash.uid}" end EACCOUNT_MAP.each do |k,v| val = auth_hash.extra[k] if val && v == :email # Email fields come in as multiple <mail> xml nodes :/ val = [] << val unless val.respond_to?(:each) self.email = val[0] if val[0] self.email_cc = val[1] if val[1] next elsif val && val.respond_to?(:blank?) self.send("#{v}=", val) unless val.blank? else self.send("#{v}=", val) end end self.e_account_no = auth_hash.uid self.save end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_omniauth(auth_hash)\n token = auth_hash['credentials']['token']\n secret = auth_hash['credentials']['secret']\n self.access_token = '%s:%s' % [token, secret]\n\n self.save(validate: false)\n end", "def update_from_auth_hash(auth_hash)\n update_account_info auth_hash['info']\n update...
[ "0.77054006", "0.7323602", "0.73129374", "0.6790565", "0.67804104", "0.64600694", "0.6413746", "0.63452804", "0.63410807", "0.6339837", "0.63082623", "0.6297301", "0.62271", "0.6215227", "0.62150675", "0.6162376", "0.6099253", "0.6052012", "0.603751", "0.6026494", "0.5992094"...
0.65935457
5
TODO Protect from mass assignment
def roles=(roles) self.roles_mask = (roles & ROLES).map { |r| 2**ROLES.index(r) }.sum end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def setup_object_attributes; end", "def private; end", "def set; end", "def set; end", "def attribute_to_set; end", "def copyable_attributes; end", "def allowed_attributes=(_arg0); end", "def allowed_attributes=(_arg0); end", "def instance_attributes; end", "def single_object_db=(v); end", "def...
[ "0.6391584", "0.6381238", "0.6343008", "0.6343008", "0.6255446", "0.6204487", "0.61700296", "0.61700296", "0.6148692", "0.60288066", "0.6018341", "0.6000972", "0.59830016", "0.59830016", "0.59830016", "0.5913404", "0.5907515", "0.5851846", "0.5831856", "0.58210015", "0.582100...
0.0
-1
not using is_a? here because Devise doesn't like that
def is_an?(role) roles.include?(role.to_s) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def logged_in?\n current_user.is_a? User\nend", "def logged_in?\n current_user.is_a? User\n end", "def logged_in?\n #current_user.is_a? User\n user_signed_in?\n end", "def admin?\n self.is_a? AdminUser\n end", "def authenticated_with_devise?(current_resource)\n devise_resource = noti...
[ "0.6787292", "0.657618", "0.64529157", "0.6339012", "0.63156027", "0.6260995", "0.62455726", "0.6245541", "0.62082595", "0.6166752", "0.61321366", "0.61321366", "0.61242616", "0.6117511", "0.6085059", "0.6058367", "0.6018991", "0.6018991", "0.60175145", "0.6014257", "0.600949...
0.0
-1
Generate AnyInsert_Adapter version of the Any insert policy, used with the sequence of basic types in the ORB.
def generate_anyinsert_adapter? params[:gen_anyinsert_adapter_policy] || false end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def generate_insert\n @binds = Array.new\n @insert_statement = \"insert into #{fully_qualified_table_name} (\"\n @insert_statement << column_details.keys.sort.map { |k| column_detail(k).column_name }.join(',')\n @insert_statement << ') values ('\n @insert_statement << column_details.keys.s...
[ "0.5421253", "0.50607294", "0.50544417", "0.50239134", "0.49784452", "0.4964235", "0.49589485", "0.49447936", "0.485442", "0.4792907", "0.47484314", "0.47484314", "0.47285524", "0.47175333", "0.46902987", "0.46390116", "0.45820755", "0.45820755", "0.45393705", "0.45092", "0.4...
0.61647284
0
parse the input, and create the matrix
def importMatrix num_vertices = gets.chomp!.to_i matrix = [] num_vertices.times do |x| matrix << gets.chomp!.split(',').map(&:to_i) end p matrix end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parse_input(input)\n lines = input.lines.map(&:chomp)\n $n = lines.shift.to_i\n if $n <= 0\n abort \"ERROR: Wrong node number: #{$n}\"\n end\n number_of_lines = $n*($n-1)/2\n if $n*($n-1)/2 != lines.size\n abort \"ERROR: Wrong number of lines: #{lines.size} for #{$n} nodes, should be #{number_of_li...
[ "0.75604516", "0.66323406", "0.6335979", "0.6208776", "0.61889136", "0.6164212", "0.6144401", "0.6143251", "0.61198324", "0.61198324", "0.6080802", "0.5993715", "0.598658", "0.593631", "0.59334344", "0.5929906", "0.5877058", "0.5815853", "0.57783246", "0.57522357", "0.5727258...
0.6319689
3
given the matrix as an input, create a nested hash of edges and a list in decreasing order of which edges to attack first
def listEdges(matrix) edges = {} hitList = {} matrix.each_with_index do |line, i| aI = @alphaHash[i] line.each_with_index do |node, j| dist = matrix[i][j] aJ = @alphaHash[j] if dist != -1 edge = (i < j ? "#{aI}#{aJ}" : "#{aJ}#{aI}") edges[aI] = {} if edges[aI].nil? edges[aJ] = {} if edges[aJ].nil? edges[aI][aJ] = dist edges[aJ][aI] = dist hitList[edge] = dist end end end hitList = Hash[hitList.sort_by {|k,v| v*-1}] [edges,hitList] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def listEdges(matrix)\n edges = {}\n hitList = {}\n\n matrix.each_with_index do |line, i|\n aI = @alphaHash[i]\n line.each_with_index do |node, j|\n dist = matrix[i][j]\n aJ = @alphaHash[j]\n if dist != -1\n edge = (i < j ? \"#{aI}#{aJ}\" : \"#{aJ}#{aI}\")\n edges[aI] = {} if ...
[ "0.7625337", "0.69273746", "0.6580559", "0.63194907", "0.6269406", "0.59992045", "0.59561235", "0.5919652", "0.5912622", "0.58269376", "0.58228636", "0.5800162", "0.5783707", "0.572209", "0.5698397", "0.5697139", "0.5692431", "0.56831443", "0.56752723", "0.56723666", "0.56547...
0.74941504
1
given the nested hash and hitlist, iterate over the list and check if deleting an edge results in a broken connection or not
def reverse_delete(result) edges = result[0] hitList = result[1] hitList.each do |k, dist| edges[k[0]].delete(k[-1]) edges[k[-1]].delete(k[0]) unless path_exists?(edges, k[0], k[-1]) #check if connection still path p "path does not exist, reconnecting #{k[0]} to #{k[-1]} " edges[k[0]][k[-1]] = dist edges[k[-1]][k[0]] = dist end end edges end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete_edge(v)\n count = 0\n @edges.each do |e|\n @edges.delete_at(count)if e.vertex.eql?(v)\n count+=1\n end\n end", "def test_remove_edge\n @dgraph.add_edge('a', 'b');\n @dgraph.remove_edge('a','b')\n\n # 0 and 1 are indexes of vertex a and vertex b respectively\n assert(@dg...
[ "0.5664156", "0.5640195", "0.5632432", "0.561697", "0.55708873", "0.55670065", "0.55141366", "0.54469585", "0.54268616", "0.5403383", "0.5398353", "0.5327631", "0.528506", "0.5233341", "0.52190673", "0.5216307", "0.5191192", "0.5157154", "0.51500756", "0.5138267", "0.5131398"...
0.6792649
0
this implements a breadth first search to ensure that the connection between two vertices still exists
def path_exists?(edges, start, finish) nodes = edges[start].keys touchedNodes = nodes + [start] newNodes = nodes until newNodes.length == 0 return true if touchedNodes.include?(finish) newNodes = [] nodes.each do |node| newNodes += edges[node].keys - touchedNodes end touchedNodes += newNodes nodes = newNodes end false end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_connection_to(another_vertex)\n @edges.each do |edge|\n if edge.head == another_vertex || edge.tail == another_vertex\n return edge\n end\n end\n end", "def breadth_first_search(start, target)\n queue = [ @vertices[start] ]\n visited = []\n until queue.empty?\n ...
[ "0.68422997", "0.67987984", "0.6706332", "0.63934577", "0.6392134", "0.63443154", "0.6267984", "0.6171298", "0.61429363", "0.61343217", "0.61111933", "0.611081", "0.6095931", "0.6089284", "0.6088888", "0.6076561", "0.6048362", "0.6035882", "0.60334164", "0.60168606", "0.59823...
0.54746157
85
prints the distance of the MST and the edges that remain
def printResult(edges) sum = 0 graph = [] edges.each do |k,v| edges[k].each do |key,value| sum += value graph << "#{k}#{key}" edges[key].delete(k) end end p sum p graph end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def inspect\n \"<Edge distance=#{@distance.inspect}>\"\n end", "def print_graph()\n puts \"Adjacency Matrix\"\n @adjacent_list.each_with_index {|value, index| puts \"#{index} #{value} \\n\" }\n\n puts \"Indegree Matrix\"\n @indegree.each_with_index {|value, index| puts \"#{index} #{value} \\n...
[ "0.6134928", "0.6128301", "0.60140556", "0.5988581", "0.5924075", "0.5859368", "0.5801462", "0.5800245", "0.57902837", "0.57781726", "0.57688355", "0.5759202", "0.57297134", "0.5719057", "0.5713047", "0.56130904", "0.5605152", "0.55496514", "0.55416685", "0.55237", "0.5501995...
0.5702481
15
Iterate over tokens in path; for every capture, find every valid value and continue, making note of the capture value. The end result should be an array of paths along with the captures that created them.
def calculate_valid_paths(tokens, doc = input) token, index = tokens.each_with_index.find { |t, i| t.start_with?(':') } return [{}] unless token sub_doc = tokens[0 .. index - 1].inject(doc) { |o, t| o[t] } items = case sub_doc when Array 0...sub_doc.size when Hash sub_doc.keys else [sub_doc] end items.map { |value| { token => value } } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def segments_from_path(path)\n # Remove leading ^ and trailing $ from each segment (left-overs from regexp joining)\n strip = proc { |str| str.gsub(/^\\^/, '').gsub(/\\$$/, '') }\n segments = []\n while match = (path.match(SEGMENT_REGEXP))\n segments << strip[match.pre_match] u...
[ "0.57558805", "0.5668753", "0.551809", "0.5424821", "0.5389769", "0.5297217", "0.5283294", "0.52475065", "0.52423704", "0.5222118", "0.51415724", "0.51248246", "0.51223075", "0.5072017", "0.506116", "0.5005724", "0.49971333", "0.49858987", "0.4972604", "0.49611896", "0.491758...
0.52820104
7
Recursively replace strings that match a capture with the value of that capture. For example, this returns 'bar': replace_captures(':foo', foo: 'bar')
def replace_captures(object, captures) case object when String object.start_with?(':') ? captures[object] : object when Array object.map { |o| replace_captures(o, captures) } when Hash object.each_with_object({}) do |(key, value), o| o[replace_captures(key, captures)] = replace_captures(value, captures) end else object end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def gsub(value, context, parameters)\n # Try to find a full replacement match - if found, return the actual value of that reference.\n return get_reference_value($1, context, parameters) if value.match(REPLACE_REGEX)\n # No full match, substitute all references with their string representations\n ...
[ "0.56903785", "0.5582522", "0.55392194", "0.55037194", "0.54166585", "0.5335475", "0.5328394", "0.52778536", "0.5277121", "0.52562034", "0.52336746", "0.5223958", "0.50879425", "0.5066853", "0.5053972", "0.5053972", "0.50397456", "0.50349355", "0.50283116", "0.5026142", "0.50...
0.68476784
0
GET /position_scene3s GET /position_scene3s.json
def index @position_scene3s = PositionScene3.all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @vertices_scene3s = VerticesScene3.all\n end", "def set_position_scene3\n @position_scene3 = PositionScene3.find(params[:id])\n end", "def position_scene3_params\n params.require(:position_scene3).permit(:file_name, :vertices_number, :space_ratio, :position_difference, :colour_diff...
[ "0.66901696", "0.62267053", "0.60647935", "0.6056347", "0.5975101", "0.59587735", "0.5872097", "0.58393097", "0.5771715", "0.57236433", "0.5703224", "0.56510586", "0.5650088", "0.556884", "0.5552209", "0.55487365", "0.55392325", "0.55241376", "0.54655373", "0.5437492", "0.541...
0.7394477
0
GET /position_scene3s/1 GET /position_scene3s/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @position_scene3s = PositionScene3.all\n end", "def index\n @vertices_scene3s = VerticesScene3.all\n end", "def set_position_scene3\n @position_scene3 = PositionScene3.find(params[:id])\n end", "def create\n @position_scene3 = PositionScene3.new(position_scene3_params)\n\n r...
[ "0.75232285", "0.68821174", "0.66009504", "0.6317897", "0.627255", "0.62319857", "0.6203394", "0.6182338", "0.61561346", "0.5912895", "0.5858226", "0.58175355", "0.5814155", "0.58009195", "0.570259", "0.56631523", "0.5660085", "0.56217307", "0.5606306", "0.5606306", "0.560107...
0.0
-1
POST /position_scene3s POST /position_scene3s.json
def create @position_scene3 = PositionScene3.new(position_scene3_params) respond_to do |format| if @position_scene3.save format.html { redirect_to @position_scene3, notice: 'Position scene3 was successfully created.' } format.json { render :show, status: :created, location: @position_scene3 } else format.html { render :new } format.json { render json: @position_scene3.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def position_scene3_params\n params.require(:position_scene3).permit(:file_name, :vertices_number, :space_ratio, :position_difference, :colour_difference, :scene_score, :admin_panel_id, :user_panel_id)\n end", "def index\n @position_scene3s = PositionScene3.all\n end", "def create\n @vertices_sc...
[ "0.66534513", "0.6282151", "0.6143743", "0.60779256", "0.6018844", "0.60146385", "0.5970919", "0.5901671", "0.5895524", "0.5886972", "0.5877844", "0.5825189", "0.5821773", "0.57642365", "0.5733401", "0.5704506", "0.56077296", "0.55775374", "0.55739796", "0.5547537", "0.552541...
0.69233054
0
PATCH/PUT /position_scene3s/1 PATCH/PUT /position_scene3s/1.json
def update respond_to do |format| if @position_scene3.update(position_scene3_params) format.html { redirect_to @position_scene3, notice: 'Position scene3 was successfully updated.' } format.json { render :show, status: :ok, location: @position_scene3 } else format.html { render :edit } format.json { render json: @position_scene3.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n respond_to do |format|\n if @vertices_scene3.update(vertices_scene3_params)\n format.html { redirect_to @vertices_scene3, notice: 'Vertices scene3 was successfully updated.' }\n format.json { render :show, status: :ok, location: @vertices_scene3 }\n else\n format.html...
[ "0.69265884", "0.689157", "0.6810434", "0.66915816", "0.65419286", "0.6531544", "0.6485073", "0.6433723", "0.6333171", "0.6304912", "0.6227378", "0.61956966", "0.6064819", "0.60269105", "0.6024557", "0.59938353", "0.5975327", "0.59564656", "0.5947385", "0.589723", "0.58929193...
0.73787314
0
DELETE /position_scene3s/1 DELETE /position_scene3s/1.json
def destroy @position_scene3.destroy respond_to do |format| format.html { redirect_to position_scene3s_url, notice: 'Position scene3 was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @vertices_scene3.destroy\n respond_to do |format|\n format.html { redirect_to vertices_scene3s_url, notice: 'Vertices scene3 was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n\n @scene.destroy\n\n respond_to do |format|\n fo...
[ "0.7647676", "0.7429477", "0.7428472", "0.739779", "0.7190029", "0.71854806", "0.71673805", "0.71564126", "0.70947355", "0.70282966", "0.70010453", "0.69859236", "0.6977276", "0.69558185", "0.6927517", "0.68987846", "0.68885815", "0.6885702", "0.6807381", "0.67774194", "0.676...
0.78511286
0
Use callbacks to share common setup or constraints between actions.
def set_position_scene3 @position_scene3 = PositionScene3.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_...
[ "0.6163163", "0.6045976", "0.5946146", "0.591683", "0.5890051", "0.58349305", "0.5776858", "0.5703237", "0.5703237", "0.5652805", "0.5621621", "0.54210985", "0.5411113", "0.5411113", "0.5411113", "0.5391541", "0.53794575", "0.5357573", "0.53402257", "0.53394014", "0.53321576"...
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def position_scene3_params params.require(:position_scene3).permit(:file_name, :vertices_number, :space_ratio, :position_difference, :colour_difference, :scene_score, :admin_panel_id, :user_panel_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.6981537", "0.67835593", "0.6748275", "0.67436063", "0.6736311", "0.65937173", "0.6503359", "0.6498499", "0.6482832", "0.6478776", "0.645703", "0.6439998", "0.63802195", "0.6377008", "0.6366287", "0.632018", "0.63016284", "0.63011277", "0.62932974", "0.62919617", "0.6290564...
0.0
-1
separate method that starts the game
def start_game(game_config) # start a new game end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def start\n DataManager.create_game_objects\n $game_party.setup_starting_members\n $game_map.setup(Config::Starting_Map_ID)\n $game_player.moveto(Config::X_Pos, Config::Y_Pos)\n $game_player.followers.visible = false\n $game_player.refresh\n $game_player.make_encounter_count\n\n @character_...
[ "0.8175995", "0.80289495", "0.7985139", "0.7931865", "0.7917531", "0.7788931", "0.77850294", "0.77699196", "0.775761", "0.77370995", "0.7711706", "0.7710449", "0.7690734", "0.76858914", "0.7662775", "0.76427615", "0.7632968", "0.7591797", "0.75579363", "0.7543254", "0.7479409...
0.79643035
3
Formerly the start_game method
def start # start a new game using @config end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def run\n game = Game.new\n game.game_start\nend", "def start_game(game_config)\n # start a new game\nend", "def start_a_game\n jeopardy_board\n play_game\nend", "def start\r\n initialize_game\r\n until @game.over?\r\n take_turn\r\n end\r\n print_outcome\r\n end", "de...
[ "0.83258617", "0.8214982", "0.82042176", "0.8190747", "0.8136638", "0.8039483", "0.79852015", "0.79449844", "0.793594", "0.7929015", "0.78854525", "0.78547156", "0.7822794", "0.7787647", "0.7751312", "0.7671359", "0.75935197", "0.75738055", "0.7570348", "0.756748", "0.7559196...
0.79734343
7
I guess in a way, this self.name is locked on the input field already as Itinerary so it wouldn't be left blank. If erased and left blank, it returns an empty string At least it is saving the name! THANK THE HEAVENS!
def set_default_name self.name ||= "Itinerary" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cleanse_name\n return if self.name.nil?\n self.name = self.name.strip\n self.name = nil if self.name.length == 0\n end", "def erase\r\n @name = nil.to_s\r\n end", "def name=(str); dirty!; super; end", "def name\n name = \"\"\n end", "def name\n name = \"\"\n end", "def s...
[ "0.69033676", "0.6830963", "0.6682971", "0.6592978", "0.6592978", "0.64323044", "0.6405118", "0.6370096", "0.6316006", "0.63136834", "0.62672913", "0.61958563", "0.61329144", "0.6108618", "0.6107787", "0.6065305", "0.60207105", "0.60067934", "0.59993017", "0.5992824", "0.5987...
0.0
-1
Progress to the next page
def next next_button.click end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def next\n goto(@current_page + 1)\n end", "def next_page\n go_to_page(@current_page+1)\n end", "def next_page!\n next_page.tap { |page| update_self(page) }\n end", "def next_page\n page = self.page() + 1\n request = @request.clone()\n request.replace_param( :page, page )\n...
[ "0.7771687", "0.7753164", "0.7598284", "0.7572311", "0.7540186", "0.7496128", "0.74274576", "0.7398684", "0.73865855", "0.7385774", "0.73313916", "0.7243541", "0.72061884", "0.71681374", "0.7163169", "0.71478796", "0.7060513", "0.69941306", "0.69886494", "0.698697", "0.698400...
0.6800564
31
Use callbacks to share common setup or constraints between actions.
def set_link @link = Link.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 link_params params.require(:link).permit(:linking_id, :linking_type, :linked_id, :linked_type, :external_link, :medium_id, :x, :y, :status) 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
METODOS Metodo que registra el log de creacion de producto
def registrar_log(tipo) logp = Logproducto.new(:usuario_id => self.usuario_id, :producto_id => self.id, :tipo => tipo, :nusuario => self.usuario.nombre, :nproducto => self.nombre) return logp.save end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def registrar_log(tipo)\n logd = Logdocumento.new(:usuario_id => Usuario.current.id, \n :documento_id => self.id, \n :tipo => tipo, \n :producto_id => self.producto_id, \n :nusuario => Usuario.c...
[ "0.69288266", "0.67055976", "0.65675235", "0.64108986", "0.63957435", "0.63409805", "0.62646973", "0.62552893", "0.6232871", "0.61502564", "0.6079376", "0.6058452", "0.60450584", "0.60037136", "0.5965296", "0.59601396", "0.5950585", "0.59493047", "0.59426117", "0.58943594", "...
0.72156984
0
render :layout => false
def new_uutinen uutinen = Uutinen.new(content: params[:content]) if uutinen.save render :text => "200" else render :text => "200" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index \n render :layout => false\n end", "def show\n render :layout => false\n end", "def show\n render :layout => false\n end", "def show\n #render :layout => false\n end", "def show\n render :layout=>false\n end", "def show\n render :layout=>false\n end", "def show\n ...
[ "0.85031885", "0.8446934", "0.8446934", "0.8442455", "0.83708435", "0.83708435", "0.83708435", "0.8208881", "0.8208881", "0.8208881", "0.80902195", "0.80902195", "0.7942561", "0.76511884", "0.7606297", "0.75544065", "0.7511275", "0.7418859", "0.74157286", "0.7387568", "0.7379...
0.0
-1
GET /compositions/1 GET /compositions/1.json
def show @composition = Composition.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render :json => @composition } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @compositions = Composition.all\n end", "def index\r\n @compositions = Composition.all\r\n end", "def show\n\n @competitions = Competition.all\n @competition = Competition.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { rende...
[ "0.7286041", "0.70959455", "0.6472799", "0.6445214", "0.63882047", "0.6341801", "0.6302635", "0.62601626", "0.6228922", "0.621186", "0.6079616", "0.607879", "0.6044221", "0.60356283", "0.6011026", "0.5995855", "0.5995855", "0.5995855", "0.5994388", "0.5971513", "0.5922357", ...
0.76885444
0
GET /packages GET /packages.json
def index @packages = Package.all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @user_packages = UserPackage.all\n\n render json: @user_packages\n end", "def get_packages!(path)\n response = Api::Request.new do |request|\n request[:sign] = false\n request[:method] = :GET\n request[:path] = \"/shared/packages/#{path}\"\n end.execute!\n\n ...
[ "0.7094987", "0.6980382", "0.6915026", "0.6870578", "0.66833556", "0.6557783", "0.64823544", "0.6404226", "0.6371317", "0.63614136", "0.63333756", "0.63276005", "0.62957823", "0.6293979", "0.62011826", "0.6176134", "0.61614174", "0.6132927", "0.6128261", "0.61154467", "0.6108...
0.64163077
10
GET /packages/1 GET /packages/1.json
def show respond_to do|format| format.html format.pdf do pdf = PackagePdf.new(@package) send_data pdf.render, filename: "package_#{@package.pack_nr}.pdf", type: "application/pdf", disposition: "inline" end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_packages!(path)\n response = Api::Request.new do |request|\n request[:sign] = false\n request[:method] = :GET\n request[:path] = \"/shared/packages/#{path}\"\n end.execute!\n\n Object::File.open(path, 'wb') do |file|\n file.write(response)\n end\n\n path...
[ "0.681649", "0.6812562", "0.6763046", "0.6685305", "0.6537243", "0.6433314", "0.6433314", "0.6433314", "0.6433314", "0.64313513", "0.64066017", "0.632991", "0.63220793", "0.62971985", "0.62949884", "0.6280894", "0.62229276", "0.61833423", "0.6109267", "0.6067275", "0.6053432"...
0.0
-1
POST /packages POST /packages.json
def create @package = Package.new(package_params) add_items respond_to do |format| if @package.save format.html { redirect_to @package, notice: 'Package was successfully created.' } format.json { render action: 'show', status: :created, location: @package } else format.html { render action: 'new' } format.json { render json: @package.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @package = Package.create(package_params)\n\n render json: @package\n end", "def create\n api_service = Api.find_by(status: true).name\n result_hash = RouteCalculator.call(package_params.merge(service: api_service))\n @package = current_user.packages.new(result_hash.merge(package_par...
[ "0.7046362", "0.6602616", "0.6572252", "0.6494805", "0.6482147", "0.64049584", "0.64049584", "0.6324552", "0.6219304", "0.6121728", "0.6080309", "0.6058989", "0.59427685", "0.592677", "0.5926081", "0.59182817", "0.5878696", "0.5864899", "0.58166134", "0.5809055", "0.580403", ...
0.65703434
3
PATCH/PUT /packages/1 PATCH/PUT /packages/1.json
def update respond_to do |format| add_items if @package.update(package_params) format.html { redirect_to @package, notice: 'Package was successfully updated.' } format.json { head :no_content } else format.html { render action: 'edit' } format.json { render json: @package.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @package = Package.find(params[:id])\n\n respond_to do |format|\n if @package.update_attributes(params[:package])\n format.html { redirect_to @package, :notice => 'Package was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action...
[ "0.6692511", "0.6640756", "0.6635521", "0.6551934", "0.65434575", "0.65434575", "0.65343845", "0.6519612", "0.6474908", "0.64227545", "0.63775104", "0.6357034", "0.6286585", "0.62261856", "0.6212161", "0.6173306", "0.6151871", "0.6148322", "0.61106825", "0.61055434", "0.60999...
0.671029
0
DELETE /packages/1 DELETE /packages/1.json
def destroy @package.destroy Logunit.where(:package_id => @package.id).destroy_all Logcomponent.where(:package_id => @package.id).destroy_all respond_to do |format| format.html { redirect_to packages_url } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @package = Package.find(params[:id])\n @package.destroy\n\n respond_to do |format|\n format.html { redirect_to packages_url }\n format.json { head :ok }\n end\n end", "def destroy\n @package.status = nil\n @package.save!\n respond_to do |format|\n format.html { ...
[ "0.7325984", "0.72980565", "0.7151152", "0.7102877", "0.7102877", "0.7101819", "0.70484847", "0.6978", "0.6962748", "0.69584566", "0.69584566", "0.6896802", "0.68251055", "0.6804538", "0.6768487", "0.6722521", "0.6719763", "0.6709181", "0.67016065", "0.67013747", "0.6674813",...
0.6820448
13
Use callbacks to share common setup or constraints between actions.
def set_package @package = Package.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_...
[ "0.6163163", "0.6045976", "0.5946146", "0.591683", "0.5890051", "0.58349305", "0.5776858", "0.5703237", "0.5703237", "0.5652805", "0.5621621", "0.54210985", "0.5411113", "0.5411113", "0.5411113", "0.5391541", "0.53794575", "0.5357573", "0.53402257", "0.53394014", "0.53321576"...
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def package_params params.require(:package).permit(:client_id, :origin, :destiantion, :arrival_date, :reciver, :status, :po, :ref, :coment, :pack_nr, :unit_ids, :components_ids) 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.6981537", "0.67835593", "0.6748275", "0.67436063", "0.6736311", "0.65937173", "0.6503359", "0.6498499", "0.6482832", "0.6478776", "0.645703", "0.6439998", "0.63802195", "0.6377008", "0.6366287", "0.632018", "0.63016284", "0.63011277", "0.62932974", "0.62919617", "0.6290564...
0.0
-1
retrieve a user TVUser.get_user("00000000000000000000000000000000")
def find(user_id, read_attributes="01") options = default_options_to_merge_with.merge({ query: { full: read_attributes} }) self.class.get("/#{@api_ver}/users/#{user_id}", options) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def retrieve(user_id:)\n User.new get_request(\"users/#{user_id}\").body.dig(\"user\")\n end", "def get_user_from_ethereum\n user_id = Md5UserExtendedDetail.get_user_id(@client_id, @ethereum_address)\n @user = User.get_from_memcache(user_id)\n end", "def get_user(user_id)\n return User....
[ "0.7245057", "0.72177154", "0.70575833", "0.7055133", "0.6986631", "0.69173634", "0.6895025", "0.6892636", "0.6865146", "0.6793772", "0.6772947", "0.6770703", "0.6767582", "0.67660016", "0.67511606", "0.67327917", "0.67299473", "0.67255497", "0.67079896", "0.67075706", "0.668...
0.0
-1
list all users TVUser.list_users
def all(read_attributes="01") options = default_options_to_merge_with.merge({ query: { full: read_attributes} }) self.class.get("/#{@api_ver}/users", options) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def list_users\n @users = User.find(:all)\n end", "def list_users\n BrickFTP::API::User.all\n end", "def list_users\n BrickFTP::API::User.all\n end", "def list\n\t\t# retrieve all users\n @users = User.find(:all)\n end", "def list\n @all_users = User.find(:all)\n end", "de...
[ "0.833375", "0.82698226", "0.82698226", "0.8147666", "0.80910057", "0.8089902", "0.8078977", "0.79891425", "0.79209477", "0.78854185", "0.7881807", "0.7817645", "0.78144747", "0.78014225", "0.7788796", "0.7649271", "0.76208127", "0.75744414", "0.7574356", "0.7574356", "0.7546...
0.0
-1
delete a user TVUser.delete_user("00000000000000000000000000000000")
def delete(user_id) self.class.delete("/#{@api_ver}/users/#{user_id}", default_options_to_merge_with) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete_user\n client.delete(user)\n end", "def delete_user(user_id)\n Result.new(call(CMD_DEL_USER % user_id))\n end", "def delete_user(id)\n elektron_identity.delete(\"users/#{id}\")\n end", "def delete\n connection.delete_user id\n nil\n end", "def del...
[ "0.8144694", "0.79609406", "0.7861856", "0.7843033", "0.78365", "0.7787378", "0.7731245", "0.7666392", "0.764828", "0.76379544", "0.76375365", "0.7624737", "0.7576482", "0.7570101", "0.75649935", "0.7547225", "0.7530859", "0.7519478", "0.7496981", "0.7485316", "0.74827874", ...
0.7489983
19
Scrapping member from a group id
def member_from_group_id(group_id) #scrap first page begin puts "fetching group ID #{group_id}" members = flickr.groups.members.getList(:group_id => "#{group_id}") members.each do |m| #store member save_member(m, group_id) end #scrap next page total_pages = members.pages current_page = 2 while current_page <= total_pages begin puts "fetching at current page #{current_page} of group id #{group_id}" members = flickr.groups.members.getList(:group_id => "#{group_id}", :page => current_page) members.each do |m| save_member(m, group_id) end rescue => e write_to_log(e) write_to_log("fetching at current page #{current_page} of group id #{group_id}") end current_page = current_page + 1 end rescue => e write_to_log(e) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_group_member\n @group_member = GroupMember.find_by(group_id:params[:id])\n end", "def group_leader\n if self.group_leader_id.nil?\n return nil\n else\n Member.find_by_id( self.group_leader_id )\n end\n end", "def set_group_member\n @groupmember = GroupMember.find(para...
[ "0.64318144", "0.6270811", "0.6164735", "0.61212945", "0.61185694", "0.6105707", "0.6105707", "0.6050406", "0.60104525", "0.6006531", "0.5988906", "0.5983", "0.59644294", "0.59602", "0.5925886", "0.59017247", "0.588417", "0.58743864", "0.5832436", "0.58219314", "0.5813716", ...
0.7215987
0
indicate the type of the document
def categorize_supplemental_documents if request.put? supplemental_document = SupplementalDocument.find(params[:supplemental_document][:id]) params[:supplemental_document].delete(:id) # do this so not get mass assignment error supplemental_document.update_attributes(params[:supplemental_document]) if supplemental_document.present? # update the stats # get user stats @supplemental_document_user_stats = SupplementalDocument.user_stats(current_user.id) # get document stats @document_stats = SupplementalDocument.document_stats end # get the next doc @supplemental_document = SupplementalDocument.next_to_categorize end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def document_type name=nil\n @document_type = name || @document_type || implicit(:document_type)\n end", "def document_type\n instance.class.tire.document_type\n end", "def type\n document._type = document.class.name if typed?\n end", "def document_type=(name)\n ...
[ "0.838238", "0.83167154", "0.82788527", "0.82735026", "0.82735026", "0.8225212", "0.8108172", "0.8091009", "0.8065792", "0.79334545", "0.7739577", "0.7739577", "0.7676201", "0.76055634", "0.75319254", "0.7485255", "0.73470676", "0.7297241", "0.72603095", "0.723169", "0.711421...
0.0
-1
set the say what flag for a protocol
def say_what # check for required fields if params[:election_id].present? && params[:district_id].present? && params[:precinct_id].present? dp = DistrictPrecinct.by_ids(params[:election_id], params[:district_id], params[:precinct_id]).first if dp.present? dp.has_say_what = true dp.say_what_reported_at = Time.now dp.save end end respond_to do |format| format.json {render json: {status: 200}} end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def setsockopt(*) end", "def protocol=(_arg0); end", "def server_flags; end", "def protocol; end", "def protocol; end", "def protocol; end", "def protocol; end", "def set_protocol(opts)\n opts = check_params(opts,[:protocols])\n super(opts)\n end", "def set_protocol\n @protocol = ...
[ "0.6252573", "0.6237471", "0.62124914", "0.6202158", "0.6202158", "0.6202158", "0.6202158", "0.6147214", "0.60699004", "0.59812725", "0.59749323", "0.59580564", "0.5882743", "0.58180934", "0.58109885", "0.57190675", "0.56931764", "0.5668189", "0.56626445", "0.56545913", "0.56...
0.0
-1
remove bad characters from file name
def clean_filename(filename) Utf8Converter.convert_ka_to_en(filename.gsub(' ', '_').gsub(/[\\ \/ \: \* \? \" \< \> \| \, \. ]/,'')) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sanitize_filename(file_name)\r\n\t\tjust_filename = File.basename(file_name)\r\n\t\tjust_filename.sub(/[^\\w\\.\\-]/, '_')\r\n\tend", "def sanitize_filename\n name = self.strip\n #--- get only the filename, not the whole path\n name.gsub! /^.*(\\\\|\\/)/, ''\n\n #--- Finally, replace all non alph...
[ "0.8352087", "0.8310687", "0.8181577", "0.8174325", "0.8172705", "0.81624806", "0.8162322", "0.8133944", "0.7990816", "0.79817086", "0.797522", "0.79445267", "0.79445267", "0.79445267", "0.79445267", "0.7943147", "0.7928786", "0.78831226", "0.7821622", "0.7810954", "0.7809861...
0.8164079
5
similar to the spaceship operator
def bubble_sort_by(array) #loop until everything is swapped by length (sorted) loop do swapped = false (array.length - 1).times do |i| #assign to a variable the parameter implicitly returned by the block value = yield array[i], array[i+1] #check the value from the block and swap if needed (so set swap to true) if (value == 1) array[i], array[i+1] = array[i+1], array[i] swapped = true end end #if nothing is swapped (so the array is sorted), the method will never #enter the IF and the swapped variable would be false and will BREAK #if swapped is true it just jump the break and go back to the loop break if !swapped end #print inspect and return the array puts array.inspect return array end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def spaceship(left, right, **options)\n case\n # @see https://www.w3.org/TR/sparql11-query/#OperatorMapping\n # @see https://www.w3.org/TR/sparql11-query/#modOrderBy\n when left.is_a?(RDF::Literal) && right.is_a?(RDF::Literal)\n # @see https://www.w3.org/TR/xpath-functions/#str...
[ "0.6552151", "0.6371739", "0.5980921", "0.5980921", "0.59694445", "0.5827617", "0.58254284", "0.58228105", "0.58077115", "0.5739517", "0.56422997", "0.55573213", "0.5555548", "0.5510739", "0.5509239", "0.54972917", "0.54932815", "0.54399425", "0.5438157", "0.5408703", "0.5388...
0.0
-1
GET /songs GET /songs.json
def index @songs = Song.all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def songs\n \t@songs = Album.find(params[:id])\n songs = RSpotify::Track.search(@songs.name)\n \t@songs = songs.map do |s_songs|\n \tSong.new_from_spotify_song(s_songs)\n end\n render json: {data:@songs}\n end", "def index\n \n @songs = Song.order 'id'\n\n respond_to do |format|\n f...
[ "0.8023557", "0.772287", "0.7639002", "0.7577367", "0.7519796", "0.7518334", "0.74522924", "0.74318486", "0.7406608", "0.7387082", "0.7190135", "0.7173719", "0.7173719", "0.7173719", "0.7173719", "0.7109256", "0.70980364", "0.70968103", "0.7045383", "0.7045383", "0.7045383", ...
0.7022663
36
GET /songs/1 GET /songs/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n @song = Song.find(params[:id])\n\n respond_to do |format|\n format.json { render json: @song }\n end\n end", "def getSong\n\t\tid = params[:songId]\n\t\tresult = GetSongFromSpotify.build.call(id)\n\t\trender json: result\n\tend", "def show\n @song = Song.find(params[:id])\n\n re...
[ "0.7938354", "0.7895859", "0.7706705", "0.7706705", "0.7706705", "0.7706705", "0.76346755", "0.7571089", "0.75562555", "0.75397277", "0.7520489", "0.7483983", "0.74218845", "0.7320445", "0.7221914", "0.7221914", "0.71899533", "0.7179004", "0.7111133", "0.7081457", "0.70678484...
0.0
-1
POST /songs POST /songs.json
def create artist_id = artist_exist_or_new(params[:artist_name]) album_id = album_exist_or_new(params[:album_name], params[:genre], artist_id) @song = Song.new(song_params) @song.album_id = album_id respond_to do |format| if @song.save format.html { render '/shared/created'} format.json { render action: 'show', status: :created, location: @song } else format.html { render action: 'new' } format.json { render json: @song.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n\t\tparams = song_params\n\t\tsongkey = params['song_key']\n\t\tparams.delete('song_key')\n\n songtags = params['tags']\n params.delete('tags')\n\n\t\t@song = Song.new(params)\n\n\t\trespond_to do |format|\n\t\t\tif @song.save\n\n\t\t\t\tif songkey.to_s.length > 0\n\t\t\t\t\t@song.song_ke...
[ "0.73157895", "0.7304832", "0.7290315", "0.72273165", "0.72147673", "0.7177101", "0.7172705", "0.7172705", "0.7122533", "0.7122533", "0.7122533", "0.7095", "0.7068517", "0.706235", "0.7046306", "0.7038219", "0.7026587", "0.70128095", "0.6970287", "0.69490415", "0.69486827", ...
0.62768656
83
PATCH/PUT /songs/1 PATCH/PUT /songs/1.json
def update artist_id = update_artist_exist_or_new(params[:artist_name]) album_id = update_album_exist_or_new(params[:album_name], params[:genre], artist_id) respond_to do |format| @song.album_id = album_id a = @song.album a.artist_id = artist_id a.save if @song.update(song_params) format.html { redirect_to @song, notice: 'Song was successfully updated.' } format.json { head :no_content } else format.html { render action: 'edit' } format.json { render json: @song.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n \n \n respond_to do |format|\n updated_params = song_params\n if (@song.artist != song_params[:artist] || @song.songname != song_params[:songname])\n uri = 'http://developer.echonest.com/api/v4/song/search?api_key=6XUOAXHJOW28GGGRH&format=json&results=1&artist=' + Rack::Utils...
[ "0.73953635", "0.7364439", "0.7333291", "0.7289592", "0.7278623", "0.727002", "0.727002", "0.727002", "0.72454554", "0.72009903", "0.7190894", "0.7183998", "0.7183998", "0.7183998", "0.7183998", "0.7183998", "0.7183998", "0.7183998", "0.7183998", "0.7183176", "0.718239", "0...
0.6471456
54
DELETE /songs/1 DELETE /songs/1.json
def destroy @song.destroy respond_to do |format| format.html { redirect_to songs_url } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @song = Song.find(params[:id])\n @song.destroy\n\n respond_to do |format|\n format.html { redirect_to songs_url }\n format.json { head :ok }\n end\n end", "def destroy\n @song = Song.find(params[:id])\n @song.destroy\n\n respond_to do |format|\n format.html { re...
[ "0.7993327", "0.79589206", "0.79589206", "0.79589206", "0.79589206", "0.79589206", "0.79589206", "0.7946083", "0.77754766", "0.77688175", "0.7692386", "0.76777565", "0.76777565", "0.76777565", "0.76777565", "0.76777565", "0.7673852", "0.7672169", "0.7672086", "0.7668517", "0....
0.787302
13
Use callbacks to share common setup or constraints between actions.
def set_song @song = Song.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_...
[ "0.6163163", "0.6045976", "0.5946146", "0.591683", "0.5890051", "0.58349305", "0.5776858", "0.5703237", "0.5703237", "0.5652805", "0.5621621", "0.54210985", "0.5411113", "0.5411113", "0.5411113", "0.5391541", "0.53794575", "0.5357573", "0.53402257", "0.53394014", "0.53321576"...
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def song_params params.require(:song).permit(:song_title, :track, :duration, :path, :filename, :composer) 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
:callseq: spore.enable(Spore::Middleware::SomeThing, :optionX => 42) This method takes a middleware class as its first argument. Options to pass to the middleware can be given as a second argument. Once this method is called, the Spore client will pass the request and the response objects to the middleware whenever appropriate. The order in which middlewares are enabled is respected by Spore. (same order for processing the request before it's sent, reverse order for processing response, as described in the Spore specification).
def enable(middleware, args={}) m = middleware.new(args) self.middlewares.push({ :condition => Proc.new { true }, :middleware => m }) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def use ware, *args, &proc\n @middleware << {ware: ware, args: args, block: proc} if configurable?\n end", "def use(middleware, options = nil)\n self.middleware << [middleware, options].compact\n end", "def use ware, *args, &proc\n @middleware << {ware: ware, args: args, block: proc}\n ...
[ "0.68266726", "0.66535246", "0.6362326", "0.63369894", "0.6335782", "0.6208871", "0.6158463", "0.609287", "0.6019688", "0.6010302", "0.5975371", "0.59723103", "0.59705824", "0.5942374", "0.5885826", "0.5825692", "0.5821172", "0.5803331", "0.57717156", "0.5744372", "0.57090217...
0.77635145
0
++ | | | ++ | | | ++ | | ++
def test_nonconvex nonconvex_polygon = Polygon.new [ Point(0, 0), Point(0, 6), Point(4, 6), Point(4, 4), Point(2, 4), Point(2, 2), Point(4, 2), Point(4, 0) ] inner_points = [ Point(1, 5), Point(3, 5), Point(1, 3), Point(1, 1), Point(3, 1) ] outer_points = [ Point(7, 5), Point(5, 3), Point(7, 3), Point(7, 1) ] inner_points.each do |inner_point| assert nonconvex_polygon.contains?(inner_point) end outer_points.each do |outer_point| assert ! nonconvex_polygon.contains?(outer_point) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def succ!() end", "def succ() end", "def succ() end", "def succ() end", "def increment!\n self.left_half += 1\n # TODO: This breaks if the length of a palindrome changes, as odd doesn't update\n self\n end", "def inc(cb)\n c = 0\n additive = 0\n left_32 = cb.slice(12..15)\n while c<=4\n ...
[ "0.6357881", "0.6066902", "0.6066902", "0.6066902", "0.6063121", "0.6013053", "0.5984278", "0.58934104", "0.58910197", "0.5859154", "0.58191997", "0.57865703", "0.5766903", "0.57400763", "0.57378703", "0.57183254", "0.57118106", "0.5707648", "0.5696796", "0.5694727", "0.56906...
0.0
-1
Export all ended spans to the configured `Exporter` that have not yet been exported. This method should only be called in cases where it is absolutely necessary, such as when using some FaaS providers that may suspend the process after an invocation, but before the `Processor` exports the completed spans.
def force_flush(timeout: nil) writer.force_flush(timeout: timeout) if writer.respond_to? :force_flush Export::SUCCESS end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def export spans\n each { |delegate| delegate.export spans }\n nil\n end", "def force_flush\n snapshot = lock { spans.shift(spans.size) }\n until snapshot.empty?\n batch = snapshot.shift(@batch_size).map!(&:to_span_data)\n result_code = @ex...
[ "0.7409153", "0.6003419", "0.52626204", "0.5081593", "0.5056326", "0.50105655", "0.50105655", "0.4980772", "0.48567322", "0.48378584", "0.47785163", "0.4757584", "0.47449043", "0.46992812", "0.46992812", "0.46618074", "0.46583405", "0.46012115", "0.45670867", "0.45419884", "0...
0.0
-1
Check whether a stated assertion is satisfied by its attributes
def valid? !invalid? end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def assertions\n @@assertions\n end", "def _assert_exposes_for(asserted, expected, **options)\n passed, matches, last_failed = Assert.assert_attributes(asserted, expected, **options) do |_matches, last_failed|\n name, expected_value, actual_value, _passed, is_eq, error_msg = last_fail...
[ "0.68054235", "0.67299426", "0.66159385", "0.65802604", "0.65577793", "0.6488008", "0.6488008", "0.64763427", "0.64644885", "0.6414435", "0.639143", "0.62687147", "0.62582093", "0.6254449", "0.6216292", "0.6209724", "0.61759704", "0.61643803", "0.61598295", "0.61187273", "0.6...
0.0
-1
Check whether a stated assertion is not satisfied by its attributes
def invalid? !@state end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def assert_invalid(model, *attributes)\n assert(!model.valid?, \"#{model.inspect} should be invalid, but isn't.\")\n \n return if attributes.empty?\n\n missing_invalids = attributes - invalid_attributes(model)\n\n assert missing_invalids.empty?,\n \"Attribute(s) #{missing_invalids.join(\", \")}...
[ "0.68231434", "0.6736904", "0.6725965", "0.6659121", "0.66404265", "0.65700036", "0.6529919", "0.65076864", "0.64996123", "0.6476367", "0.64723766", "0.6455279", "0.6455279", "0.64290035", "0.64018816", "0.63908005", "0.6384246", "0.63809955", "0.63531065", "0.6350039", "0.63...
0.0
-1
Composes the state with the other state
def &(other) self.class.new(valid? & other.valid?, messages + other.messages) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def chain_state\n super\n end", "def merge( otherstate )\n\t\tmerged = self.dup\n\t\tmerged.merge!( otherstate )\n\t\treturn merged\n\tend", "def merge!(state)\n @cardinality = state.cardinality\n @policy = state.policy\n\n @transitions.merge!(state.transitions) do |_, _, transition|\n ...
[ "0.63858867", "0.6058648", "0.59622145", "0.58934563", "0.5860953", "0.5804442", "0.5767233", "0.57062817", "0.5622882", "0.5562896", "0.5560747", "0.5528543", "0.55277604", "0.55196023", "0.5515336", "0.54942137", "0.54865646", "0.5483829", "0.5483829", "0.54384524", "0.5438...
0.0
-1
0indexed, exclusive (both taken together are) therefore you might end up on a newline character or the next line
def end_row strict_position.end_row end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_text_invariant(t)\n\tt1 = t.text.gsub(\"\\n\", \"\\\\n\")\n\trep = \"line indices: [#{t.line_indices.join(', ')}], text = #{t1}\"\n\n\tassert(t.text.gsub(/[^\\n]/, '').length == t.line_indices.length, \"Incorrect number of newlines: #{rep}\")\n\tassert(t.line_indices == t.line_indices.sort)\n\tt.line_indi...
[ "0.6610046", "0.6562085", "0.6456427", "0.64123964", "0.63362646", "0.62578994", "0.62430924", "0.62374777", "0.62163377", "0.61694425", "0.6166293", "0.61253816", "0.61233217", "0.6111839", "0.60958207", "0.60940415", "0.6093128", "0.6092638", "0.60747695", "0.6057278", "0.6...
0.0
-1
have to use return to exit from the loop. (Well, it will get you out of the whole method, but it will get you out of the loop in the process.) How do you like the resulting method? I usually try to avoid using return (a personal preference), but I might make an exception here.
def ask question while true puts question reply = gets.chomp.downcase if reply == 'yes' return true end if reply == 'no' return false end puts 'Please answer "yes" or "no".' end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def endless_loop?; end", "def method_return_from_loop\n (1..10).each do |n|\n if n == 5\n return 5 * 5\n end\n end\n nil\n end", "def continue?; end", "def continue; end", "def continue; end", "def stop!\n throw :return, 1\n end", "def dothings( aNum )\n i ...
[ "0.70893955", "0.70642287", "0.6835179", "0.6754193", "0.6754193", "0.6567662", "0.65189886", "0.6516085", "0.6425434", "0.6400969", "0.63508964", "0.6328655", "0.63177586", "0.6295159", "0.62886375", "0.6275419", "0.62528133", "0.62455875", "0.6225246", "0.62226856", "0.6191...
0.0
-1
This takes a multiline string and formats it as an entry Params: +input+:: String Returns: [title(String), note(Array)]
def format_input(input) raise "No content in entry" if input.nil? || input.strip.length == 0 input_lines = input.split(/[\n\r]+/) title = input_lines[0].strip note = input_lines.length > 1 ? input_lines[1..-1] : [] note.map! { |line| line.strip }.delete_if { |line| line =~ /^\s*$/ } [title, note] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def format_input(input)\n raise EmptyInput, 'No content in entry' if input.nil? || input.strip.empty?\n\n input_lines = input.split(/[\\n\\r]+/).delete_if(&:ignore?)\n title = input_lines[0]&.strip\n raise EmptyInput, 'No content in first line' if title.nil? || title.strip.empty?\n\n date ...
[ "0.80618155", "0.62237", "0.62102634", "0.6155973", "0.6059779", "0.6044895", "0.6044335", "0.6044335", "0.59971434", "0.59282774", "0.5876253", "0.5801333", "0.5775101", "0.56913257", "0.56144536", "0.55479103", "0.5528916", "0.5484099", "0.5471562", "0.5461", "0.5430824", ...
0.8827636
0
Converts `input` string into a Time object when `input` takes on the following formats: interval format e.g. '1d2h30m', '45m' etc. a semantic phrase e.g. 'yesterday 5:30pm' a strftime e.g. '20160315 15:32:04 PDT'
def chronify(input) now = Time.now raise "Invalid time expression #{input.inspect}" if input.to_s.strip == "" secs_ago = if input.match /^(\d+)$/ # plain number, assume minutes $1.to_i * 60 elsif (m = input.match /^((?<day>\d+)d)?((?<hour>\d+)h)?((?<min>\d+)m)?$/i) # day/hour/minute format e.g. 1d2h30m [[m['day'], 24*3600], [m['hour'], 3600], [m['min'], 60]].map {|qty, secs| qty ? (qty.to_i * secs) : 0 }.reduce(0, :+) end if secs_ago now - secs_ago else Chronic.parse(input, {:context => :past, :ambiguous_time_range => 8}) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def string_to_time(string)\n super(handle_date_parse_input(string))\n end", "def string_as_t string\n Time.parse(string)\n end", "def string_to_time(string)\n Time.parse(string)\n end", "def set_date_string(input)\n\n now = Time.new\n date = Time.new\n\n #Handle minute no...
[ "0.6806604", "0.65848327", "0.65418404", "0.6415356", "0.6404535", "0.6206487", "0.6173816", "0.6165856", "0.6111781", "0.6101951", "0.60857445", "0.6084804", "0.6077049", "0.60298175", "0.60230863", "0.5994102", "0.5959713", "0.5955604", "0.5940024", "0.5920447", "0.59149575...
0.68291557
0
Converts simple strings into seconds that can be added to a Time object Params: +qty+:: HH:MM or XX[dhm][[XXhm][XXm]] (1d2h30m, 45m, 1.5d, 1h20m, etc.) Returns seconds (Integer)
def chronify_qty(qty) minutes = 0 if qty.strip =~ /^(\d+):(\d\d)$/ minutes += $1.to_i * 60 minutes += $2.to_i elsif qty.strip =~ /^(\d+)([hmd])?$/ amt = $1 type = $2.nil? ? "m" : $2 minutes = case type.downcase when 'm' amt.to_i when 'h' (amt.to_f * 60).round when 'd' (amt.to_f * 60 * 24).round else minutes end end minutes * 60 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def to_seconds(str)\n hours, minutes = str.split(\" \").map(&:to_i)\n (hours * 3600) + (minutes * 60)\n end", "def parse_time(str)\n seconds = 0\n str.scan(/\\d+ *[Dd]/).each { |m| seconds += (m.to_i * 24 * 60 * 60) }\n str.scan(/\\d+ *[Hh]/).each { |m| seconds += (m.to_i * 60 * 60) }\n str.sc...
[ "0.7302043", "0.7272789", "0.7092062", "0.7023205", "0.7022784", "0.6901681", "0.67546433", "0.6727387", "0.6710112", "0.6676517", "0.66703576", "0.665274", "0.6634472", "0.66261446", "0.6608128", "0.6608128", "0.6560184", "0.65490186", "0.6500812", "0.64713055", "0.6396781",...
0.6590143
16
accepts one tag and the raw text of a new item
def stop_start(tag,opt={}) opt[:section] ||= @current_section opt[:archive] ||= false opt[:back] ||= Time.now opt[:new_item] ||= false opt[:note] ||= false opt[:section] = guess_section(opt[:section]) tag.sub!(/^@/,'') found_items = 0 @content[opt[:section]]['items'].each_with_index {|item, i| if item['title'] =~ /@#{tag}/ title = item['title'].gsub(/(^| )@(#{tag}|done)(\([^\)]*\))?/,'') title += " @done(#{opt[:back].strftime('%F %R')})" @content[opt[:section]]['items'][i]['title'] = title found_items += 1 if opt[:archive] && opt[:section] != "Archive" @results.push(%Q{Completed and archived "#{@content[opt[:section]]['items'][i]['title']}"}) archive_item = @content[opt[:section]]['items'][i] archive_item['title'] = i['title'].sub(/(?:@from\(.*?\))?(.*)$/,"\\1 @from(#{i['section']}") @content['Archive']['items'].push(archive_item) @content[opt[:section]]['items'].delete_at(i) else @results.push(%Q{Completed "#{@content[opt[:section]]['items'][i]['title']}"}) end end } @results.push("No active @#{tag} tasks found.") if found_items == 0 if opt[:new_item] title, note = format_input(opt[:new_item]) note.push(opt[:note].gsub(/ *$/,'')) if opt[:note] title += " @#{tag}" add_item(title.cap_first, opt[:section], {:note => note.gsub(/ *$/,''), :back => opt[:back]}) end write(@doing_file) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def todo_tag(text); end", "def tag(new_tag); end", "def abstract_tag(text); end", "def add( item)\n\t\titem.addtag self.gettag\n\tend", "def example_tag(text); end", "def parse_tag_with_types_and_title(tag_name, text); end", "def note_tag(text); end", "def see_tag(text); end", "def update_raw_text(...
[ "0.6862956", "0.6773321", "0.6589801", "0.65598667", "0.64776516", "0.64729863", "0.6448899", "0.6410626", "0.63967294", "0.63967294", "0.63520616", "0.6279996", "0.6189386", "0.61657596", "0.6159688", "0.6152599", "0.6128166", "0.6116789", "0.6102744", "0.608714", "0.5912302...
0.0
-1
Uses autotag: configuration to turn keywords into tags for time tracking. Does not repeat tags in a title, and only converts the first instance of an untagged keyword
def autotag(title) return unless title @config['autotag']['whitelist'].each {|tag| title.sub!(/(?<!@)(#{tag.strip})\b/i) do |m| m.downcase! if tag =~ /[a-z]/ "@#{m}" end unless title =~ /@#{tag}\b/i } tail_tags = [] @config['autotag']['synonyms'].each {|tag, v| v.each {|word| if title =~ /\b#{word}\b/i tail_tags.push(tag) end } } if tail_tags.length > 0 title + ' ' + tail_tags.uniq.map {|t| '@'+t }.join(' ') else title end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def auto_tag!\n tags = self.body.scan(/(?<=#)\\S+/).map{ |ts| J::Tag.find_or_create_by(name: ts) }\n self.tags = tags\n end", "def autotag(string)\n return unless string\n return string unless Doing.auto_tag\n\n original = string.dup\n text = string.dup\n\n current_tags = text.sca...
[ "0.6610083", "0.63007635", "0.5847165", "0.57939935", "0.5783745", "0.57753485", "0.573175", "0.55864877", "0.5572811", "0.55698454", "0.552362", "0.55158406", "0.55103374", "0.5487168", "0.54627097", "0.54627097", "0.54492545", "0.54342014", "0.5370436", "0.5332789", "0.5323...
0.74938774
0
Given a hash with numeric values, return the key for the smallest value
def key_for_min_value(name_hash) if name_hash == {} return nil else right_key = "" right_value = "" name_hash.each do |key, value| if right_value == "" right_key = key right_value = value elsif value < right_value right_key = key right_value = value end end right_key end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def key_for_min_value(hash)\n lowest_key = nil\n lowest_value = Float::INFINITY\n hash.each do |key, value|\n if value < lowest_value\n lowest_value = value\n lowest_key = key\n end\n end\n lowest_key\nend", "def key_for_min_value(hash)\n lowest_key = nil\n lowest_value = Float::INFINITY\n...
[ "0.8821222", "0.8777674", "0.87769854", "0.8745862", "0.8689437", "0.86553806", "0.865241", "0.86165065", "0.8587693", "0.8572328", "0.85674095", "0.8550907", "0.8529734", "0.8529734", "0.85182345", "0.84936565", "0.8475531", "0.8475531", "0.8466132", "0.8449126", "0.84490585...
0.0
-1
returns the header_content page part for the given page slug
def header_content_for_page(slug) content = "" @slug_page ||= Page.find_by_slug(slug) if @slug_page content = @slug_page.part_content("header_content") end content end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def title_tag_for_page(slug)\n content = \"\"\n \n @slug_page ||= Page.find_by_slug(slug)\n \n if @slug_page\n content = @slug_page.part_content(\"title_tag\")\n end\n \n content\n end", "def content_for(part_slug)\n part_with_slug(part_slug).try(:body)\n end", "def body_c...
[ "0.7164687", "0.7111337", "0.6538764", "0.65150076", "0.62412447", "0.61441344", "0.6131874", "0.6004456", "0.587571", "0.5837695", "0.5785475", "0.5785475", "0.5770436", "0.57590425", "0.5757612", "0.5733365", "0.5725819", "0.5709662", "0.5694118", "0.5691494", "0.56718946",...
0.8895231
0
returns the body_class page part for the given page slug
def body_class_for_page(slug) content = "" @slug_page ||= Page.find_by_slug(slug) if @slug_page content = @slug_page.part_content("body_class") end content end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def body_class(class_name=\"page\")\n content_for :body_class, class_name\n end", "def page_classes(page)\n classes = []\n classes << 'home' if page.home?\n classes << page.class.name.underscore.dasherize\n classes.join ' '\n end", "def body_class\n ssv = []\n ssv << 'home' if is_home?\n...
[ "0.6548584", "0.64037114", "0.6304561", "0.6169498", "0.6110914", "0.6105468", "0.6103271", "0.6056024", "0.6032401", "0.5982034", "0.5982034", "0.59597903", "0.5890185", "0.585033", "0.582105", "0.5819807", "0.5811125", "0.57780415", "0.573365", "0.57073814", "0.5699461", ...
0.89628255
0
returns the title_tag page part for the given page slug
def title_tag_for_page(slug) content = "" @slug_page ||= Page.find_by_slug(slug) if @slug_page content = @slug_page.part_content("title_tag") end content end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def page_title\n case\n when @post\n \"#{@post.title} - Ben Hoad\"\n when @tag\n \"Tagged with ##{@tag} - Ben Hoad\"\n else\n \"Ben Hoad\"\n end\n end", "def page_title\n page.title\n end", "def slug; (page.slug rescue ''); end", "def slug; (page.slug re...
[ "0.7139907", "0.7102421", "0.7093065", "0.7093065", "0.70611376", "0.70119417", "0.69910127", "0.69596213", "0.68924975", "0.6889632", "0.688845", "0.67259604", "0.67128634", "0.67103714", "0.6707617", "0.67018086", "0.6687012", "0.6679875", "0.66796714", "0.6677577", "0.6671...
0.87427586
0
Helper to determine an instance of the model to which an object is related to in case there is a polymorphic relation. e.g. if new picture is related to Business and Review but a picture related to an instance of Business model is created, associated_record returns the instance of Business model the picture is related to.
def associated_record(params) relationship = relationships(params).keys[0] relationship.camelize.constantize.friendly_uuid_find!(relation_id(params, relationship.to_sym)) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_association_model(association)\n (association == :self) ? self : self.reflect_on_association(association.to_sym).klass\n end", "def target_class\n if reflection.polymorphic?\n base_model.send(reflection.foreign_type).constantize\n else\n reflection.klass\n e...
[ "0.6226397", "0.60785913", "0.607688", "0.60131764", "0.5983371", "0.59285223", "0.5870443", "0.5699502", "0.5596186", "0.55820465", "0.55708957", "0.5513492", "0.5510044", "0.55026627", "0.5471223", "0.54574347", "0.545122", "0.5451142", "0.54508823", "0.5444363", "0.5444363...
0.6112536
1
Helper for returning associated records of resource. Firstly it finds a resource (using either slug if supported or plain id), then checks if it should return the records.
def authorized_resource_with_includes_find(resource_class, association) resource = get_current_user_with_includes(association) if resource_class == User && params[:id].nil? resource ||= get_resource(resource_class.includes(association)) resource.tap do |res| authorize res, "show_#{association}?".to_sym end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def load_resource\n query = eager_load(resource_class)\n if resource_class.respond_to? :friendly_id\n query.friendly.find params[:id]\n else\n query.find params[:id]\n end\n end", "def ar_retrieve_resource(opts = {})\n @resource_relation ||= ar_model\n @resource_relation = ar_model.i...
[ "0.6292835", "0.61984766", "0.60944015", "0.6002636", "0.59995013", "0.5939507", "0.58978665", "0.58580023", "0.58523345", "0.5824505", "0.58204997", "0.57919306", "0.57756114", "0.5760734", "0.5718781", "0.5716896", "0.5669784", "0.56656057", "0.562346", "0.56187356", "0.559...
0.0
-1
Helper for standard resource update. Firstly it checks if provided ids differ, then authorize action, updates resource and finaly ruturns 204 no body status.
def update_resource(resource, params) check_id_uniformity(params) resource.assign_attributes(json_api_attributes(params)) authorize resource, :update? resource.save! resource end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_resource_by_id(authorization, \n id, \n update_resource_by_id_body = nil)\n\n # prepare query url\n _query_builder = Configuration.get_base_uri()\n _query_builder << '/resources/{id}'\n _query_builder = APIHelper.append_url_wi...
[ "0.66404116", "0.6389578", "0.6289442", "0.6276393", "0.60987914", "0.6068396", "0.6063604", "0.6061937", "0.6033769", "0.60307544", "0.60212886", "0.6014286", "0.5993092", "0.59711426", "0.59670824", "0.59594554", "0.5936073", "0.59354556", "0.5933531", "0.5931983", "0.59309...
0.6348501
2
NOTE: We generally test error conditions before OK conditions here. Since we're testing a matcher, checking for `exp_not_met` is also a regular OK case. A shortcut for a quoted Regexp constructor. rx('expected: ["1", ".?", "/3/"]') etc.
def rx(s) Regexp.new(Regexp.escape(s)) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def assert_match exp, act, msg = nil\n msg = message(msg) { \"Expected #{mu_pp(exp)} to match #{mu_pp(act)}\" }\n assert_respond_to act, \"=~\"\n exp = Regexp.new(Regexp.escape(exp)) if String === exp\n assert act =~ exp, msg\n end", "def test_match \n begin\n md = @regexp =~ @s\n ...
[ "0.6102069", "0.6080411", "0.59767604", "0.58153903", "0.5788544", "0.57605374", "0.57143897", "0.5710043", "0.570123", "0.5674982", "0.567111", "0.5663042", "0.5643125", "0.5643015", "0.56397873", "0.55329585", "0.55237347", "0.5519261", "0.5516597", "0.54953504", "0.5474766...
0.0
-1
temporary addition. will be replaced by 'main_address' once we acquire what the main address is from a person
def main_address addresses.first end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def secondary_address; end", "def add_address # rubocop:disable Metrics/AbcSize\n return unless @bib.place.any?\n\n reg = @bib.place[0].region[0].name if @bib.place[0].region.any?\n addr = [@bib.place[0].name, @bib.place[0].city, reg]\n @item.address = addr.compact.join(\", \")\n ...
[ "0.7080134", "0.6700149", "0.6685086", "0.6565648", "0.65624666", "0.6561436", "0.64557993", "0.6453334", "0.645102", "0.64357984", "0.64335424", "0.64245486", "0.6420486", "0.6415653", "0.6381937", "0.6359036", "0.6358869", "0.6357357", "0.633789", "0.63278085", "0.63124746"...
0.73930347
0
Returns a cache key that can be used to identify this photo
def cache_key [super, user.try(:cache_key)].compact.join('/') end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def generate_photo_cache_key(photo_id:)\n \"flickr_photo/#{photo_id}\"\n end", "def cache_key\n name.to_s\n end", "def cache_key\n \"#{self.class.cache_key_base}/#{self.id}\"\n end", "def cache_key\n end", "def cache_key\n Digest::SHA1.hexdigest \"#{self.class.name}#{bas...
[ "0.82171184", "0.81359833", "0.8092021", "0.8022915", "0.79373485", "0.778045", "0.77478826", "0.7667832", "0.7498665", "0.74615735", "0.74504584", "0.7403831", "0.7359736", "0.7338422", "0.7336387", "0.7283753", "0.7208573", "0.7207339", "0.7207042", "0.7152031", "0.714166",...
0.7119155
26
Returns the last time this photo or the associated user was touched
def last_modified [updated_at, user.try(:updated_at)].max end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def modified_at\n @photo.updated.to_datetime.utc\n end", "def last_edited_time\n begin\n $redis.hget 'last_edit:instrument', self.id\n rescue\n nil\n end\n end", "def last_updated_time\n data[:last_updated_time]\n end", "def last_time\n @last_time\n end", "def last_updat...
[ "0.6896479", "0.67174035", "0.6691389", "0.66015166", "0.6488707", "0.6488707", "0.6488707", "0.6488707", "0.64825124", "0.6437273", "0.6437273", "0.6437273", "0.6437273", "0.6437273", "0.6437273", "0.6437273", "0.6437273", "0.6437273", "0.6437273", "0.6437273", "0.6437273", ...
0.67814136
1
Get a list of job summaries GET /jobs
def job_summaries(params = {}) # rubocop:disable Style/OptionHash query = { "statusGroups": "ALL", # JOB_STATUS_GROUPS "sortBy": "created", # "count", "title", "lead", "created", "status" "sortOrder": "ASC" # "ASC", "DESC" }.merge(params) request(:get, "applicant_tracking/jobs", query: query) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def list_jobs(json_payload={})\n conn = @client.get do |req|\n req.url '/api/v2/job/list?'\n req.headers[\"Authorization\"] = @token\n req.params = json_payload\n end\n conn.body\n end", "def jobs(opts = {})\n api(\n @client.list_jobs(\n ...
[ "0.77218395", "0.746117", "0.74526215", "0.7441141", "0.7414207", "0.7331995", "0.7302135", "0.7262121", "0.72499275", "0.72499275", "0.72499275", "0.72499275", "0.72499275", "0.72499275", "0.71930206", "0.7116629", "0.7073411", "0.70701414", "0.7010662", "0.70095384", "0.699...
0.7861452
0
Get a list of applications, following pagination GET /applications
def applications(params = {}) # rubocop:disable Style/OptionHash page_limit = params.delete(:page_limit) { 1 } applications_array = [] 1.upto page_limit do |i| response = request_applications(params.merge(page: i)) applications_array += response["applications"] break if response["paginationComplete"] end applications_array end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def applications_list\n get \"applications\"\n end", "def applications\n Application.from session.get 'operations/application', API_V1\n end", "def applications(options = {})\n @applications = api.get_applist if !@applications\n @applications\n end", "def get_applications\n ...
[ "0.87946963", "0.78359675", "0.7800434", "0.77287054", "0.76489466", "0.761755", "0.7616506", "0.7579191", "0.7579191", "0.7579191", "0.7579191", "0.75679946", "0.7552262", "0.73903817", "0.7366789", "0.7336402", "0.7335249", "0.7310203", "0.72693866", "0.72308815", "0.722902...
0.85279393
1
Get the details of an application GET /applications/:id
def application(applicant_id) request(:get, "applicant_tracking/applications/#{applicant_id}") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get(id)\n response = Network.get(['Applications', id])\n Application.new(response)\n end", "def show\n @application = Application.find(params[:id])\n end", "def show\n @application = Application.find(params[:id])\n end", "def app_by_id(id)\n get(\"/apps/#{id}\")\n ...
[ "0.82386005", "0.82147247", "0.81260365", "0.80975026", "0.7891961", "0.78621876", "0.78621876", "0.7855958", "0.7744247", "0.7678909", "0.75795466", "0.7328704", "0.72891426", "0.7271243", "0.71601087", "0.71601087", "0.71601087", "0.7146693", "0.7112435", "0.7040706", "0.70...
0.6841554
27
Add comments to an application POST /applications/:id/comments
def add_comment(applicant_id, comment) details = { type: "comment", comment: comment }.to_json options = { body: details, headers: { "Content-Type" => "application/json" } } request(:post, "applicant_tracking/applications/#{applicant_id}/comments", options) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @comment = Comment.create(content: params[:content])\n current_user.comments << @comment\n current_user.save\n\n idea = Idea.find(params[:ideaId])\n idea.comments << @comment\n idea.comments.order(\"created_at DESC\")\n idea.save\n respond_to do |format|\n format.json {ren...
[ "0.61512876", "0.6100358", "0.59255856", "0.59255856", "0.59255856", "0.5892135", "0.5874475", "0.5790468", "0.578525", "0.56986123", "0.56195366", "0.560897", "0.5605689", "0.5591543", "0.55852544", "0.55535424", "0.5534293", "0.5530625", "0.5530082", "0.5515354", "0.5510741...
0.70347595
0
Get a list of statuses for a company GET /statuses
def statuses request(:get, "applicant_tracking/statuses") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def statuses\n Sifter.\n get(\"/api/statuses\").\n parsed_response[\"statuses\"]\n end", "def statuses\n api.get('status')\n end", "def list_statuses(user, list)\n get(\"/#{user}/lists/#{list}/statuses.json\")\n end", "def index\n @statuses = Status.all\n end", "def index\...
[ "0.8111472", "0.7712566", "0.73654735", "0.7189553", "0.7189553", "0.7131381", "0.70960724", "0.70813876", "0.7072944", "0.6965537", "0.69280165", "0.68560684", "0.6809256", "0.6790572", "0.6692649", "0.6676152", "0.6669938", "0.66577554", "0.66390514", "0.6634723", "0.663098...
0.7392715
2
Change applicant's status POST /applications/:id/status
def change_status(applicant_id, status_id) details = { status: status_id.to_i }.to_json options = { body: details, headers: { "Content-Type" => "application/json" } } request(:post, "applicant_tracking/applications/#{applicant_id}/status", options) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_app_status\n @app_status = AppStatus.find(params[:id])\n end", "def status_updated\n new_status = params[:new_status]\n id = params[:id]\n application = EventApplication.find_by(user_id: id)\n application.status = new_status\n application.save(:validate => false)\n flash[:succes...
[ "0.75890446", "0.724024", "0.7224821", "0.7083324", "0.68390423", "0.6806999", "0.67153627", "0.6650212", "0.6604857", "0.6549975", "0.6517904", "0.6516687", "0.64611864", "0.6445602", "0.64409107", "0.64320064", "0.63934696", "0.6372577", "0.6372107", "0.63658965", "0.636589...
0.79391515
0
GET /jobsites GET /jobsites.json
def index @jobsites = Jobsite.all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @jobs = Job.all\n\n render json: @jobs\n end", "def index\n @jobs = Job.all\n render json: @jobs\n end", "def index\n @jobs = current_user.jobs\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @jobs }\n end\n end", "def index...
[ "0.70450765", "0.7035387", "0.6970419", "0.69405013", "0.6905687", "0.6840646", "0.6789795", "0.6766813", "0.6677228", "0.66553694", "0.659517", "0.65687114", "0.656583", "0.65428066", "0.65262043", "0.6480038", "0.64546156", "0.6413426", "0.6405583", "0.64006424", "0.6400293...
0.74203616
1
GET /jobsites/1 GET /jobsites/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @jobs = Job.all\n\n render json: @jobs\n end", "def index\n @jobs = Job.all\n render json: @jobs\n end", "def index\n @jobsites = Jobsite.all\n end", "def index\n @jobsites = Jobsite.all\n end", "def index\n @jobs = current_user.jobs\n\n respond_to do |format|\n ...
[ "0.7113349", "0.709993", "0.70890284", "0.70890284", "0.70171463", "0.699673", "0.69071186", "0.6877797", "0.6870899", "0.68652475", "0.68509215", "0.6830221", "0.6820617", "0.6815443", "0.6732569", "0.6726849", "0.67175037", "0.6691201", "0.6678366", "0.6655584", "0.66500545...
0.0
-1
POST /jobsites POST /jobsites.json
def create @jobsite = Jobsite.new(jobsite_params) respond_to do |format| if @jobsite.save format.html { redirect_to @jobsite, notice: 'Jobsite was successfully created.' } format.json { render :show, status: :created, location: @jobsite } else format.html { render :new } format.json { render json: @jobsite.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @job = current_user.posted_jobs.build(job_params)\n if @job.save\n render json: @job\n else\n render json: @job.errors.full_messages, status: :unprocessable_entity\n end\n end", "def index\n @jobsites = Jobsite.all\n end", "def index\n @jobsites = Jobsite.all\n end",...
[ "0.63936996", "0.6280419", "0.6280419", "0.6035561", "0.6013581", "0.6005676", "0.6002905", "0.59798616", "0.5934883", "0.5916979", "0.5901784", "0.58963364", "0.58533883", "0.58302045", "0.58302045", "0.58238524", "0.581845", "0.58178085", "0.5796334", "0.5795649", "0.577946...
0.5936609
8
PATCH/PUT /jobsites/1 PATCH/PUT /jobsites/1.json
def update respond_to do |format| if @jobsite.update(jobsite_params) format.html { redirect_to @jobsite, notice: 'Jobsite was successfully updated.' } format.json { render :show, status: :ok, location: @jobsite } else format.html { render :edit } format.json { render json: @jobsite.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n job = Job.find(params[:id])\n job.update_attributes(job_params)\n render json: job\n end", "def update\n begin\n @job_request = job_requests.find( params[ :id ] )\n rescue ActiveRecord::RecordNotFound\n @job_request = nil\n end\n\n respond_to do |format|\n ...
[ "0.69928473", "0.69602", "0.6852725", "0.68327415", "0.6831508", "0.6831508", "0.6831508", "0.673164", "0.6726895", "0.6723068", "0.670784", "0.66889334", "0.66700107", "0.6663613", "0.6659347", "0.66031975", "0.65903276", "0.65872955", "0.6554506", "0.6538182", "0.6532945", ...
0.0
-1
DELETE /jobsites/1 DELETE /jobsites/1.json
def destroy @jobsite.destroy respond_to do |format| format.html { redirect_to jobsites_url, notice: 'Jobsite was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete(id)\n connection.delete do |req|\n req.url \"job/#{id}\"\n end\n end", "def destroy\n @jobsite.destroy\n respond_to do |format|\n format.html { redirect_to jobsites_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @job = @user.j...
[ "0.7350004", "0.71954113", "0.7119218", "0.71013135", "0.71013135", "0.71013135", "0.71013135", "0.71009505", "0.70856166", "0.7082857", "0.707775", "0.70766455", "0.7064885", "0.70632493", "0.70543724", "0.7050449", "0.7049655", "0.70347095", "0.70015323", "0.7000815", "0.69...
0.6881696
37
Use callbacks to share common setup or constraints between actions.
def set_jobsite @jobsite = Jobsite.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_...
[ "0.6163163", "0.6045976", "0.5946146", "0.591683", "0.5890051", "0.58349305", "0.5776858", "0.5703237", "0.5703237", "0.5652805", "0.5621621", "0.54210985", "0.5411113", "0.5411113", "0.5411113", "0.5391541", "0.53794575", "0.5357573", "0.53402257", "0.53394014", "0.53321576"...
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def jobsite_params params.require(:jobsite).permit(:name, :street, :city, :state, :zip) 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.6981537", "0.67835593", "0.6748275", "0.67436063", "0.6736311", "0.65937173", "0.6503359", "0.6498499", "0.6482832", "0.6478776", "0.645703", "0.6439998", "0.63802195", "0.6377008", "0.6366287", "0.632018", "0.63016284", "0.63011277", "0.62932974", "0.62919617", "0.6290564...
0.0
-1
Name: Consecutive Strings Difficulty: 6 sources Website: Provided by: Adeel Attempted by: Wendy PSEUDOCODE Declare a variable to hold longest string Declare a variable to compare a new string to our previous longest string IF k is negative, zero or bigger than the input array's size, return an empty string ELSE iterate over the input array Set the new string variable to the current sum of elements IF our longest string is smaller than the current string, grab its value ELSE our longest string remains with the previous value OBJECTIVE: Return the longest string value
def longest_consec(strarr, k) longest_str = "" new_str = "" if k <= 0 || k > strarr.count longest_str else strarr.each.with_index do |str, i| new_str = strarr[i..k+i-1].join longest_str.length < new_str.length ? longest_str = new_str : longest_str end longest_str end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def longest_consec(strarr, k)\n if strarr.length == 0 || k>strarr.length || k<=0\n \"\"\n else\n strarr.each_cons(k).map {|group| group.join}.max_by {|string| string.length}\n end\nend", "def longest_consec(strarr, k)\n if strarr.empty? || k <= 0 || k > strarr.length\n return \"\"\n else\n strarr....
[ "0.8041365", "0.8021315", "0.792394", "0.78638035", "0.77455163", "0.77203363", "0.7559266", "0.7510174", "0.7332884", "0.7294302", "0.7268858", "0.7246451", "0.7219226", "0.71927184", "0.716014", "0.7135137", "0.7103048", "0.7091685", "0.70756394", "0.7013094", "0.6987099", ...
0.788144
3
Create a new Logic instance
def initialize(battle_scene) @battle_scene = battle_scene @battle_info = battle_scene.battle_info Message.setup(self) @messages = [] # @type [Array<Hash>] @actions = [] @bags = [] @battlers = [] @global_states = {} @bank_states = Hash.new({}) @battle_result = -1 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_logic\n return Battle::Logic.new(self)\n end", "def create\n @logic = Logic.new(params[:logic])\n\n respond_to do |format|\n if @logic.save\n format.html { redirect_to @logic, notice: 'Logic was successfully created.' }\n format.json { render json: @logic, status: :cre...
[ "0.7793518", "0.66523737", "0.5881993", "0.57741016", "0.57238", "0.57238", "0.56102085", "0.5606528", "0.5550838", "0.55333006", "0.5504064", "0.5451733", "0.5422059", "0.5419884", "0.5419047", "0.54155135", "0.5405659", "0.53956044", "0.5351945", "0.5305585", "0.5300738", ...
0.0
-1
Return the number of bank in the current battle
def bank_count return @battlers.size end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def battler_count(bank)\n count = 0\n $game_temp.vs_type.times { |i| count += 1 if battler(bank, i)&.dead? == false }\n return count\n end", "def count_ai_battler\n count = -1\n @battle_info.parties.each do |bank|\n count += bank.size\n end\n log_debug(\"Found #{count...
[ "0.76156884", "0.712378", "0.70337045", "0.6666342", "0.66432196", "0.65991056", "0.6571031", "0.63939804", "0.63801", "0.62270343", "0.6203678", "0.61979085", "0.61792773", "0.6156825", "0.61017686", "0.6080581", "0.6080581", "0.6066413", "0.60588557", "0.6045667", "0.602753...
0.83687836
0
Tell if the battle can continue
def can_battle_continue? return false if @battle_result >= 0 banks_that_can_fight = [] @battlers.each_with_index do |battler_bank, bank| battler_bank.each do |battler| break(banks_that_can_fight << bank) if battler&.can_fight? end end # It's a victory if the player still have a Pokemon on its bank if banks_that_can_fight.size <= 1 @battle_result = banks_that_can_fight.include?(0) ? 0 : 1 return false end return true end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def finished?\n @turns_allowed < 0\n end", "def can_battle?(id)\n has_pokemon?(id) && (Graphics.current_time - get(id)[:slather_time]) > WAIT_TO_BATTLE\n end", "def won?\n @game.started? && !detectives_won? && detectives_cannot_move?\n end", "def start_battle\n self.go_to_pokemon_cente...
[ "0.73972607", "0.6971537", "0.6841954", "0.68143797", "0.6739615", "0.6714177", "0.6700573", "0.66655415", "0.66563857", "0.6630062", "0.66173905", "0.659354", "0.6591867", "0.65599316", "0.6548355", "0.65400505", "0.6531308", "0.6524227", "0.65102273", "0.6504524", "0.647168...
0.76676744
0
Load the RNG for the battle logic
def load_rng(seeds = Hash.new(Random.new_seed)) @move_damage_rng = Random.new(seeds[:move_damage_rng]) @move_critical_rng = Random.new(seeds[:move_critical_rng]) @move_accuracy_rng = Random.new(seeds[:move_accuracy_rng]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def load_seed; end", "def load_seed; end", "def initialize\n srand\n end", "def load_seed\n s1 = Station.new('Moscow')\n s2 = Station.new('St.Petersburg')\n s3 = Station.new('Novosibirsk')\n s4 = Station.new('Chelyabinsk')\n s5 = Station.new('Khabarovsk')\n\n t1 = PassengerTrain.new('PA...
[ "0.64205563", "0.64205563", "0.6048658", "0.6024046", "0.58516634", "0.58516634", "0.57599354", "0.57531863", "0.57463354", "0.57346207", "0.5694414", "0.5678315", "0.55972433", "0.5583655", "0.55766207", "0.55739814", "0.5554635", "0.5545821", "0.55336636", "0.5529508", "0.5...
0.7553762
0