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
end test Test that the graph class will not let you to_s on an incomplete graph
def test_graph_to_s_incomplete sut_graph = Graph.new sut_graph.name="test_graph" #sut_graph.type=:digraph sut_graph.node_style=:ellipse sut_graph.add_edge("TEST1" , "TEST2" , "take_me_to_test_2") assert_raises RuntimeError do returned_obj = sut_graph.to_s end # end assert end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_to_s_empty_graph\n graph = Graph.new\n\n assert(graph.to_s == '')\n end", "def test_to_s\n graph = DirectedGraph.new\n vertex_a = Vertex.new('a')\n vertex_b = Vertex.new('b')\n vertex_c = Vertex.new('c')\n graph.add_vertex(vertex_a).add_vertex(vertex_b).add_vertex(vertex_c)\n gr...
[ "0.8240558", "0.7790349", "0.77343917", "0.767811", "0.7484956", "0.68562925", "0.6537316", "0.65276414", "0.65032285", "0.6472538", "0.6434005", "0.63676643", "0.6310323", "0.6239692", "0.6239692", "0.6225078", "0.61920583", "0.61881006", "0.61529404", "0.611738", "0.607198"...
0.8398824
0
flag and close activity
def reported @activities = Activity.flagged_or_close.order("created_at desc"). not_undo.paginate(:per_page=>default_per_page,:page=>params[:page]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def close \n #Self trigger window lost focus, since we are going to home\n focus_changed false, @screen_width, @screen_height\n @showing = false\n @activity.moveTaskToBack(true)\n end", "def closeeye()\n\t\t@opened_eye = false\n\tend", "def close; true; end", "def close; true; end"...
[ "0.63778806", "0.5755592", "0.57464164", "0.57464164", "0.57203835", "0.5671849", "0.5651762", "0.5592362", "0.5582573", "0.5580761", "0.5578875", "0.5577521", "0.55613935", "0.5553227", "0.55531317", "0.55365914", "0.54902256", "0.5468107", "0.5461585", "0.5455934", "0.54559...
0.0
-1
Stubs SOAP requests to a given soap_action.
def stubs(soap_action) setup :stubs, soap_action self end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def dispatch(soap_action)\n response = @request.soap @soap\n Response.new response\n end", "def setup(soap_action, &block)\n @soap = SOAP.new @wsdl.soap_actions[soap_action]\n @wsse = WSSE.new\n\n yield_parameters &block if block\n\n @soap.namespaces[\"xmlns:wsdl\"] = @wsdl.names...
[ "0.7005628", "0.6440213", "0.63615036", "0.6125479", "0.6076433", "0.60549504", "0.58985615", "0.5896121", "0.58701813", "0.5791605", "0.5756803", "0.5471734", "0.5461388", "0.5436634", "0.5424589", "0.54219496", "0.54078627", "0.53144324", "0.53101104", "0.5275829", "0.52747...
0.80295694
0
Expects a given SOAP body Hash to be used.
def with(soap_body) Savon::SOAP::XML.any_instance.expects(:body=).with(soap_body) if mock_method == :expects self end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def find_soap_body\n envelope = self[self.keys.first] || {}\n body_key = envelope.keys.find { |key| /.+:Body/ =~ key } rescue nil\n body_key ? envelope[body_key].map_soap_response : {}\n end", "def soap_body(env)\n env['rack.input'].respond_to?(:string) ? env['rack.input'].string\n ...
[ "0.5992388", "0.5599322", "0.55401725", "0.52851087", "0.51988", "0.5166695", "0.5096424", "0.5090427", "0.50637686", "0.50632364", "0.5051357", "0.50453806", "0.50090665", "0.49846715", "0.4972368", "0.49688593", "0.49623933", "0.49608627", "0.49439153", "0.49319795", "0.492...
0.585774
1
Sets up HTTPI to return a given +response+.
def returns(response = nil) http = { :code => 200, :headers => {}, :body => "" } case response when Symbol then http[:body] = Fixture[soap_action, response] when Hash then http.merge! response end httpi_mock.returns HTTPI::Response.new(http[:code], http[:headers], http[:body]) self end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def response=(response); @response = response end", "def handle_response(response); end", "def handle_response(response); end", "def prepare_response(response)\n response\n end", "def setup\n @response ||= {}\n end", "def set_response(response, body, status = 200)\n raise NotImplemente...
[ "0.6912565", "0.68331957", "0.68331957", "0.67839104", "0.67219913", "0.66436416", "0.66436416", "0.6630335", "0.6616575", "0.64495313", "0.64495313", "0.64495313", "0.64495313", "0.6409897", "0.6359536", "0.6346745", "0.62924343", "0.62924343", "0.62924343", "0.62924343", "0...
0.0
-1
Sets up Savon to respond like there was a SOAP fault.
def raises_soap_fault Savon::SOAP::Response.any_instance.expects(:soap_fault?).returns(true) self end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def format_soap_faults\n fault = self.hash[:envelope][:body].delete(\"soap:Fault\") || self.hash[:envelope][:body].delete(:fault)\n self.errors << (fault[:faultstring] || fault[\"faultstring\"])\n self.valid = false\n end", "def raise_errors\n message = 'FIXME: Need to parse http for res...
[ "0.614185", "0.6041459", "0.60386366", "0.6015774", "0.59535646", "0.5841786", "0.5819629", "0.5807705", "0.5764952", "0.5753135", "0.5753135", "0.57317203", "0.5716532", "0.5706272", "0.566745", "0.5649483", "0.5637122", "0.5628838", "0.5577762", "0.5465068", "0.54605436", ...
0.6792786
0
Wrap tests that use Mocha and skip if unavailable.
def uses_mocha(test_name) require 'mocha' unless Object.const_defined?(:Mocha) rescue LoadError => load_error $stderr.puts "Skipping #{test_name} tests. `gem install mocha` and try again." else yield end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def uses_mocha(test_name)\n require 'mocha'\n yield\nrescue LoadError\n $stderr.puts \"Skipping #{test_name} tests. `gem install mocha` and try again.\"\nend", "def uses_mocha(test_name)\n unless Object.const_defined?(:Mocha)\n gem 'mocha', '>= 0.9.5'\n require 'mocha'\n end\nrescue LoadError => load_...
[ "0.7830533", "0.7767795", "0.59468395", "0.59468395", "0.57822424", "0.5688788", "0.5685269", "0.56059647", "0.55875677", "0.5562946", "0.5555831", "0.55513185", "0.55316496", "0.55299443", "0.55291027", "0.5526648", "0.55130935", "0.547739", "0.5475869", "0.5448887", "0.5441...
0.7847089
0
lexer rules lexer rule t__6! (T__6) (in CSV.g)
def t__6! # -> uncomment the next line to manually enable rule tracing # trace_in( __method__, 1 ) type = T__6 channel = ANTLR3::DEFAULT_CHANNEL # - - - - main rule block - - - - # at line 7:8: '+' match( 0x2b ) @state.type = type @state.channel = channel ensure # -> uncomment the next line to manually enable rule tracing # trace_out( __method__, 1 ) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def t__63!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 2 )\n\n type = T__63\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at line 8:9: '\\\\n'\n match( 0xa )\n\n \n @state.type = type\n...
[ "0.64735585", "0.6448308", "0.64443517", "0.6433646", "0.64273816", "0.6420842", "0.6401554", "0.63948524", "0.63883007", "0.63377064", "0.6299572", "0.6292796", "0.62752616", "0.6272566", "0.626987", "0.62571025", "0.6247509", "0.62355816", "0.6226294", "0.6211529", "0.62088...
0.65833735
0
lexer rule number! (NUMBER) (in CSV.g)
def number! # -> uncomment the next line to manually enable rule tracing # trace_in( __method__, 2 ) type = NUMBER channel = ANTLR3::DEFAULT_CHANNEL # - - - - main rule block - - - - # at line 11:10: ( '0' .. '9' )+ # at file 11:10: ( '0' .. '9' )+ match_count_1 = 0 while true alt_1 = 2 look_1_0 = @input.peek( 1 ) if ( look_1_0.between?( 0x30, 0x39 ) ) alt_1 = 1 end case alt_1 when 1 # at line 11:11: '0' .. '9' match_range( 0x30, 0x39 ) else match_count_1 > 0 and break eee = EarlyExit(1) raise eee end match_count_1 += 1 end @state.type = type @state.channel = channel ensure # -> uncomment the next line to manually enable rule tracing # trace_out( __method__, 2 ) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def num!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 5 )\n\n type = NUM\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at line 37:9: ( '1' .. '9' ) ( '0' .. '9' )*\n # at line 37:9: ( '1' .. '9' )...
[ "0.7435637", "0.71241164", "0.68142223", "0.6804753", "0.67911065", "0.664575", "0.66360193", "0.66350996", "0.6434702", "0.63688004", "0.6323316", "0.62384313", "0.6213848", "0.62036186", "0.6157369", "0.60919815", "0.60741335", "0.6072288", "0.597126", "0.5920029", "0.59157...
0.7509113
0
lexer rule space! (SPACE) (in CSV.g)
def space! # -> uncomment the next line to manually enable rule tracing # trace_in( __method__, 3 ) type = SPACE channel = ANTLR3::DEFAULT_CHANNEL # - - - - main rule block - - - - # at line 12:9: ( ' ' )+ # at file 12:9: ( ' ' )+ match_count_2 = 0 while true alt_2 = 2 look_2_0 = @input.peek( 1 ) if ( look_2_0 == 0x20 ) alt_2 = 1 end case alt_2 when 1 # at line 12:9: ' ' match( 0x20 ) else match_count_2 > 0 and break eee = EarlyExit(2) raise eee end match_count_2 += 1 end # --> action channel = HIDDEN # <-- action @state.type = type @state.channel = channel ensure # -> uncomment the next line to manually enable rule tracing # trace_out( __method__, 3 ) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delim!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 13 )\n\n\n\n type = DELIM\n channel = ANTLR3::DEFAULT_CHANNEL\n # - - - - label initialization - - - -\n\n\n # - - - - main rule block - - - -\n # at line 305:3: '|'\n match( 0x...
[ "0.72857696", "0.7151333", "0.7031983", "0.7002252", "0.6868628", "0.67804253", "0.6627531", "0.6617852", "0.6569228", "0.6249484", "0.6244152", "0.62422854", "0.6228803", "0.62190044", "0.61122173", "0.6088007", "0.60851634", "0.597342", "0.5960626", "0.59551775", "0.5930669...
0.7325442
0
main rule used to study the input at the current position, and choose the proper lexer rule to call in order to fetch the next token usually, you don't make direct calls to this method, but instead use the next_token method, which will build and emit the actual next token
def token! # at line 1:8: ( T__6 | NUMBER | SPACE ) alt_3 = 3 case look_3 = @input.peek( 1 ) when 0x2b then alt_3 = 1 when 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39 then alt_3 = 2 when 0x20 then alt_3 = 3 else raise NoViableAlternative( "", 3, 0 ) end case alt_3 when 1 # at line 1:10: T__6 t__6! when 2 # at line 1:15: NUMBER number! when 3 # at line 1:22: SPACE space! end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def next_token\n\n token = nil\n\n until ss.eos? or token do\n if ss.check(/\\n/) then\n self.lineno += 1\n # line starts 1 position after the newline\n self.start_of_current_line_pos = ss.pos + 1\n end\n self.old_pos = ss.pos\n token =\n case state\n wh...
[ "0.71777105", "0.7152235", "0.711723", "0.7098178", "0.70267206", "0.7022751", "0.7022216", "0.7018345", "0.70166904", "0.69872034", "0.69616836", "0.69474554", "0.69171876", "0.68387187", "0.67689776", "0.67452294", "0.66701007", "0.66021335", "0.6599689", "0.6596234", "0.65...
0.0
-1
GET /orders GET /orders.json
def index @orders = Order.user_orders current_user end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getorders(args={})\n {\n :method=> \"GetOrders\"\n }.to_json\n end", "def orders\n params = { command: 'account_orders' }\n get('/json.php', params)\n end", "def index\n @orders = Order.all\n render json: @orders\n end", "def index\n @orders = Order.all\n ...
[ "0.83267236", "0.815406", "0.80041754", "0.7947603", "0.7846487", "0.7823147", "0.78028905", "0.76992875", "0.76980406", "0.7682792", "0.7682792", "0.7682792", "0.7682792", "0.76827645", "0.75880665", "0.7574349", "0.756171", "0.7531827", "0.74860185", "0.7432208", "0.7369724...
0.0
-1
GET /orders/1 GET /orders/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getorders(args={})\n {\n :method=> \"GetOrders\"\n }.to_json\n end", "def index\n @orders = Order.all\n render json: @orders\n end", "def index\n @orders = Order.all\n render json: @orders, status: 200\n end", "def index\n @orders = Order.order(\"id\").all\n\n resp...
[ "0.7554187", "0.7488565", "0.7475228", "0.73777765", "0.73714006", "0.7341344", "0.73384553", "0.73168725", "0.73018956", "0.7291244", "0.7291244", "0.7291244", "0.7291244", "0.72911215", "0.7281374", "0.7266143", "0.72498786", "0.7228276", "0.7213504", "0.71842283", "0.71261...
0.0
-1
POST /parking_places/1/orders POST /parking_places/1/orders.json
def create @order = Order.payment(current_user, @parking_place, order_params[:booked_time].to_i, order_params[:payment]) begin respond_to do |format| if @order.save format.html { redirect_to @order, notice: t(:parking_place_successfully_booked) } format.json { render :show, status: :created, location: @order } else format.html { render :new } format.json { render json: @order.errors, status: :unprocessable_entity } end end rescue Order::NeedPayment respond_to do |format| format.html { render :payment } format.json { render json: @order.errors, status: :payment_required } end rescue Order::NotEnoughMoney respond_to do |format| format.html { render :payment } format.json { render json: @order.errors, status: :unprocessable_entity } end rescue Order::ParkingPlaceNotFree respond_to do |format| format.html { redirect_to root_path, alert: t(:parking_place_not_free) } format.json { render json: @order.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def submit_order()\n\tputs \"Submitting order\"\n\tdata = create_order()\n\tresponse = request_post(\"/api/order\", data)\n\tputs response.body\nend", "def create_order(order_params)\n res = request('post', \"https://#{orders_path}\", order_params)\n parse_response res\n end", "def orders\n a...
[ "0.692877", "0.6879032", "0.6749802", "0.665593", "0.66548663", "0.66374075", "0.6625363", "0.6558686", "0.6527811", "0.6513646", "0.6504733", "0.64470786", "0.6440704", "0.64008266", "0.6398549", "0.63868403", "0.6369669", "0.635966", "0.63524467", "0.6341479", "0.6336716", ...
0.0
-1
Use callbacks to share common setup or constraints between actions.
def set_order @order = Order.find_for_user(params[:id], current_user) 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 order_params params.require(:order).permit(:booked_time, :payment) 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
Returns an array of locations for a circle.
def get_circle(location, r) startY = location.y - r startX = 0 endX = 0 if startY % 2 == 0 startX = location.x - (r / 2.0).floor endX = location.x + r; else startX = location.x - (r / 2.0).floor endX = location.x + r; if r % 2 == 0 startX+=1; endX+=1; end end endY = location.y + r; circle_width = 2 * r + 1; delta_y_odd = -1; delta_y_even = -1; offset = 0; circle = Array.new; for y in Range.new(startY, endY) length = circle_width - (y - location.y).abs; if (y % 2 == 0) if (delta_y_even == -1) delta_y_even = (y - location.y).abs; end offset = ((y - location.y).abs - delta_y_even) / 2; if ((location.y - r) % 2 != 0) offset-=1; end else if (delta_y_odd == -1) delta_y_odd = (y - location.y).abs; end offset = (((y - location.y).abs - delta_y_odd) / 2.0).floor - 1; end start = startX + offset; #trace("y = " + y + "location = " + location.y + " : " + length); s = ""; for x in Range.new(start, start + length - 1) s += x.to_s + " "; circle.push(Location.new(x,y)); end #trace(s); end return circle; end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def points_for_circle(x, y, r)\n cur_page.points_for_circle(x, y, r)\n end", "def location(x, y, theta, distance)\n \t return [\n \t x + distance * Math.cos(theta),\n \t y - distance * Math.sin(theta)\n \t ]\n \tend", "def bresenham_circle_coordinates\n coordinates = []\n\n p...
[ "0.68248504", "0.67919993", "0.64993674", "0.64616084", "0.6434406", "0.6395247", "0.6297898", "0.62888646", "0.62259", "0.62119913", "0.61935437", "0.6125707", "0.6115966", "0.6093299", "0.60277575", "0.6024512", "0.6022414", "0.60211587", "0.59975594", "0.59971297", "0.5919...
0.700229
0
Initialize a Terminal Color
def initialize(options = {}) @enabled = options.fetch(:enabled) { supports? } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def initialize_colors\n Ncurses.start_color\n [[Ncurses::COLOR_RED, Ncurses::COLOR_WHITE],\n [Ncurses::COLOR_GREEN, Ncurses::COLOR_BLACK],\n [Ncurses::COLOR_YELLOW, Ncurses::COLOR_BLACK],\n [Ncurses::COLOR_BLUE, Ncurses::COLOR_WHITE],\n [Ncurses::COLOR_MAGENTA, Ncurses::COLOR_BLAC...
[ "0.73090994", "0.7153503", "0.71362793", "0.7011966", "0.6879383", "0.67821366", "0.6780507", "0.6735075", "0.67218095", "0.6625582", "0.6613872", "0.66080594", "0.65918624", "0.65684193", "0.6524045", "0.65139604", "0.6511712", "0.6473946", "0.63969326", "0.6395496", "0.6370...
0.0
-1
Disable coloring of this terminal session
def disable! @enabled = false end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def no_color\n add option: \"-no-color\"\n end", "def reset\n # color is enabled by default, can be turned of by switch --no-color\n Term::ANSIColor.coloring = true\n end", "def no_color\n reset_prev_formatting self, :color\n end", "def disable_color\n retu...
[ "0.74163955", "0.72037435", "0.70543873", "0.6912874", "0.6859117", "0.6782006", "0.66943157", "0.66922075", "0.66635287", "0.66455126", "0.66303605", "0.6624913", "0.66145134", "0.6604859", "0.65819734", "0.65725183", "0.6564395", "0.6548926", "0.6541174", "0.65066266", "0.6...
0.0
-1
Detect terminal color support
def supports? return false unless $stdout.tty? return false if ENV['TERM'] == 'dumb' if ENV['TERM'] =~ /^screen|^xterm|^vt100|color|ansi|cygwin|linux/i return true end return true if ENV.include?('COLORTERM') true end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def detect_colour_mode\n case ENV['TERM']\n when /-truecolor$/ then 16_777_216\n when /-256color$/, 'xterm' then 256\n when /-color$/, 'rxvt' then 16\n else 256\n end\n end", "def detect_colour_mode\n case ENV['TERM']\n when /-truecolor$/ then 16_777...
[ "0.8104025", "0.8104025", "0.79577106", "0.79177874", "0.7411239", "0.7368447", "0.7349984", "0.7342547", "0.73409164", "0.72787374", "0.7227641", "0.7131074", "0.7084524", "0.7057505", "0.70459276", "0.7007803", "0.6982087", "0.69002515", "0.68771774", "0.68199635", "0.67652...
0.66991824
24
Apply ANSI color to the given string.
def decorate(string, *colors) return string if string.empty? || !enabled validate(*colors) ansi_colors = colors.map { |color| lookup(color) } ansi_string = "#{ansi_colors.join}#{string}#{ANSI::CLEAR}" if ansi_string =~ /(#{Regexp.quote(ANSI::CLEAR)}){2,}/ ansi_string.gsub!(/(#{Regexp.quote(ANSI::CLEAR)}){2,}/, '') end matches = ansi_string.scan(/#{Regexp.quote(ANSI::CLEAR)}/) if matches.length >= 2 ansi_string.sub!(/#{Regexp.quote(ANSI::CLEAR)}/, ansi_colors.join) end ansi_string end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ansi_color(color, text)\n #\"\\x1b[38;5;#{color}m#{text}\\x1b[0m\"\n \"\\e[38;5;#{color}m#{text}\\e[0m\"\nend", "def colorize(str, color_code = 36)\n \"\\e[#{color_code}m#{str}\\e[0m\"\n end", "def colorize(string, code)\n \"\\e[#{code}m#{string}\\e[0m\"\n end", "def ansi(string, *codes...
[ "0.75238115", "0.7335181", "0.73001397", "0.72790354", "0.7220566", "0.71449566", "0.71449566", "0.7144078", "0.7144078", "0.71135604", "0.7083712", "0.7083712", "0.7083712", "0.7083712", "0.7083712", "0.70121366", "0.7001054", "0.6998708", "0.69800097", "0.6932377", "0.69105...
0.65859956
56
Strip ANSI color codes from a string.
def strip(string) string.to_s.gsub(/(\[)?\033(\[)?[;?\d]*[\dA-Za-z](\])?/, '') end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strip_ansi(str)\n str.gsub(ANSI, '')\n end", "def strip_ansi(str)\n str.gsub(\n ANSI_MATCHR, \"\"\n )\n end", "def strip_ansi(str)\n str.gsub(/\\e\\[(?:\\d+)(?:;\\d+)?m/, \"\")\n end", "def strip_color_codes(text); end", "def unansi(string)\n string.gsub(PATTERN, '')\n ...
[ "0.8508064", "0.830651", "0.7984447", "0.7951355", "0.7910524", "0.7729496", "0.76483184", "0.7619692", "0.7607166", "0.7519985", "0.7481777", "0.746306", "0.7399694", "0.7231407", "0.7126164", "0.71191233", "0.71106493", "0.68943185", "0.6791379", "0.65753347", "0.6528369", ...
0.7600902
9
Return raw color code without embeding it into a string.
def code(*colors) validate(*colors) colors.map { |color| lookup(color) } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def raw\n parsed_colors[:string].uncolor\n end", "def strip_color_codes(text); end", "def to_c\n\t\t\tif color == \"white\"\n\t\t\t\t\"\\u26aa\"\n\t\t\telsif color == \"red\"\n\t\t\t\t\"\\u26d4\"\n\t\t\telsif color == \"black\"\n\t\t\t\t\"\\u26ab\"\n\t\t\tend\n\t\tend", "def strip_colors\n self....
[ "0.8024637", "0.6739806", "0.66919494", "0.65730506", "0.65545756", "0.65379274", "0.64491004", "0.6409886", "0.64058053", "0.64058053", "0.63524437", "0.6298113", "0.6255913", "0.62427396", "0.62427396", "0.6221583", "0.6201253", "0.6180551", "0.6160523", "0.6151703", "0.610...
0.0
-1
Expose all ANSI color names and their codes
def styles ANSI.constants(false).each_with_object({}) do |col, acc| acc[col.to_sym.downcase] = lookup(col) acc end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def colors\n color_codes.keys\n end", "def convert_ansi_to_html(data)\n COLOR_MAPPING.each do |k, v|\n data.gsub!(/\\e\\[#{k}m/, \"<span style=\\\"color:#{v}\\\">\")\n end\n return data.gsub(/\\e\\[0m/, \"</span>\")\n end", "def ansi_color(color, text)\n #\"\\x1b[38;5;#{color}...
[ "0.73594534", "0.6982657", "0.6969286", "0.68380195", "0.6805915", "0.67983305", "0.675174", "0.6712724", "0.6695327", "0.6695327", "0.66877675", "0.66730374", "0.66616553", "0.6640176", "0.6585285", "0.6585285", "0.6585285", "0.6585285", "0.6585285", "0.6573913", "0.6569377"...
0.6631542
14
List all available style names
def style_names styles.keys end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def styles\n mentos(:get_all_styles)\n end", "def list_styles(**opt)\n # Overridden by the subclass if configured for search analysis.\n end", "def get_styles &block\n response = self.search :styles => nil\n doc = Nokogiri::XML(response)\n styles = doc.xpath(Style.root_xpath).collect...
[ "0.7380433", "0.7204228", "0.67233413", "0.67182636", "0.6682742", "0.6538333", "0.6526848", "0.65208", "0.6436264", "0.63944024", "0.63812304", "0.6332522", "0.61585027", "0.61585027", "0.61585027", "0.6083059", "0.6081906", "0.60627264", "0.6058523", "0.6042654", "0.601944"...
0.83735865
0
Check if provided colors are known colors
def valid?(*colors) colors.all? { |color| style_names.include?(color.to_sym) } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_valid_color?(color_string)\n COLORS.include?(color_string)\n end", "def colors?\n scan(/%([a-z]+)/).each do\n return true if Regexp.last_match(1).validate_color\n end\n false\n end", "def color_valid\n color == \"blue\" || color == \"green\"\n end", "def color_valid?(_...
[ "0.8056831", "0.7976372", "0.78964174", "0.78522", "0.78522", "0.7704579", "0.76846343", "0.7656823", "0.7656823", "0.76385766", "0.75507593", "0.7525427", "0.7422714", "0.739179", "0.739179", "0.739179", "0.739179", "0.739179", "0.739179", "0.739179", "0.739179", "0.739179...
0.76292187
10
[ [X,X,X,X,X,X,X,X,X,X], [X,X,X,X,X,X,X,X,X,X], [X,X,X,X,X,X,X,X,X,X], [X,X,X,X,X,X,X,X,X,X], [X,X,X,X,X,X,X,X,X,X], [X,X,X,X,X,X,X,X,X,X], [X,X,X,X,X,X,X,X,X,X], [X,X,X,X,X,X,X,X,X,X], [X,X,X,X,X,X,X,X,X,X], [X,X,X,X,X,X,X,X,X,X], ]
def length grid_shape.length end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def iterate(arr)\n # TODO 3\n arrNew = []\n (0...arr.count).each do |x|\n arrNew[x] = []\n (0...arr.count).each do |y|\n if num_neighbors(x, y, arr) == 3\n arrNew[x][y] = \"X\"\n else\n arrNew[x][y] = \".\"\n end\n end\n end\n\n arrNew\nend", "def input4\n [\n [1, 0...
[ "0.66918766", "0.6473316", "0.64554584", "0.62220085", "0.6184812", "0.6164545", "0.61179817", "0.6057151", "0.6052865", "0.6045232", "0.6038872", "0.6011229", "0.59992135", "0.5983799", "0.59737647", "0.59647954", "0.5947121", "0.589279", "0.5868995", "0.58670413", "0.585915...
0.0
-1
Remove notifications from problem editors
def remove_problem_upvote_notifications ((@resource.versions.map{ |version| version.user }).uniq - [@actor]).each do |editor| n = Notification.find_by(recipient: editor, actor: @actor, notifiable: @resource, action_type: "like") if !n.nil? n.destroy @removed += 1 end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def remove_from_notifications\n notifications.find_all { |n| n.noti_read == 'N' }.each do |n|\n remove_from_notification(n)\n end # each n\n end", "def remove_proof_upvote_notifications\n ((@resource.versions.map{ |version| version.user }).uniq - [@actor]).each do |editor|\n n = Notif...
[ "0.6260517", "0.6110999", "0.6046434", "0.60085297", "0.59338176", "0.5880503", "0.5869141", "0.5804477", "0.57785124", "0.5757553", "0.5727281", "0.5698001", "0.5684405", "0.56784624", "0.56572413", "0.5634316", "0.56001025", "0.55715257", "0.55238694", "0.54960984", "0.5458...
0.66725373
0
Remove notifications from proof editors
def remove_proof_upvote_notifications ((@resource.versions.map{ |version| version.user }).uniq - [@actor]).each do |editor| n = Notification.find_by(recipient: @resource.user, actor: @actor, action_type: "like", notifiable: @resource) if @resource.user != @actor if !n.nil? n.destroy @removed += 1 end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def remove_problem_upvote_notifications\n ((@resource.versions.map{ |version| version.user }).uniq - [@actor]).each do |editor|\n n = Notification.find_by(recipient: editor,\n actor: @actor,\n notifiable: @resource,\n ...
[ "0.6593376", "0.6380433", "0.6120637", "0.6116147", "0.61107093", "0.6052392", "0.5969748", "0.59078586", "0.5905529", "0.58484566", "0.58292305", "0.5812028", "0.5777078", "0.56985176", "0.5674592", "0.5670423", "0.56559753", "0.5570358", "0.5560994", "0.55516726", "0.552027...
0.6894099
0
Remove notification from owner of comment
def remove_comment_upvote_notifications n = Notification.find_by(recipient: @resource.user, actor: @actor, action_type: "like", notifiable: @resource) if @resource.user != @actor if !n.nil? n.destroy @removed += 1 end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def remove_notification\n if followable_type == \"User\"\n notice = Notification.where({\n target_id: followable_id,\n target_type: \"User\",\n notice_id: id,\n notice_type: \"Follow\",\n user_id: followable_id,\n notifier_id: follower_id\n }).first\n not...
[ "0.6999875", "0.69937617", "0.6849901", "0.67677766", "0.6663127", "0.659714", "0.6530698", "0.6475304", "0.63988656", "0.6389776", "0.63698304", "0.6322537", "0.6279924", "0.6260112", "0.6244098", "0.6233276", "0.6212999", "0.61734164", "0.613409", "0.59765583", "0.5971494",...
0.7223053
0
def set_of_instructions def initialize (instruction) end end
def do_instruction(x) case x when x = "L" then turn_left when x = "R" then turn_right when x = "M" then move_forward else puts "This is not a valid instruction" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def initialize(instructions)\n\t\t@operands = Array.new\n\t\t@operators = Array.new\n\t\t@errors = Array.new\n\t\t@instructions = instructions\n\tend", "def initialize(inst_set, opcode, params=[])\n @instruction_set = inst_set\n @opcode = opcode\n @params = params\n ...
[ "0.7554903", "0.73453623", "0.7246319", "0.6981637", "0.6927867", "0.67096573", "0.6660172", "0.6649419", "0.6593684", "0.6496055", "0.64936775", "0.6469679", "0.64469993", "0.6397139", "0.6390382", "0.6352654", "0.62854266", "0.62737554", "0.62690496", "0.62635577", "0.62416...
0.0
-1
'anchor' is one of the ANCHOR_ constants above. 'where' is the pixel location to slide around, and slide_direction is +/1 to indicate which way to slide when showing. 'displacement' is where along the nonanchored axis the box should be.
def initialize(anchor, where, slide_direction, disp = 0) super() @rl = Opal::ResourceLocator.instance @bgcolor = Rubygame::Color[:blue] @border = Rubygame::Color[:white] @anchor = anchor @where = where @slide_direction = slide_direction @displacement = disp @slide_offset = 0 @speed = 120 setup_gui hide end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def showing?\n return true if @state == STATE_DISPLAYED\n ext = extent\n case(@anchor)\n when ANCHOR_TOP\n return @slide_offset >= 0\n when ANCHOR_LEFT\n return @slide_offset >= 0\n when ANCHOR_BOTTOM\n return @slide_offset <= -ext\n when ANCHOR_RIGHT\n return @slide_offset...
[ "0.56952196", "0.5655555", "0.5618236", "0.537118", "0.53434837", "0.53434837", "0.5302156", "0.5202816", "0.51520866", "0.5117545", "0.5083145", "0.5079932", "0.507465", "0.49990264", "0.4939094", "0.4862796", "0.48468092", "0.47734866", "0.47325787", "0.46962148", "0.468138...
0.60322
0
How far along the slide this has to go to be fully extended
def extent if @anchor == ANCHOR_TOP || @anchor == ANCHOR_BOTTOM return @rect.h else return @rect.w end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def slide_effect(duration, height)\n if @temp_basic_step_height == nil\n @temp_basic_step_height = height / duration.to_f\n \n @we_open_start_height = self.height\n end\n\n step_height = height - (duration * @temp_basic_step_height)\n \n self.height = @we_open_start_height + step_heig...
[ "0.6298013", "0.61545056", "0.61545056", "0.61545056", "0.61353254", "0.6114734", "0.6114734", "0.5989357", "0.59288347", "0.59227586", "0.59227586", "0.58450705", "0.5824173", "0.5817732", "0.5775455", "0.5763048", "0.5731604", "0.5726077", "0.5692901", "0.5689719", "0.56785...
0.0
-1
Whether or not this is fully hidden
def hidden? return true if @state == STATE_HIDDEN ext = extent case(@anchor) when ANCHOR_TOP return @slide_offset <= -ext when ANCHOR_LEFT return @slide_offset <= -ext when ANCHOR_BOTTOM return @slide_offset >= 0 when ANCHOR_RIGHT return @slide_offset >= 0 end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def hidden?\n not visible\n end", "def hidden?()\n not visible?()\n end", "def is_visible?\n visibility && ( visibility > 0 )\n end", "def is_hidden?\n\t\tself.hidden\n\tend", "def hidden?\n false\n end", "def hidden?\n false\n end", "def hidden?\...
[ "0.82311636", "0.8133142", "0.8063336", "0.79033816", "0.78247166", "0.7776644", "0.7776644", "0.77705187", "0.77705187", "0.77097124", "0.76978064", "0.7676774", "0.7676774", "0.7676774", "0.76727", "0.7670146", "0.7657416", "0.7657416", "0.761389", "0.7594288", "0.75856316"...
0.72321993
33
Programatically hides this box, without going through any necessary states.
def hide @state = STATE_HIDDEN if @anchor == ANCHOR_TOP || @anchor == ANCHOR_LEFT @slide_offset = extent * -@slide_direction - 1 else @slide_offset = 0 end setup_gui end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def hide!\n visible(false)\n end", "def hide!\n visible(false)\n end", "def hide\n @visible = false\n self\n end", "def hide!\n self[:hidden] = true\n self\n end", "def hide\n self.visible = false\n clear_dmg_preview\n end", "def hide; end", ...
[ "0.7594872", "0.7594872", "0.7587589", "0.7535907", "0.72000504", "0.70249903", "0.70249903", "0.6931334", "0.68570924", "0.68235856", "0.67397046", "0.6721017", "0.6718066", "0.670836", "0.66130656", "0.65533435", "0.6549156", "0.652437", "0.6493507", "0.6486117", "0.6464020...
0.68795395
8
Subclasses should override this to place things in the slider, set its rect w/h and then call up to this method, as this will set the rect x/y
def setup_gui x = x_for_anchor(@anchor).to_i y = y_for_anchor(@anchor).to_i translate_to(x,y) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_position\n # Calculate values\n target_pos = @direction.object_origin(@target) - @min # Retrieve target ox / oy\n bar_size = @background_sprite.height - @button_slider_sprite.height\n base = @direction.object_position(@background_sprite)\n value = base + (target_pos / (@max - @m...
[ "0.6686312", "0.65477455", "0.6507212", "0.6379917", "0.621754", "0.618316", "0.6141478", "0.6139662", "0.61041296", "0.6004107", "0.59860784", "0.5912727", "0.59074444", "0.58716637", "0.5793109", "0.5784767", "0.5745929", "0.5740602", "0.5733178", "0.5700126", "0.56826675",...
0.53128964
62
Whether or not this is fully showing
def showing? return true if @state == STATE_DISPLAYED ext = extent case(@anchor) when ANCHOR_TOP return @slide_offset >= 0 when ANCHOR_LEFT return @slide_offset >= 0 when ANCHOR_BOTTOM return @slide_offset <= -ext when ANCHOR_RIGHT return @slide_offset <= -ext end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def refresh_view?\n visible? && (ox >= bordered_width || oy >= bordered_height)\n end", "def visible?\n true\n end", "def visible?\n @visible\n end", "def visible?\n @visible\n end", "def visible?\n\t\t\t@visible\n\t\tend", "def show_full\n @show_full=true\n end", "d...
[ "0.7353578", "0.7344829", "0.73133254", "0.73133254", "0.7290243", "0.7274726", "0.72310144", "0.7222399", "0.7220974", "0.7199099", "0.7175825", "0.7119526", "0.71025115", "0.68979704", "0.6869228", "0.6859618", "0.6771067", "0.6769969", "0.6710631", "0.6702703", "0.6665202"...
0.6550656
31
Adjusts the scale (and inverse_scale) by the given amount ZOOM_SPEED
def zoom(delay) self.scale += delay * ZOOM_SPEED end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_zoom\n @effectus_old_zoom_x = @picture.zoom_x\n @effectus_old_zoom_y = @picture.zoom_y\n self.zoom_x = @effectus_old_zoom_x / 100.0\n self.zoom_y = @effectus_old_zoom_y / 100.0\n end", "def vscale(factor)\n @height = @height * factor\n @top *= factor\n self\n end", "def zoom(d...
[ "0.6357948", "0.63213265", "0.61937875", "0.59902763", "0.590808", "0.58783174", "0.5777762", "0.577419", "0.5753107", "0.57381606", "0.570375", "0.5629697", "0.5622397", "0.5600802", "0.5596528", "0.55393696", "0.5528985", "0.54692817", "0.5465162", "0.5460557", "0.54478043"...
0.703119
0
Register a lock to be renewed every extend_interval seconds.
def register(lock, extend_interval) registration = Registration.new registration.lock = lock registration.mutex = Mutex.new registration.thread = Thread.current registration.acquired_at = Time.now registration.extend_interval = extend_interval registration.released = false @locks_mutex.synchronize do locks << registration end registration end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def extend_lock_if_expires_in_less_than(duration)\n extend_lock if duration > remaining_lock_time\n end", "def extend_lock!\n Resque.redis.expire(key, timeout)\n end", "def lock_interval= value\n put_settings(get_settings.tap {|s| s[:lock_interval] = value})\n end", ...
[ "0.6693901", "0.6399278", "0.6149864", "0.6066555", "0.60389113", "0.5899571", "0.58183295", "0.5671344", "0.55594057", "0.5495701", "0.54651004", "0.54388404", "0.5399389", "0.53882456", "0.5364531", "0.5355837", "0.5348644", "0.52948856", "0.5271662", "0.52258074", "0.52215...
0.8018224
0
Extend all currently registered locks that have been held longer than the extend_interval since they were last acquired/extended. If any locks have expired (should not happen), it will release them.
def extend_locks # Make a local copy of the locks array to avoid accessing it outside of the mutex. locks_copy = @locks_mutex.synchronize { locks.dup } locks_copy.each { |registration| extend_lock(registration) } @locks_mutex.synchronize do locks.delete_if(&:released) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def extend_lock_if_expires_in_less_than(duration)\n extend_lock if duration > remaining_lock_time\n end", "def extend_lock!\n Resque.redis.expire(key, timeout)\n end", "def register(lock, extend_interval)\n registration = Registration.new\n registration.lock = lock...
[ "0.67517155", "0.59968555", "0.5689523", "0.559227", "0.5391564", "0.52705073", "0.5240198", "0.51786256", "0.5078256", "0.5058195", "0.49850562", "0.49557242", "0.4947205", "0.49445063", "0.4943477", "0.49239856", "0.49131888", "0.4823957", "0.4818961", "0.47674716", "0.4735...
0.7650049
0
Provide a getter and setters for headers
def header(name, value = nil) if value (@headers ||= {})[name] = value else (@headers || {})[name] end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def headers\n end", "def headers; end", "def headers; end", "def headers; end", "def headers; end", "def headers; end", "def headers; end", "def headers; end", "def headers; end", "def headers; end", "def headers; end", "def get_headers\n @headers = headers\n @headers\n end", "def h...
[ "0.7771739", "0.77104694", "0.77104694", "0.77104694", "0.77104694", "0.77104694", "0.77104694", "0.77104694", "0.77104694", "0.77104694", "0.77104694", "0.76148844", "0.74984527", "0.74853534", "0.7454026", "0.7425922", "0.7393394", "0.73925054", "0.7367843", "0.73488545", "...
0.6870623
52
Allow convenience setters for the data payload
def method_missing(method, *args) return unless method =~ /.*=/ @data[method.to_s.gsub(/=$/, '')] = args.first end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def data=(data)\n @data = data\n end", "def data=(data)\n @data = data\n end", "def data=(new_data)\n @data = nil\n self.data_json = new_data && ActiveSupport::JSON.encode(new_data)\n end", "def data= data \n end", "def data=(data)\n @data = data.to_s\n end", "def set...
[ "0.6786163", "0.6662369", "0.6483353", "0.64550596", "0.6436892", "0.63887084", "0.6382805", "0.6369151", "0.6340051", "0.63362247", "0.6305498", "0.6305498", "0.6305498", "0.6305498", "0.6305498", "0.6305498", "0.6305498", "0.6305498", "0.62513494", "0.6250158", "0.62466294"...
0.0
-1
Shortcut method to deliver a single message
def deliver! return true unless Apostle.deliver unless template_id && template_id != '' raise DeliveryError, 'No email template_id provided' end queue = Apostle::Queue.new queue.add self queue.deliver! # Return true or false depending on successful delivery if queue.results[:valid].include?(self) return true else raise _exception end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def deliver(message)\n raise NotImplementedError\n end", "def deliver_now!\n message.deliver!\n end", "def deliver_now\n message.deliver\n end", "def deliver(message) \n @channel.send(:add_message, message)\n end", "def deliver_message(options)\n self.sms_service_provid...
[ "0.7206859", "0.71881324", "0.71686906", "0.7134063", "0.68219066", "0.6802479", "0.6689876", "0.66111016", "0.6609674", "0.66090864", "0.6603094", "0.65422374", "0.65370464", "0.65368295", "0.6530035", "0.6499281", "0.6467335", "0.6455981", "0.6450886", "0.6448657", "0.64428...
0.0
-1
=begin input: integer (n) output: none return: integer Rules: 1. The answer has to be correct. 2. The final method must not use recursion. 3. No example asks for the 0th element of the sequence Mental Model: Build a fibonacci sequence up to the nth element and return final element (nth element). 1. We need only keep track of the final two elements of the fib sequence thus far [1, 1] to start with (sequence) 2. We need a counter to determine how far into the sequence we are This can be done by counting down from integer given in the argument A counter viarable, x, will be made 3. A loop is needed to iterate until x == given argument integer 4. With each iteration, the sequence array should be ammended such that sequence[1] = sequence[0] + sequence[1] sequence[0] = sequence[1] This can be accomplished by assigning temp variables as follows: last = seuqence[0] + sequence[1] first = sequence[1] Then doing the following: sequence = [first, last] Then x must be reduced by 1 Test: fibonacci(10) =end
def fibonacci(integer) x = 2 sequence = [1, 1] until x == integer last = sequence[0] + sequence[1] first = sequence[1] sequence[1] = last sequence[0] = first x += 1 end sequence.last end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def fibonacci_sequence(n)\n counter = 1\n fib_sum = 1\n previous = [1]\n if n == 1 || n == 2\n return 1\n else \n until counter == n - 1\n previous << fib_sum\n fib_sum += previous[counter - 1] \n counter += 1\n end\n return fib_sum\n end\nend", "def fib_sequenc...
[ "0.8097728", "0.8002613", "0.79860437", "0.7869245", "0.7812189", "0.7802796", "0.779705", "0.7764601", "0.7747439", "0.77333474", "0.7711602", "0.7694139", "0.76787966", "0.7674505", "0.7668799", "0.7661284", "0.7656368", "0.7625008", "0.7610017", "0.7609069", "0.7607894", ...
0.7847279
4
GET /selecaos/1 GET /selecaos/1.json
def show @selecao = Selecao.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render json: @selecao } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n @seguro = Seguro.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @seguro }\n end\n end", "def index\n @socios = Socio.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @...
[ "0.71064365", "0.6753639", "0.66718787", "0.6658466", "0.66025007", "0.65756786", "0.6562154", "0.653512", "0.65227085", "0.6406556", "0.6405248", "0.63974494", "0.6388989", "0.63684595", "0.6367398", "0.6338508", "0.63342", "0.6314306", "0.6309118", "0.63060516", "0.6303607"...
0.69207305
1
GET /selecaos/new GET /selecaos/new.json
def new @selecao = Selecao.new respond_to do |format| format.html # new.html.erb format.json { render json: @selecao } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @seguro = Seguro.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @seguro }\n end\n end", "def new\n @sezione = Sezione.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @sezione }\n en...
[ "0.7673355", "0.7500561", "0.74599725", "0.73434454", "0.73012733", "0.7284069", "0.72820944", "0.72461057", "0.7233107", "0.7222035", "0.71592706", "0.7148576", "0.7142686", "0.7138414", "0.7121858", "0.7118427", "0.71063447", "0.70926577", "0.7088671", "0.7081683", "0.70816...
0.7744536
0
POST /selecaos POST /selecaos.json
def create @selecao = Selecao.new(params[:selecao]) respond_to do |format| if @selecao.save format.html { redirect_to @selecao, notice: 'Selecao was successfully created.' } format.json { render json: @selecao, status: :created, location: @selecao } else format.html { render action: "new" } format.json { render json: @selecao.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @seguro = Seguro.new(params[:seguro])\n\n respond_to do |format|\n if @seguro.save\n format.html { redirect_to @seguro, notice: 'Seguro was successfully created.' }\n format.json { render json: @seguro, status: :created, location: @seguro }\n else\n format.html { r...
[ "0.6663375", "0.65300363", "0.6406342", "0.6395286", "0.6338467", "0.63044035", "0.6278391", "0.6276684", "0.6267618", "0.62545985", "0.62474227", "0.6229199", "0.6219681", "0.6217479", "0.62123716", "0.62107056", "0.6206724", "0.6206048", "0.619697", "0.6191094", "0.61886233...
0.6659651
1
PUT /selecaos/1 PUT /selecaos/1.json
def update @selecao = Selecao.find(params[:id]) respond_to do |format| if @selecao.update_attributes(params[:selecao]) format.html { redirect_to @selecao, notice: 'Selecao was successfully updated.' } format.json { head :no_content } else format.html { render action: "edit" } format.json { render json: @selecao.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @seguro = Seguro.find(params[:id])\n\n respond_to do |format|\n if @seguro.update_attributes(params[:seguro])\n format.html { redirect_to @seguro, notice: 'Seguro was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: ...
[ "0.6427689", "0.6255403", "0.61362725", "0.6129032", "0.60895616", "0.6065918", "0.6046543", "0.6029601", "0.60295624", "0.6023039", "0.60130554", "0.60099554", "0.6006212", "0.59947383", "0.59772074", "0.59656155", "0.5962535", "0.5933297", "0.59308934", "0.59105206", "0.590...
0.634854
1
DELETE /selecaos/1 DELETE /selecaos/1.json
def destroy @selecao = Selecao.find(params[:id]) @selecao.destroy respond_to do |format| format.html { redirect_to selecaos_url } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @seguro = Seguro.find(params[:id])\n @seguro.destroy\n\n respond_to do |format|\n format.html { redirect_to seguros_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @seguidore = Seguidore.find(params[:id])\n @seguidore.destroy\n\n respond_to do |...
[ "0.71521413", "0.7094811", "0.70051724", "0.69976777", "0.69643164", "0.6921676", "0.6911437", "0.6901799", "0.6891904", "0.6860565", "0.683041", "0.6826397", "0.68180317", "0.68075925", "0.68063647", "0.68016326", "0.68003345", "0.67889255", "0.67889255", "0.67889255", "0.67...
0.71586585
0
events [array] of objects [Google::Apis::CalendarV3::Event]
def call(events) events.each { |event| Rails.configuration.gcal_service.insert_event('primary', event) } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _convert_events(events)\n g_events = []\n events.each do |event|\n source = Google::Apis::CalendarV3::Event::Source.new(\n title: @cfg['calendar']['eventSource']['title'],\n url: @cfg['calendar']['eventSource']['url'],\n )\n g_event = Google::Apis::CalendarV3::Event.new(\n ...
[ "0.72515243", "0.7226806", "0.71277463", "0.7121339", "0.7039129", "0.7026969", "0.7017228", "0.69764996", "0.692445", "0.68752366", "0.68379885", "0.67639434", "0.67608327", "0.67442226", "0.66917515", "0.66832185", "0.66683763", "0.66585296", "0.66338986", "0.65893066", "0....
0.0
-1
GET /franchises GET /franchises.json
def index @franchises = Franchise.all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show \n @franchise = @franchise_set.franchises.find(params[:id])\n\n respond_with(@franchise_set, @franchise)\n end", "def show \n @franchise_set = FranchiseSet.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @franchise_set }...
[ "0.68629324", "0.66568244", "0.65204364", "0.6466579", "0.6461302", "0.6414443", "0.6412911", "0.63708305", "0.63563764", "0.6344071", "0.6344071", "0.63136554", "0.6311347", "0.6288984", "0.626852", "0.624103", "0.6216137", "0.6170594", "0.61650807", "0.6142835", "0.6113395"...
0.69259226
0
GET /franchises/1 GET /franchises/1.json
def show @address = Address.find_by(id: @franchise.address_id) @loss_types = LossType.all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show \n @franchise = @franchise_set.franchises.find(params[:id])\n\n respond_with(@franchise_set, @franchise)\n end", "def show \n @franchise_set = FranchiseSet.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @franchise_set }...
[ "0.69264513", "0.6824369", "0.6803302", "0.6521705", "0.6509705", "0.6501075", "0.64499724", "0.64327174", "0.6416755", "0.6416755", "0.64097106", "0.64078087", "0.63947767", "0.6377932", "0.63657635", "0.6353808", "0.6286338", "0.62391776", "0.6233477", "0.6228835", "0.62232...
0.0
-1
POST /franchises POST /franchises.json
def create @franchise = Franchise.new(franchise_params) @address = Address.new(address_params) @franchise.address_id = @address.id respond_to do |format| if @franchise.save format.html { redirect_to @franchise, notice: 'Franchise was successfully created.' } format.json { render :show, status: :created, location: @franchise } else format.html { render :new } format.json { render json: @franchise.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create \n @franchise = @franchise_set.franchises.new(params[:franchise])\n\n respond_to do |format|\n if @franchise.save \n format.html { redirect_to \"/franchise_sets/#{@franchise_set.id}/edit\", :franchise_set_id => franchise_set.id, notice: 'Franchise was successfully created....
[ "0.74402696", "0.7076273", "0.68256736", "0.6690302", "0.6678855", "0.6668468", "0.6616737", "0.64184356", "0.63953596", "0.6390258", "0.6383752", "0.6368777", "0.63076323", "0.62814444", "0.6252537", "0.62483674", "0.622775", "0.6221251", "0.62183034", "0.6193696", "0.618844...
0.6240462
16
PATCH/PUT /franchises/1 PATCH/PUT /franchises/1.json
def update if @franchise.address @franchise.address.update(address_params) unless address_params.empty? else @address = Address.create(address_params) @franchise.address_id = @address.id @franchise.save end respond_to do |format| if @franchise.update(franchise_params) if franchise_params[:notes_attributes] @note = @franchise.notes.last @franchise.track 'Note Created', current_user, @note end if franchise_params[:uploads_attributes] @upload = @franchise.uploads.last @franchise.track 'File Uploaded', current_user, @upload end format.html { redirect_to @franchise, notice: 'Franchise was successfully updated.' } format.json { render :show, status: :ok, location: @franchise } else format.html { render :edit } format.json { render json: @franchise.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update \n @franchise = @franchise_set.franchises.find(params[:id])\n\n respond_to do |format|\n franchise_set = FranchiseSet.find(params[:franchise_set_id])\n if @franchise.update_attributes(params[:franchise])\n format.html { redirect_to \"/franchise_sets/#{franchise_set.id}/edit\" ,...
[ "0.6700158", "0.659464", "0.6402481", "0.6275365", "0.6201156", "0.6197571", "0.6190996", "0.61566097", "0.61088634", "0.61082864", "0.60971856", "0.6046711", "0.60307807", "0.60184574", "0.5999068", "0.5981367", "0.5966143", "0.5945144", "0.5945061", "0.59390193", "0.5935612...
0.5700533
86
DELETE /franchises/1 DELETE /franchises/1.json
def destroy @franchise.destroy respond_to do |format| format.html { redirect_to franchises_url, notice: 'Franchise was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n franchise.destroy\n\n respond_to do |format|\n format.html { redirect_to franchises_url }\n format.json { head :no_content }\n end\n end", "def destroy \n @franchise = @franchise_set.franchises.find(params[:id])\n @franchise.destroy\n\n # respond_to do |format| ...
[ "0.7426003", "0.73714197", "0.7231688", "0.710703", "0.70505047", "0.7008981", "0.6990697", "0.68669045", "0.6827915", "0.68034506", "0.678156", "0.6779242", "0.6769297", "0.67291707", "0.6724265", "0.67088115", "0.67023784", "0.6676823", "0.66693914", "0.6657469", "0.6655576...
0.7141111
3
Use callbacks to share common setup or constraints between actions.
def set_franchise @franchise = Franchise.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 franchise_params params.require(:franchise).permit( :name, :franchise_number, :legal_name, :phone, :fax, :website, :general_license, :residential_license, :commercial_license, :mold_remediation_license, :adwords_client_id, uploads_attributes: [ :upload_category_id, :description, uploads: [] ], notes_attributes: [:content], work_order_distribution_ids: [], scheduling_manager_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.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
Converts the given field to the value that the database adapter returns as a usable column name: column_alias_for("users.id") => "users_id" column_alias_for("sum(id)") => "sum_id" column_alias_for("count(distinct users.id)") => "count_distinct_users_id" column_alias_for("count()") => "count_all"
def column_alias_for(field) column_alias = +field column_alias.gsub!(/\*/, "all") column_alias.gsub!(/\W+/, " ") column_alias.strip! column_alias.gsub!(/ +/, "_") @connection.table_alias_for(column_alias) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def col_name(col)\n [@_table_name, col.name].join('.')\n end", "def converted_field_name\n FIELD_NAMES_TABLE[@field_name] || @field_name\n end", "def aggregated_fact_column_sql\n aggregate_fields.collect { |c| \n \"#{c.strategy_name}(#{c.from_table_name}.#{c.name}) AS #{c.la...
[ "0.5895517", "0.58782315", "0.58514905", "0.5712649", "0.56917036", "0.5688646", "0.56815845", "0.56802845", "0.56715626", "0.5626864", "0.56251174", "0.56140554", "0.5603858", "0.5601835", "0.5581238", "0.5534465", "0.5524514", "0.5519214", "0.54917383", "0.5488859", "0.5488...
0.7471608
0
Same as count but perform the query asynchronously and returns an ActiveRecord::Promise
def async_count(column_name = nil) async.count(column_name) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def count\n @count ||=\n begin\n # self.sql sets self.model_class.\n this_sql = sql(:count => true)\n model_class.connection.\n query(this_sql).\n first.first\n end\n end", "def count\n query.count\n end", "def count\n query.count\n e...
[ "0.6552634", "0.6464964", "0.6464964", "0.63392395", "0.61851805", "0.590122", "0.58874714", "0.5857866", "0.58360636", "0.58178264", "0.5779527", "0.57781446", "0.5759162", "0.5729152", "0.5725027", "0.5710067", "0.5634603", "0.56287456", "0.5612585", "0.55990654", "0.558016...
0.7223257
0
Calculates the average value on a given column. Returns +nil+ if there's no row. See calculate for examples with options. Person.average(:age) => 35.8
def average(column_name) calculate(:average, column_name) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def average(column)\n if s = sum(column)\n s / _all_with_present_column(column).count.to_f\n end\n end", "def column_average(input_query, key)\n output = input_query.average(key)\n number_with_precision(output, precision: 1)\n end", "def avg(field)\n to...
[ "0.8124579", "0.6897474", "0.66772103", "0.66442484", "0.66257405", "0.6408009", "0.6398571", "0.63593835", "0.63576573", "0.635402", "0.63029486", "0.6258484", "0.61673945", "0.6148234", "0.60933393", "0.6086343", "0.60742986", "0.6063052", "0.6054823", "0.6044952", "0.60206...
0.80437046
1
Same as average but perform the query asynchronously and returns an ActiveRecord::Promise
def async_average(column_name) async.average(column_name) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def average_student_gpa\n \"SELECT AVG(gpa) from students;\"\nend", "def async_sum(identity_or_column = nil)\n async.sum(identity_or_column)\n end", "def calculate(operation, column_name)\n operation = operation.to_s.downcase\n\n if @none\n case operation\n when \"count\", \"s...
[ "0.5835753", "0.547055", "0.5469689", "0.54238045", "0.52602386", "0.52592427", "0.52137923", "0.52137923", "0.52137923", "0.5198025", "0.51939225", "0.51723516", "0.51477414", "0.5140449", "0.51170796", "0.51098645", "0.50977683", "0.5089294", "0.50892437", "0.5078895", "0.5...
0.72706807
0
Calculates the minimum value on a given column. The value is returned with the same data type of the column, or +nil+ if there's no row. See calculate for examples with options. Person.minimum(:age) => 7
def minimum(column_name) calculate(:minimum, column_name) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def min(column)\n _all_with_present_column(column).min\n end", "def min(args)\n col = column field: args[:field]\n col.map! {|item| item = item.to_f} \n col.min\n end", "def min(attr)\n column(attr).min\n end", "def get_min()\n @data.min\n end", "def ...
[ "0.80278295", "0.79727817", "0.79599094", "0.70214087", "0.70161986", "0.6862306", "0.67386323", "0.6722003", "0.6711711", "0.6696324", "0.66915125", "0.663722", "0.6621367", "0.6616968", "0.6611135", "0.65922457", "0.65894884", "0.6576366", "0.65665114", "0.6523344", "0.6507...
0.8268641
0
Same as minimum but perform the query asynchronously and returns an ActiveRecord::Promise
def async_minimum(column_name) async.minimum(column_name) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def find_min()\r\n self.min\r\n end", "def get_min()\n # O(1) time\n @min.last\n end", "def lowest_student_gpa\n \"SELECT MIN(gpa) FROM students\"\nend", "def oldest(constraints = {})\n constraints.merge!(order: :created_at.asc)\n _q = query(constraints)\n _q.define_singleton...
[ "0.5744234", "0.5733445", "0.5683802", "0.5457232", "0.54498786", "0.5439021", "0.54343444", "0.5344327", "0.5337682", "0.5315812", "0.5305487", "0.5303429", "0.5288761", "0.52610934", "0.5255177", "0.52475387", "0.52416587", "0.523488", "0.5215397", "0.5209032", "0.51844305"...
0.7292647
0
Calculates the maximum value on a given column. The value is returned with the same data type of the column, or +nil+ if there's no row. See calculate for examples with options. Person.maximum(:age) => 93
def maximum(column_name) calculate(:maximum, column_name) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def max(attr)\n column(attr).max\n end", "def max(args)\n col = column field: args[:field]\n col.map! {|item| item = item.to_f} \n col.max\n end", "def max(column)\n _all_with_present_column(column).max\n end", "def max_value(table_name, column_name)\n ...
[ "0.7988431", "0.7961002", "0.79240566", "0.77619857", "0.755031", "0.69626755", "0.68912166", "0.68822396", "0.6876943", "0.6874555", "0.6835841", "0.681519", "0.6812449", "0.68052596", "0.6793194", "0.6715649", "0.6711083", "0.66858816", "0.66575557", "0.66409886", "0.663825...
0.80665714
0
Same as maximum but perform the query asynchronously and returns an ActiveRecord::Promise
def async_maximum(column_name) async.maximum(column_name) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def calculate_latest_submissions\n max_version_subquery = \"SELECT * FROM (SELECT MAX(version), course_user_datum_id\n FROM `submissions`\n WHERE assessment_id = #{id} AND ignored = FALSE\n GROUP BY course_user_datum_id) AS x\"\n ...
[ "0.5775883", "0.5580071", "0.55321914", "0.5442837", "0.5436593", "0.53789496", "0.53772753", "0.5294841", "0.5290199", "0.5259959", "0.5196192", "0.51851493", "0.51657784", "0.516499", "0.5159016", "0.51292676", "0.5123591", "0.51186675", "0.51104236", "0.5088175", "0.507164...
0.7333761
0
Calculates the sum of values on a given column. The value is returned with the same data type of the column, +0+ if there's no row. See calculate for examples with options. Person.sum(:age) => 4562
def sum(initial_value_or_column = 0, &block) if block_given? map(&block).sum(initial_value_or_column) else calculate(:sum, initial_value_or_column) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sum(column)\n result = all\n\n if result.any?\n result.inject(0.0) do |acc, record|\n if value = record.public_send(column)\n acc += value\n end\n\n acc\n end\n end\n end", "def s...
[ "0.82282233", "0.7980951", "0.7726712", "0.73051023", "0.70191306", "0.7005354", "0.69311947", "0.67743874", "0.67564225", "0.6572698", "0.6436665", "0.6418924", "0.63971466", "0.6380664", "0.6364009", "0.63602984", "0.63245946", "0.6299268", "0.62766486", "0.6274544", "0.619...
0.71741664
4
Same as sum but perform the query asynchronously and returns an ActiveRecord::Promise
def async_sum(identity_or_column = nil) async.sum(identity_or_column) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def record_sum(session, record_type, database)\n session.send(database).select_one( \\\n \"select sum(number1) + sum(number2) + sum(number3) + sum(number4) as sum\n from big_scan where diff_type = '#{record_type}'\")['sum'].to_f\n end", "def calculate(operation, column_name)\n operation =...
[ "0.591459", "0.58025765", "0.5746341", "0.56798476", "0.56798476", "0.56158334", "0.55061966", "0.545525", "0.54466367", "0.5435918", "0.54290265", "0.53577954", "0.53356", "0.53315973", "0.5273493", "0.5221661", "0.5211997", "0.5177458", "0.5129632", "0.51146936", "0.5112505...
0.74440587
0
This calculates aggregate values in the given column. Methods for count, sum, average, minimum, and maximum have been added as shortcuts. Person.calculate(:count, :all) The same as Person.count Person.average(:age) SELECT AVG(age) FROM people... Selects the minimum age for any family without any minors Person.group(:last_name).having("min(age) > 17").minimum(:age) Person.sum("2 age") There are two basic forms of output: Single aggregate value: The single value is type cast to Integer for COUNT, Float for AVG, and the given column's type for everything else. Grouped values: This returns an ordered hash of the values and groups them. It takes either a column name, or the name of a belongs_to association. values = Person.group('last_name').maximum(:age) puts values["Drake"] => 43 drake = Family.find_by(last_name: 'Drake') values = Person.group(:family).maximum(:age) Person belongs_to :family puts values[drake] => 43 values.each do |family, max_age| ... end
def calculate(operation, column_name) operation = operation.to_s.downcase if @none case operation when "count", "sum" result = group_values.any? ? Hash.new : 0 return @async ? Promise::Complete.new(result) : result when "average", "minimum", "maximum" result = group_values.any? ? Hash.new : nil return @async ? Promise::Complete.new(result) : result end end if has_include?(column_name) relation = apply_join_dependency if operation == "count" unless distinct_value || distinct_select?(column_name || select_for_count) relation.distinct! relation.select_values = [ klass.primary_key || table[Arel.star] ] end # PostgreSQL: ORDER BY expressions must appear in SELECT list when using DISTINCT relation.order_values = [] if group_values.empty? end relation.calculate(operation, column_name) else perform_calculation(operation, column_name) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sum(column)\n result = all\n\n if result.any?\n result.inject(0.0) do |acc, record|\n if value = record.public_send(column)\n acc += value\n end\n\n acc\n end\n end\n end", "def s...
[ "0.6312181", "0.5965439", "0.5858012", "0.58323276", "0.57973707", "0.57532007", "0.5661123", "0.5625472", "0.55592465", "0.5552942", "0.55311996", "0.54411584", "0.5381846", "0.536721", "0.5345193", "0.52855587", "0.52511686", "0.52275676", "0.5203544", "0.51965743", "0.5191...
0.6134351
1
Use pluck as a shortcut to select one or more attributes without loading an entire record object per row. Person.pluck(:name) instead of Person.all.map(&:name) Pluck returns an Array of attribute values typecasted to match the plucked column names, if they can be deduced. Plucking an SQL fragment returns String values by default. Person.pluck(:name) SELECT people.name FROM people => ['David', 'Jeremy', 'Jose'] Person.pluck(:id, :name) SELECT people.id, people.name FROM people => [[1, 'David'], [2, 'Jeremy'], [3, 'Jose']] Person.distinct.pluck(:role) SELECT DISTINCT role FROM people => ['admin', 'member', 'guest'] Person.where(age: 21).limit(5).pluck(:id) SELECT people.id FROM people WHERE people.age = 21 LIMIT 5 => [2, 3] Person.pluck(Arel.sql('DATEDIFF(updated_at, created_at)')) SELECT DATEDIFF(updated_at, created_at) FROM people => ['0', '27761', '173'] See also ids.
def pluck(*column_names) return [] if @none if loaded? && all_attributes?(column_names) result = records.pluck(*column_names) if @async return Promise::Complete.new(result) else return result end end if has_include?(column_names.first) relation = apply_join_dependency relation.pluck(*column_names) else klass.disallow_raw_sql!(column_names.flatten) columns = arel_columns(column_names) relation = spawn relation.select_values = columns result = skip_query_cache_if_necessary do if where_clause.contradiction? ActiveRecord::Result.empty(async: @async) else klass.connection.select_all(relation.arel, "#{klass.name} Pluck", async: @async) end end result.then do |result| type_cast_pluck_values(result, columns) end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def pluck(column_name)\n merge_array([\"$pluck\", [column_name.to_s]])\n map { |r| r.send(column_name.to_sym) }\n end", "def pluck(name)\n map { |t| t[name] }\n end", "def pluck(*columns)\n fail ArgumentError, 'No columns specified for Query#pluck' if columns.size.zero?\n\n ...
[ "0.73665416", "0.73337096", "0.7298219", "0.7228862", "0.7130534", "0.69548666", "0.68428504", "0.67168826", "0.65780044", "0.6573343", "0.646296", "0.63349944", "0.6244439", "0.6131515", "0.60042065", "0.5932946", "0.58840156", "0.5862882", "0.5838078", "0.57468736", "0.5649...
0.7516116
0
Same as pluck but perform the query asynchronously and returns an ActiveRecord::Promise
def async_pluck(*column_names) async.pluck(*column_names) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def pluck(*column_names)\n return [] if @none\n\n if loaded? && all_attributes?(column_names)\n result = records.pluck(*column_names)\n if @async\n return Promise::Complete.new(result)\n else\n return result\n end\n end\n\n if has_include?(column_na...
[ "0.72998756", "0.68385845", "0.64958185", "0.6487218", "0.62413484", "0.596295", "0.5930414", "0.57285315", "0.56897277", "0.5619563", "0.55649126", "0.55202496", "0.54578054", "0.5420883", "0.54006255", "0.53791386", "0.5354856", "0.53156954", "0.52780575", "0.52760834", "0....
0.76475996
0
Pick the value(s) from the named column(s) in the current relation. This is shorthand for relation.limit(1).pluck(column_names).first, and is primarily useful when you have a relation that's already narrowed down to a single row. Just like pluck, pick will only load the actual value, not the entire record object, so it's also more efficient. The value is, again like with pluck, typecast by the column type. Person.where(id: 1).pick(:name) SELECT people.name FROM people WHERE id = 1 LIMIT 1 => 'David' Person.where(id: 1).pick(:name, :email_address) SELECT people.name, people.email_address FROM people WHERE id = 1 LIMIT 1
def pick(*column_names) if loaded? && all_attributes?(column_names) result = records.pick(*column_names) return @async ? Promise::Complete.new(result) : result end limit(1).pluck(*column_names).then(&:first) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def pluck(*columns)\n fail ArgumentError, 'No columns specified for Query#pluck' if columns.size.zero?\n\n query = return_query(columns)\n columns = query.response.columns\n\n if columns.size == 1\n column = columns[0]\n query.map { |row| row[column] }\n else\n ...
[ "0.68192977", "0.6554405", "0.6462056", "0.6354714", "0.62995535", "0.62829036", "0.62457407", "0.5963593", "0.58643395", "0.56886715", "0.5661968", "0.5649603", "0.5627481", "0.5615555", "0.5595623", "0.5537795", "0.54360074", "0.5402875", "0.53860325", "0.5380074", "0.53757...
0.77229655
0
Same as pick but perform the query asynchronously and returns an ActiveRecord::Promise
def async_pick(*column_names) async.pick(*column_names) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def pick(*column_names)\n if loaded? && all_attributes?(column_names)\n result = records.pick(*column_names)\n return @async ? Promise::Complete.new(result) : result\n end\n\n limit(1).pluck(*column_names).then(&:first)\n end", "def async_lookup args\n unless Hash === args\...
[ "0.6451383", "0.6228038", "0.62044704", "0.5987701", "0.5839192", "0.534773", "0.5245327", "0.5233414", "0.5173465", "0.51208097", "0.5100011", "0.5082961", "0.50784767", "0.50784767", "0.5074259", "0.5069922", "0.50564957", "0.5028578", "0.50239676", "0.50180995", "0.5014732...
0.6798223
0
Returns the base model's ID's for the relation using the table's primary key Person.ids SELECT people.id FROM people Person.joins(:companies).ids SELECT people.id FROM people INNER JOIN companies ON companies.id = people.company_id
def ids primary_key_array = Array(primary_key) if loaded? result = records.map do |record| if primary_key_array.one? record._read_attribute(primary_key_array.first) else primary_key_array.map { |column| record._read_attribute(column) } end end return @async ? Promise::Complete.new(result) : result end if has_include?(primary_key) relation = apply_join_dependency.group(*primary_key_array) return relation.ids end columns = arel_columns(primary_key_array) relation = spawn relation.select_values = columns result = if relation.where_clause.contradiction? ActiveRecord::Result.empty else skip_query_cache_if_necessary do klass.connection.select_all(relation, "#{klass.name} Ids", async: @async) end end result.then { |result| type_cast_pluck_values(result, columns) } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def company_ids\n @cached_company_ids ||= @object.companies.legit.pluck(:id)\n end", "def get_relation_ids(project_id = nil, base_ids = nil)\n\t\treturn [] if base_ids == []\n\t\tsubcatrels.in_project(project_id).among_denotations(base_ids).pluck(:id)\n\tend", "def all_ids\n db.transaction(true) do |d...
[ "0.63226235", "0.6315557", "0.61727315", "0.60769916", "0.6016357", "0.5820043", "0.5757177", "0.57131624", "0.557167", "0.55570906", "0.5546322", "0.5545649", "0.5503937", "0.54966134", "0.54735273", "0.5456828", "0.54509854", "0.54426056", "0.54343647", "0.5417242", "0.5417...
0.614466
3
Same as ids but perform the query asynchronously and returns an ActiveRecord::Promise
def async_ids async.ids end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def async_lookup args\n unless Hash === args\n args = primary_key_hash(args)\n end\n\n dataset.where(args).limit(1).async_all{ |rows|\n if rows.any?\n yield rows.first\n else\n yield nil\n end\n }\n nil\n end", "def...
[ "0.6503299", "0.64135385", "0.5989049", "0.59195966", "0.59133464", "0.56772715", "0.56306785", "0.5587754", "0.5564351", "0.5492134", "0.54685205", "0.5431442", "0.5407983", "0.5400428", "0.5400428", "0.5363246", "0.5344006", "0.5342844", "0.53241116", "0.53099006", "0.53059...
0.61593217
2
Generate a SOAP message fragment for the object.
def soapify_for(msg, label = 'customFieldValues') msg.add label do |submsg| submsg.add 'customfieldId', @id submsg.add 'key', @key submsg.add_simple_array 'values', @values end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def to_s\n @soap\n end", "def request_message\n return if @parts.empty?\n\n @request_message = Part.new do\n content_type 'multipart/related; type=\"text/xml\"'\n end\n\n soap_body = self.to_xml\n soap_message = Part.new do\n content_type 'text/xml; ch...
[ "0.58817387", "0.57534456", "0.57176", "0.5630687", "0.5561366", "0.55007046", "0.5497265", "0.5489613", "0.5456299", "0.54435", "0.5423764", "0.5360477", "0.53596145", "0.5348982", "0.5336954", "0.53322047", "0.5304959", "0.53029126", "0.52865994", "0.5283085", "0.52460164",...
0.0
-1
Overriding Devise builtin active_for_authentication? method
def active_for_authentication? super and not self.deleted? end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def active_for_authentication?\n super\n end", "def active_for_authentication?\n super && active\n end", "def active_for_authentication?\n active? && super\n end", "def active_for_authentication?\n super && self.active? # i.e. super && self.active\n end", "def active_for_authentication?...
[ "0.8767851", "0.8583711", "0.8578878", "0.8572761", "0.8554177", "0.8554177", "0.8554177", "0.8548365", "0.8534906", "0.8447979", "0.83890665", "0.8366759", "0.83224434", "0.83224434", "0.82388663", "0.8175957", "0.81689036", "0.81685984", "0.81514776", "0.8150547", "0.807011...
0.6956796
79
Alias to be deprecated
def is_provider? self.provider? end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def alias_of; end", "def aliased_name; end", "def deprecated_key=(_arg0); end", "def aliases; end", "def aliases; end", "def aliases; end", "def alias_names; end", "def is_alias?; end", "def private; end", "def deprecated_tag(text); end", "def alias?\n false\nend", "def alias_decls; end", ...
[ "0.78874815", "0.7004773", "0.6925187", "0.6728935", "0.6728935", "0.6728935", "0.67086947", "0.66253746", "0.64813894", "0.64297664", "0.6377957", "0.6330424", "0.632362", "0.631878", "0.6313899", "0.6311774", "0.6282888", "0.6279658", "0.6279658", "0.62695014", "0.6265237",...
0.0
-1
All comments created in the last day, or over the weekend if it is Monday Ex: On Monday, returns tasks created since Friday morning (Time.now 3.day) Ex: On Tuesday, returns tasks created since Monday morning (Time.now 1.day)
def digest_posts # Comment.digest_visible.where( topic_id: self.subscribed_topics.pluck(:id) ).where("created_at > ?", (Time.now.monday? ? Time.now.midnight - 3.day : Time.now.midnight - 1.day)) # Post.digest_visible.where( topic_id: self.subscribed_topics.pluck(:id) ).where("created_at > ?", (Time.now.monday? ? Time.now.midnight - 3.day : Time.now.midnight - 1.day)) Post.current.where(status: 'approved').where("created_at > ?", (Time.now.monday? ? Time.now.midnight - 3.day : Time.now.midnight - 1.day)) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def client_tasks_upcoming\n today = Time.zone.now\n self.find_all {|e| (e.completed.nil? or !e.completed) and (e.complete_by >= today and e.complete_by <= (today + 6.days)) }\n end", "def deadline\n weekly ? self.created_at.sunday.beginning_of_day : self.created_at.end_of_day\n end", "def week\n ...
[ "0.6157928", "0.615391", "0.6051672", "0.5840118", "0.5839378", "0.5815161", "0.5771202", "0.5749192", "0.57202655", "0.5713093", "0.56862354", "0.56813926", "0.56672066", "0.56672066", "0.56655174", "0.56523615", "0.56456274", "0.561695", "0.56120646", "0.56053054", "0.55975...
0.52882737
64
Should change to this def photo_url if photo.present? photo.url else 'defaultuser.jpg' end end
def forum_name if social_profile social_profile.public_nickname else SocialProfile.get_anonymous_name(email) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def user_image_url # return the user image\n ((self.user_image.present?)?(self.user_image.url.to_s):nil) || self.photo_url || \"/assets/no-image.png\"\n end", "def photo(if_not_found = \"anonymous.jpg\" )\n photo_name.nil? ? if_not_found : photo_name\n end", "def ...
[ "0.8395404", "0.81150687", "0.80105835", "0.79694754", "0.78429514", "0.7836549", "0.77101934", "0.7705525", "0.76152164", "0.75577146", "0.7523068", "0.7510459", "0.7479614", "0.74502176", "0.74408376", "0.7410629", "0.73853743", "0.7384063", "0.7348051", "0.7314135", "0.730...
0.0
-1
GET /qx/take_offs GET /qx/take_offs.json
def index # @qx_take_offs = Qx::TakeOff.all per_page = params[:per_page] || 100 @q = Qx::TakeOff.ransack(params[:q]) @qx_take_offs = @q.result().paginate(:page => params[:page], :per_page => per_page) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_qx_take_off\n @qx_take_off = Qx::TakeOff.find(params[:id])\n end", "def qx_take_off_params\n params.require(:qx_take_off).permit(:airport_id, :runway, :aircraft_type, :hirl_rcls, :hirl, :hirl_rcls_stop, :lights)\n end", "def client_choose(offset = 10, limit = 20)\n response = Net::HTTP...
[ "0.6381655", "0.5682251", "0.55859435", "0.54620636", "0.5439219", "0.5405428", "0.53818953", "0.5358595", "0.5263549", "0.5156631", "0.51341677", "0.51270944", "0.5113039", "0.5068326", "0.5066294", "0.5064037", "0.5054704", "0.5027866", "0.50010014", "0.5000613", "0.4991291...
0.6435972
0
GET /qx/take_offs/1 GET /qx/take_offs/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n # @qx_take_offs = Qx::TakeOff.all\n \n per_page = params[:per_page] || 100\n @q = Qx::TakeOff.ransack(params[:q])\n @qx_take_offs = @q.result().paginate(:page => params[:page], :per_page => per_page)\n end", "def set_qx_take_off\n @qx_take_off = Qx::TakeOff.find(params[:id])\n ...
[ "0.61263233", "0.61080295", "0.57958066", "0.5583166", "0.55722374", "0.5480653", "0.5380247", "0.53569096", "0.52966285", "0.5242218", "0.51876336", "0.51696175", "0.5145002", "0.51378965", "0.51368654", "0.5098539", "0.5096234", "0.5094366", "0.5087687", "0.50844526", "0.50...
0.0
-1
POST /qx/take_offs POST /qx/take_offs.json
def create runway = qx_take_off_params[:runway].split("/") runway.each do |item| qx_take_off_params[:runway_id] = Qx::Runway.get_runay_id(qx_take_off_params[:airport_id], item) @qx_take_off = Qx::TakeOff.new(qx_take_off_params) end p runway respond_to do |format| if @qx_take_off.save format.html { redirect_to @qx_take_off, notice: 'Take off was successfully created.' } format.json { render :show, status: :created, location: @qx_take_off } else format.html { render :new } format.json { render json: @qx_take_off.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_qx_take_off\n @qx_take_off = Qx::TakeOff.find(params[:id])\n end", "def qx_take_off_params\n params.require(:qx_take_off).permit(:airport_id, :runway, :aircraft_type, :hirl_rcls, :hirl, :hirl_rcls_stop, :lights)\n end", "def update\n respond_to do |format|\n if @qx_take_off.upda...
[ "0.62888044", "0.62379766", "0.5595522", "0.5462763", "0.5343938", "0.52733797", "0.51407516", "0.5062816", "0.5062299", "0.5022074", "0.49795154", "0.49691406", "0.49611592", "0.49168292", "0.49149147", "0.4893492", "0.48847798", "0.4867671", "0.4867671", "0.48537987", "0.48...
0.63028187
0
PATCH/PUT /qx/take_offs/1 PATCH/PUT /qx/take_offs/1.json
def update respond_to do |format| if @qx_take_off.update(qx_take_off_params) format.html { redirect_to @qx_take_off, notice: 'Take off was successfully updated.' } format.json { render :show, status: :ok, location: @qx_take_off } else format.html { render :edit } format.json { render json: @qx_take_off.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @kickoff = Kickoff.find(params[:id])\n\n respond_to do |format|\n if @kickoff.update_attributes(params[:kickoff])\n format.html { redirect_to @kickoff, notice: 'Kickoff was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render ac...
[ "0.61186934", "0.60202146", "0.5990585", "0.5884832", "0.5873944", "0.5863343", "0.5852479", "0.58492684", "0.58492684", "0.58492684", "0.58492684", "0.5827921", "0.58020145", "0.5784272", "0.57669574", "0.5726589", "0.5726461", "0.5709916", "0.5709825", "0.5709825", "0.57098...
0.70002294
0
DELETE /qx/take_offs/1 DELETE /qx/take_offs/1.json
def destroy @qx_take_off.destroy respond_to do |format| format.html { redirect_to qx_take_offs_url, notice: 'Take off was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_del\n header 'Content-Type', 'application/json'\n\n data = File.read 'sample-traces/0.json'\n post('/traces', data, 'CONTENT_TYPE': 'application/json')\n\n id = last_response.body\n\n delete \"/traces/#{id}\"\n assert last_response.ok?\n\n get \"/traces/#{id}\"\n\n contents = JSON....
[ "0.6665254", "0.6639267", "0.64180845", "0.6404461", "0.63492167", "0.63488585", "0.62898624", "0.6282538", "0.6251904", "0.6247144", "0.62224615", "0.6197994", "0.61745656", "0.6173084", "0.61641586", "0.61477196", "0.61431575", "0.6116767", "0.6110208", "0.6104028", "0.6102...
0.713365
0
Use callbacks to share common setup or constraints between actions.
def set_qx_take_off @qx_take_off = Qx::TakeOff.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 qx_take_off_params params.require(:qx_take_off).permit(:airport_id, :runway, :aircraft_type, :hirl_rcls, :hirl, :hirl_rcls_stop, :lights) 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
Only allow a trusted parameter "white list" through.
def slot_params params.require(:slot).permit( :name, :locked, :order, :user_id, ) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def allowed_params\n ALLOWED_PARAMS\n end", "def expected_permitted_parameter_names; end", "def param_whitelist\n [:role, :title]\n end", "def default_param_whitelist\n [\"mode\"]\n end", "def permitir_parametros\n \t\tparams.permit!\n \tend", "def permitted_params\n []\n end", ...
[ "0.7121987", "0.70541996", "0.69483954", "0.6902367", "0.6733912", "0.6717838", "0.6687021", "0.6676254", "0.66612333", "0.6555296", "0.6527056", "0.6456324", "0.6450841", "0.6450127", "0.6447226", "0.6434961", "0.64121825", "0.64121825", "0.63913447", "0.63804525", "0.638045...
0.0
-1
GET /users GET /users.json
def index @users = User.all pagination respond_to do |format| format.html # index.html.erb format.json { render json: @users } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def users(args = {})\n get(\"/users.json\",args)\n end", "def show\n begin\n user = User.find(params[:user_id])\n render json: { users: user }, status: :ok\n rescue => e\n render json: { errors: e.message}, status: 404\n end\n end", "def GetUsers params = {}\n\n para...
[ "0.82109934", "0.7873764", "0.7860689", "0.78108346", "0.78067017", "0.7678852", "0.76586664", "0.76318866", "0.7582366", "0.75291824", "0.7487637", "0.74485743", "0.7439024", "0.7437192", "0.7427442", "0.73978853", "0.73978853", "0.73978853", "0.73978853", "0.7377353", "0.73...
0.0
-1
GET /users/1 GET /users/1.json
def show if @oeuser.id.to_i == params[:id].to_i @user = User.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render json: @user } end else flash[:error] = "Restricted Access, You need to be Admin" redirect_to root_url end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n if params[:single]\n\t url = \"#{API_BASE_URL}/users/#{params[:id]}.json\"\n\t response = RestClient.get(url)\n\t @user = JSON.parse(response.body)\n\telse\n\t url = \"#{API_BASE_URL}/users.json\"\t \n response = RestClient.get(url)\n @users = JSON.parse(response.body)\t\t \n\tend\n ...
[ "0.81046426", "0.7703556", "0.77011716", "0.76262826", "0.7582106", "0.74818", "0.7461394", "0.7446168", "0.730656", "0.7300699", "0.72902125", "0.72781444", "0.72358584", "0.72335744", "0.72335744", "0.72335744", "0.72335744", "0.72335744", "0.72335744", "0.72335744", "0.722...
0.0
-1
GET /users/new GET /users/new.json
def new @user = User.new respond_to do |format| format.html # new.html.erb format.json { render json: @user } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @newuser = Newuser.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @newuser }\n end\n end", "def new\n @usernew = Usernew.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @usernew }\n ...
[ "0.8287397", "0.8169197", "0.8155916", "0.80483407", "0.8022376", "0.8021751", "0.8009459", "0.7950995", "0.793078", "0.793078", "0.7873476", "0.7873476", "0.7873476" ]
0.7860956
90
POST /users POST /users.json
def create @user = User.new(params[:user]) respond_to do |format| if @user.save UserMailer.welcome_email(@user).deliver format.html { redirect_to @user, notice: 'User was successfully created.' } format.json { render json: @user, status: :created, location: @user } else format.html { render action: "new" } format.json { render json: @user.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def post_users(users)\n self.class.post('https://api.yesgraph.com/v0/users', {\n :body => users.to_json,\n :headers => @options,\n })\n end", "def CreateUser params = {}\n \n APICall(path: 'users.json',method: 'POST',payload: params.to_json)\n \n end", "def post b...
[ "0.77179813", "0.75206673", "0.73831296", "0.72405374", "0.719841", "0.7140812", "0.71038526", "0.7058827", "0.7041636", "0.70236504", "0.7003128", "0.70021695", "0.70021695", "0.70021695", "0.69936967", "0.6990463", "0.6980393", "0.6979075", "0.69788617", "0.69788617", "0.69...
0.0
-1
PUT /users/1 PUT /users/1.json
def update if @oeuser.id.to_i == params[:id].to_i @user = User.find(params[:id]) if params[:oldpassword] and params[:newpassword] and params[:confirmpassword] @user.errors.add(:password, "Current password doesn't match") if not @user.checkpass(params[:oldpassword]) @user.errors.add(:password, "New and confirmation password doesn't match") if not params[:newpassword] == params[:confirmpassword] if @user.errors.empty? @user.password = params[:newpassword] end end respond_to do |format| if @user.errors.empty? and @user.update_attributes(params[:user]) format.html { redirect_to @user, notice: 'User was successfully updated.' } format.json { head :ok } else format.html { render action: "edit" } format.json { render json: @user.errors, status: :unprocessable_entity } end end else flash[:error] = "Restricted Access, You need to be Admin" redirect_to root_url end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n render json: Users.update(params[\"id\"], params[\"user\"])\n end", "def update\n render json: User.update(params[\"id\"], params[\"user\"])\n end", "def UpdateUser params = {}\n \n APICall(path: 'users.json',method: 'PUT',payload: params.to_json)\n \n end", "de...
[ "0.74114245", "0.73920554", "0.73041475", "0.7254177", "0.7202618", "0.70756376", "0.70535713", "0.7029043", "0.70075685", "0.69883573", "0.6983195", "0.694263", "0.69409895", "0.692315", "0.6909438", "0.687742", "0.68486536", "0.6834162", "0.6821841", "0.6801179", "0.6770304...
0.0
-1
DELETE /users/1 DELETE /users/1.json
def destroy @user = User.find(params[:id]) @user.destroy respond_to do |format| format.html { redirect_to users_url } format.json { head :ok } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def DeleteUser id\n \n APICall(path: \"users/#{id}.json\",method: 'DELETE')\n \n end", "def delete\n render json: User.delete(params[\"id\"])\n end", "def delete(id)\n request(:delete, \"/users/#{id}.json\")\n end", "def delete\n render json: Users.delete(params[\"id\...
[ "0.78750724", "0.77518034", "0.7713981", "0.7610077", "0.747295", "0.74073994", "0.74073994", "0.7369968", "0.7346072", "0.7340465", "0.7328618", "0.7309635", "0.73095363", "0.7306841", "0.7297868", "0.72917855", "0.7291585", "0.7289111", "0.7284347", "0.7245172", "0.7242216"...
0.7250935
33
TODO: probably time to move the following logic to service
def cash order = Order.find(params[:data][:attributes][:order_id]) payment = Payment.new do |p| p.order = order p.customer = order.customer p.vendor = order.vendor p.order_total = order.total p.paid_amount = 0 # NOTE: amount passed through payment gateway, thus 0, p.credits_amount = 0 p.payment_method = ::API::V1::Support::PaymentMethodCaclulator.calculate(p) end if payment.save && cash_order_state_changed?(order) render json: {}, status: 201 else head 422 end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def private; end", "def strategy; end", "def service; end", "def service_request(service); end", "def implementation; end", "def implementation; end", "def bi_service\n end", "def refutal()\n end", "def probers; end", "def operations; end", "def operations; end", "def service; ra...
[ "0.6945658", "0.60371804", "0.60099244", "0.5861514", "0.5819279", "0.5819279", "0.5667633", "0.5659446", "0.56236804", "0.56230736", "0.56230736", "0.5590478", "0.5584909", "0.5564423", "0.556105", "0.5556264", "0.5556264", "0.5556264", "0.551728", "0.551728", "0.551728", ...
0.0
-1
todo list DOWN HERE : 1. getting params DONE 2. filter params 3. create roles 4. create roles_menus 5. redirect GLOBAL PARAMS AND VARIABLE :
def paramsr @hotel_id = params[:hotel_id] @id = params[:id] @role_id = params[:role_id] @package_id = Hotel.where(id: @hotel_id).first.package_id end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n submenu_item 'role-index'\n @roles = Role.paginate_by_sql(\"select t1.role_id id,t3.role_name,t3.description from\n (select a1.role_id,count(*) permission_num from roles_permissions a1\n where a1.permission_id in (select permission_id from roles_permissions where role_id =#{@current_user.ro...
[ "0.65967965", "0.6536144", "0.63166076", "0.620196", "0.6177349", "0.61541533", "0.61504626", "0.61400247", "0.61336964", "0.61085343", "0.6066207", "0.5982902", "0.593843", "0.59358656", "0.590718", "0.5895988", "0.5876142", "0.5870164", "0.5868835", "0.5863436", "0.5840771"...
0.0
-1
YOUR CODES DOWN HERE : INDEX :
def index paramsr global # render json: @roles, each_serializer: RoleSerializer, root: false end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def lttfindex\n end", "def ta_index\n end", "def index(p0) end", "def index(p0) end", "def index ; @index ; end", "def cursor_to_decision\n @index = 89\n end", "def setting_index\n end", "def index=(_arg0); end", "def legionnairs\n\n end", "def probers; end", "def pos; end", "def pos;...
[ "0.65698695", "0.6352658", "0.6099765", "0.6099765", "0.6083747", "0.59881765", "0.59734017", "0.59647906", "0.5940142", "0.58772826", "0.58630717", "0.58630717", "0.58630717", "0.58630717", "0.58630717", "0.58630717", "0.58628696", "0.58542246", "0.58542246", "0.58542246", "...
0.0
-1
SHOW : 1. getting params DONE 2. filter params DONE 3. show roles DONE 4. show MENU DONE 5. redirect DONE 6. WAITING FOR EDIT
def show paramsr global @menu_ids=[] @role=@roles.find(@id) # render json: @role, each_serializer: RoleSerializer, root: false # respon_to do |format| # format.html # format.json { render json: @role } # end @menu_id=MenusRole.where(role_id: @id) @menu_id.all.each do |m| @menu_ids.push(m.menu_id) end @menu=Menu.where(id: @menu_ids) if @role.nil? redirect_to "/v2/hotels/#{@hotel_id}/roles/" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n submenu_item 'role-index'\n @roles = Role.paginate_by_sql(\"select t1.role_id id,t3.role_name,t3.description from\n (select a1.role_id,count(*) permission_num from roles_permissions a1\n where a1.permission_id in (select permission_id from roles_permissions where role_id =#{@current_user.ro...
[ "0.68534184", "0.6715386", "0.6648249", "0.66386", "0.6609666", "0.65830773", "0.65453887", "0.6530323", "0.6523014", "0.65209013", "0.65181243", "0.65065044", "0.64896894", "0.64754343", "0.6455182", "0.6443072", "0.64202285", "0.6364056", "0.6364056", "0.6362212", "0.635964...
0.6570462
6
NEW : 1. getting params DONE 2. filter params 3. create ROLES 4. create MENUSROLE 5. redirect 6. WAITING FOR EDIT
def new paramsr # @arr = [] # @roles=user_hotels.where(id: @hotel_id).first.roles.all @role=Role.new @menu=Menu.find_by_sql("SELECT menus.name, menus.id, menus_packages.menu_id FROM menus_packages INNER JOIN menus ON menus.id=menus_packages.menu_id WHERE package_id = #{@package_id} ") @menu_ids = [] # @package_id = Hotel.where(id: @hotel_id).first.package_id # @menu_id=MenusPackage.where(package_id: 2) #@package_id) # @menu_id.each do |m| # @arr=@arr.push(m.menu_id) # end # @menus=Menu.find_by_sql("SELECT menus.name, menus.id, menus_packages.menu_id FROM menus_packages INNER JOIN menus ON menus.id=menus_packages.menu_id WHERE package_id = #{@package_id}") # @sql = "SELECT menus.name, menus_packages.menu_id FROM menus_packages INNER JOIN menus ON menus.id=menus_packages.menu_id WHERE package_id = #{@package_id}" # @menu_id = ActiveRecord::Base.connection.execute(@sql).to_s # @menu_id=MenusPackage.find_by_sql("SELECT menus.name, menus_packages.menu_id FROM menus_packages INNER JOIN menus ON menus.id=menus_packages.menu_id WHERE package_id = #{@package_id}") # @menus_package = MenusPackage.where(package_id: @package_id) # @menu_name end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @user = User.where(:name => params[:user][:name]).first\n if @user.nil?\n @user = User.new\n flash[:notice] = '用户不存在!'\n respond_to do |format|\n format.html { render action: \"new\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n ...
[ "0.66709185", "0.6665142", "0.66624296", "0.6641296", "0.6633384", "0.6523137", "0.6506499", "0.6501287", "0.6453047", "0.64433265", "0.64421546", "0.64162004", "0.6389307", "0.63650715", "0.6329809", "0.6295988", "0.6286607", "0.62563795", "0.6228856", "0.62027156", "0.61976...
0.0
-1
this methode will should take in an argument of the game board and use the turn_count to determinate if is X or turn O
def current_player(board) current_pla = turn_count(board) if current_pla %2==0 return "X" else return "O" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def turn_count(board)\n turn_count = 0\n \n board.each do |counter|\n if counter == \"X\" || counter == \"O\"\n turn_count += 1\n end\n end\n \n turn_count\n end", "def turn_count\n counter = 0\n @board.each do |index_taken|\n if index_taken == \"X\" || index_taken == \"...
[ "0.8072727", "0.7915733", "0.79138714", "0.7856606", "0.78400487", "0.78354377", "0.78354377", "0.78343827", "0.78080595", "0.78058624", "0.77954924", "0.77886987", "0.7786069", "0.77824855", "0.7779163", "0.7755597", "0.77447635", "0.77155644", "0.771409", "0.77134347", "0.7...
0.0
-1
GET /host_states GET /host_states.json
def index @host_states = HostState.all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_states\n perform(:get, 'enum/states', nil, nonauth_headers).body\n end", "def device_states_list\n get \"deviceStates\"\n end", "def index\n @api_states = Api::State.all\n end", "def index\n @project_states = ProjectState.all\n json_response(@project_states)\n end", "def ...
[ "0.730695", "0.70312136", "0.7012061", "0.6694319", "0.6684666", "0.6555589", "0.6412258", "0.63435274", "0.63435274", "0.63435274", "0.63435274", "0.63435274", "0.6295455", "0.6283629", "0.6279372", "0.62609327", "0.61760485", "0.6172597", "0.6142149", "0.61174744", "0.61124...
0.7808806
0