query
stringlengths
7
9.55k
document
stringlengths
10
363k
metadata
dict
negatives
listlengths
0
101
negative_scores
listlengths
0
101
document_score
stringlengths
3
10
document_rank
stringclasses
102 values
Use callbacks to share common setup or constraints between actions.
def set_client @client = Client.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_...
[ "0.6163163", "0.6045976", "0.5946146", "0.591683", "0.5890051", "0.58349305", "0.5776858", "0.5703237", "0.5703237", "0.5652805", "0.5621621", "0.54210985", "0.5411113", "0.5411113", "0.5411113", "0.5391541", "0.53794575", "0.5357573", "0.53402257", "0.53394014", "0.53321576"...
0.0
-1
Only allow a trusted parameter "white list" through.
def client_params params.require(:client).permit(:cuild, :nombre, :iva, :mail) 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.71230334", "0.70530915", "0.69479465", "0.6902122", "0.67367256", "0.67172784", "0.6689043", "0.66784793", "0.6660117", "0.6555213", "0.6528485", "0.6458438", "0.6452378", "0.6451654", "0.64478326", "0.6433326", "0.6413599", "0.6413599", "0.63907677", "0.63787645", "0.6378...
0.0
-1
This will behave slightly different than the legacy jq based rule which was targeted against inline ingress only
def audit_impl(cfn_model) violating_security_groups = cfn_model.security_groups.select do |security_group| violating_egresses = security_group.egresses.select do |egress| violating_egress(egress) end !violating_egresses.empty? end violating_egresses = cfn_model.standalone_egress.select do |standalone_egress| violating_egress(standalone_egress) end violating_security_groups.map(&:logical_resource_id) + violating_egresses.map(&:logical_resource_id) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def distributed_engine_rules_2_json_simple(rules)\n\n end", "def get_ingress_endpoint(namespace, ingress_name)\n stdout, _, _ = execute(\"kubectl get ingress #{ingress_name} -n #{namespace} -o json -o jsonpath='{.status.loadBalancer.ingress[0].hostname}'\")\n stdout\nend", "def check_ingress_rule(rule, ip_p...
[ "0.5504648", "0.5355349", "0.5209314", "0.5054006", "0.4969095", "0.48849437", "0.48078898", "0.4793528", "0.47626528", "0.47625217", "0.47625217", "0.47437996", "0.47135276", "0.4674157", "0.46680933", "0.46679094", "0.46648133", "0.46560153", "0.4641458", "0.46394658", "0.4...
0.0
-1
Setup a new person
def initialize( name, options={} ) @parent = options[:parent] @name = name @repositories = Array.new @badges_static = Array.new @badges_dynamic = Array.new end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new_person\r\n @person = Person.new\r\n end", "def create_person(auth, user)\n # connections are lots of people objects!\n person = Person.find_or_create_by_firstname_and_lastname_and_linkedin_id_and_linkedin_url(\n auth.info.first_name, auth.info.last_name, user.uid, auth.info.urls[\"publi...
[ "0.7103863", "0.6901225", "0.68711716", "0.6806993", "0.6806993", "0.6806993", "0.6806993", "0.6806993", "0.6806993", "0.6806993", "0.6806993", "0.6806993", "0.6806993", "0.6806993", "0.6806993", "0.6806993", "0.6806993", "0.6806993", "0.6806993", "0.6806993", "0.6806993", ...
0.0
-1
Calculate Width of Window Contents
def contents_width width - standard_padding * 2 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def width\n return @window_width # outer width\nend", "def window_width() Graphics.width - 128 end", "def window_width\n Graphics.width / 2\n end", "def window_width\n end", "def window_width\n return WINDOW_WIDTH\n end", "def window_width\n return WINDOW_WIDTH\n end", "def window_width\n...
[ "0.8322178", "0.7986435", "0.795394", "0.79373646", "0.78832567", "0.78832567", "0.78832567", "0.78832567", "0.78832567", "0.7877487", "0.757733", "0.75689226", "0.7534443", "0.75208527", "0.7506657", "0.74952483", "0.74487317", "0.73896414", "0.7355914", "0.7355914", "0.7355...
0.68874353
37
Calculate Height of Window Contents
def contents_height h = height - standard_padding * 2 h + (@item_max * line_height) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def height\n return @window_height # outer height\nend", "def window_height\n end", "def window_height\n fitting_height(11)\n end", "def window_height\n fitting_height(11)\n end", "def window_height\n fitting_height(11)\n end", "def window_height\n Graphics.height - under_help - @keys_wi...
[ "0.8202312", "0.8073735", "0.79666626", "0.79666626", "0.79666626", "0.7933884", "0.7861128", "0.75200915", "0.7499204", "0.74642605", "0.7343024", "0.7301315", "0.727816", "0.72587305", "0.72411597", "0.72022945", "0.71514267", "0.7151034", "0.7100935", "0.7058984", "0.70589...
0.6843328
38
Get Rectangle for Drawing Items
def item_rect(index) rect = Rect.new rect.width = item_width rect.height = item_height rect.x = index % col_max * (item_width + spacing) rect.y = line_height + (index / col_max * item_height) rect end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def rect\n get.rect\n end", "def item_rect(index)\n rect = Rect.new\n rect.width = item_width\n rect.height = item_height\n rect.x = item_position(index).at(0)\n rect.y = item_position(index).at(1)\n rect\n end", "def item_rect(index)\n rect = Rect.new(0, 0, 0, 0...
[ "0.7512527", "0.7510462", "0.745555", "0.73782283", "0.7280172", "0.72232157", "0.7199935", "0.7195995", "0.71135795", "0.70872366", "0.70727074", "0.70727074", "0.7042665", "0.70147604", "0.70147604", "0.69928795", "0.6975363", "0.69383496", "0.68464637", "0.6835249", "0.680...
0.73694324
4
Add host in the specified groups. ==== Attributes +host+ Hostname +groups+ Groups to assign ==== Examples add_groups('pa2web01', ['local', 'web']) add_groups('pa2sql01', ['local', 'mysql', 'heartbeat'])
def add_groups(host, groups=[]) for group in groups if !GROUPS.key?(group) then GROUPS[group] = [] end GROUPS[group].push(host) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_new_groups(params = {})\n post(\"/groups\", params)\n end", "def hostgroup_add_member(hostnames: nil, params: {})\n raise ArgumentError, 'Hostnames is required' unless hostnames\n\n params[:all] = true\n\n params[:host] = hostnames if hostnames.kind_of?(Array)\n params[:ho...
[ "0.68681824", "0.6770978", "0.6735424", "0.6659156", "0.6440352", "0.64264405", "0.63937706", "0.63391197", "0.629191", "0.62590903", "0.6233617", "0.6229149", "0.6226344", "0.6211744", "0.62107027", "0.6054811", "0.60118145", "0.59988844", "0.5995727", "0.59905773", "0.59826...
0.7607118
0
Add disk to the virtual machine ==== Attributes +server+ Server object +size+ Disk size in bytes ==== Examples add_disk(server, 5) Add a 5GB disk add_disk(server, 10) Add a 10GB disk
def add_disk(server, size) host = server.to_s # Increment disk id if !DISKS.key?(host) then DISKS[host] = 0 else DISKS[host] += 1 end disk_id = DISKS[host] disk_filename = ".vagrant/disks/" + host + "_" + disk_id.to_s + ".vdi" server.vm.provider "virtualbox" do |v| # Create disk if it not exist unless File.exist?(disk) v.customize ["createhd", "--filename", disk_filename, "--size", size * 1024 * 1024] end v.customize ['storageattach', :id, '--storagectl', 'SATA Controller', '--port', disk_id, '--device', 0, '--type', 'hdd', '--medium', disk] end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_hdd_to_vbox_vm(client_name,vbox_disk_name)\n message = \"Attaching:\\tStorage to VM \"+client_name\n command = \"VBoxManage storageattach \\\"#{client_name}\\\" --storagectl \\\"#{$vbox_disk_type}\\\" --port 0 --device 0 --type hdd --medium \\\"#{vbox_disk_name}\\\"\"\n execute_command(message,command)\...
[ "0.7076035", "0.693785", "0.68272406", "0.67360306", "0.6712447", "0.6695081", "0.65584517", "0.6548588", "0.6505648", "0.64939356", "0.6481664", "0.63985795", "0.6391803", "0.6383347", "0.6370955", "0.63696635", "0.6250282", "0.62104225", "0.6199367", "0.6185591", "0.6156167...
0.8375884
0
GET /membership_contributions GET /membership_contributions.json
def index @membership_contributions = MembershipContribution.all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n user = User.find_by(id: params[:user_id])\n return respond_with contributions: [], status: :not_found if user.nil?\n contributions = user.contributions\n respond_with contributions: contributions, status: :ok\n end", "def get_contributions(repository)\n Git.contributions GithubAPI.n...
[ "0.73480463", "0.68995786", "0.68482727", "0.6628131", "0.6467863", "0.6412968", "0.62731004", "0.61800843", "0.60863173", "0.60760957", "0.60544586", "0.60061777", "0.59870064", "0.59585655", "0.59462893", "0.59455144", "0.5944579", "0.5922383", "0.5919908", "0.59150016", "0...
0.7566682
0
GET /membership_contributions/1 GET /membership_contributions/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @membership_contributions = MembershipContribution.all\n end", "def index\n user = User.find_by(id: params[:user_id])\n return respond_with contributions: [], status: :not_found if user.nil?\n contributions = user.contributions\n respond_with contributions: contributions, status: :ok\...
[ "0.7539071", "0.7446262", "0.6963958", "0.6885012", "0.6782966", "0.6730014", "0.6377492", "0.6276328", "0.62429464", "0.6183864", "0.6181945", "0.61777675", "0.6161134", "0.61412984", "0.60842884", "0.6059388", "0.60576326", "0.60520804", "0.6048188", "0.60459393", "0.603091...
0.0
-1
POST /membership_contributions POST /membership_contributions.json
def create # byebug @membership_contribution = MembershipContribution.new(membership_contribution_params) @membership = MembershipBalance.find_by(params[:membership_id]) respond_to do |format| if @membership_contribution.save @a = MembershipContribution.all.last # @balance = MembershipBalance.find(params) @amount1 = @membership.balance + @a.amount @b = MembershipBalance.where(membership_id: @a.membership_id).update_all(balance: @amount1) format.html { redirect_to @membership_contribution, notice: 'Membership contribution was successfully created.' } format.json { render :show, status: :created, location: @membership_contribution } else format.html { render :new } format.json { render json: @membership_contribution.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def membership_contribution_params\n params.require(:membership_contribution).permit(:membership_id, :date, :amount)\n end", "def index\n @membership_contributions = MembershipContribution.all\n end", "def set_membership_contribution\n @membership_contribution = MembershipContribution.find(par...
[ "0.7063032", "0.6562812", "0.64714324", "0.64046425", "0.631506", "0.629244", "0.6206663", "0.6166496", "0.61541796", "0.6131366", "0.610208", "0.6083469", "0.6061317", "0.6032376", "0.6020434", "0.598938", "0.59712744", "0.5959901", "0.5947049", "0.59300524", "0.5919236", ...
0.6768626
1
PATCH/PUT /membership_contributions/1 PATCH/PUT /membership_contributions/1.json
def update respond_to do |format| if @membership_contribution.update(membership_contribution_params) format.html { redirect_to @membership_contribution, notice: 'Membership contribution was successfully updated.' } format.json { render :show, status: :ok, location: @membership_contribution } else format.html { render :edit } format.json { render json: @membership_contribution.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_membership_contribution\n @membership_contribution = MembershipContribution.find(params[:id])\n end", "def update\n @contribution = Contribution.find(params[:id])\n\n respond_to do |format|\n if @contribution.update_attributes(params[:contribution])\n format.html { redirect_to @...
[ "0.6815647", "0.67277837", "0.6674991", "0.6674991", "0.66394836", "0.65078545", "0.6483071", "0.64645773", "0.646334", "0.6427524", "0.6405148", "0.6401074", "0.63899326", "0.63718337", "0.63718337", "0.63718337", "0.63718337", "0.63718337", "0.6368388", "0.6347717", "0.6339...
0.74537194
0
DELETE /membership_contributions/1 DELETE /membership_contributions/1.json
def destroy @membership_contribution.destroy respond_to do |format| format.html { redirect_to membership_contributions_url, notice: 'Membership contribution was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @contribution = Contribution.find(params[:id])\n @contribution.destroy\n\n respond_to do |format|\n format.html { redirect_to contributions_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @contribution.destroy\n\n respond_to do |format|\n form...
[ "0.73390275", "0.72188705", "0.7212978", "0.7210668", "0.7210668", "0.7193398", "0.7193253", "0.71769303", "0.71652806", "0.71325195", "0.71325195", "0.7132139", "0.71162033", "0.70957476", "0.7081842", "0.70556927", "0.7054126", "0.70502704", "0.7048006", "0.6959316", "0.694...
0.79422396
0
Use callbacks to share common setup or constraints between actions.
def set_membership_contribution @membership_contribution = MembershipContribution.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 membership_contribution_params params.require(:membership_contribution).permit(:membership_id, :date, :amount) 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
TODO need to decide if this is necessary anymore. It is part of the code that handles logging in a Schoology user when the portal is running in an iframe. If we keep this code, it needs to be fixed to handle redirecting after login when a logged out user tries to access a restricted page. The other parts of this code are in: automatically_closing_popup_link.js and _header_login_box.html.haml
def auth_after url = session[:auth_redirect] || root_path redirect_to url end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def login_popup\n session[:redirect_to_after_auth] = request.env['HTTP_REFERER']\n @login_form = LoginForm.new\n render :layout => \"blank\"\n end", "def login_and_get_initial_page(user_name, password)\n login_page = retrieve_url(\"https://my.idc.ac.il/my.policy\")\n # Check if moved to error p...
[ "0.72326684", "0.69053364", "0.68499196", "0.6596334", "0.6574196", "0.6561503", "0.6402606", "0.64008677", "0.6392955", "0.63889605", "0.63610774", "0.63552415", "0.634398", "0.6316881", "0.63046753", "0.62801564", "0.6261665", "0.62613", "0.62404746", "0.6212286", "0.618060...
0.0
-1
Checks if the current user is the same one as provided. If not, authenticate the user through the provider.
def generic_check(provider, uid=nil) session[:auth_popup] = true if params[:popup] if uid if current_user == (Authentication.find_by_provider_and_uid(provider, uid).user rescue nil) redirect_to(root_path) return end end redirect_to "/users/auth/#{provider}" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def authenticate_user!\n if current_user.id != @user.id\n redirect_back(fallback_location: root_path)\n end\n end", "def authenticate\n if @current_user\n else\n redirect_to login_url\n end\n end", "def check_authentication\n authenticate_user\n end", "def authenticat...
[ "0.69684434", "0.6871805", "0.67951375", "0.67872214", "0.67681324", "0.6751601", "0.6751601", "0.6734407", "0.6679426", "0.66778076", "0.66728437", "0.6657211", "0.66512597", "0.66240054", "0.6610319", "0.66011715", "0.65973324", "0.6578689", "0.65686876", "0.65642935", "0.6...
0.0
-1
Return booking request list where your user ID is equal to the owner ID on the booking = Other users requesting your space.
def my_space_requests my_space_requests = CONNECTION.exec("SELECT id FROM bookings WHERE owner_id='#{@user_id}'") return my_space_requests end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def eligible_owners\n User.where('users.id != ?', @cookbook.user_id)\n end", "def index\n @bookings = Booking.where(consumer_id: current_user).or(Booking.where(consultant_id: current_user))\n\n end", "def owner_request_ids\n Request.by_owner.pluck(:id).sort\n end", "def owner_request_...
[ "0.6495409", "0.6252313", "0.61979896", "0.61979896", "0.61979896", "0.6088526", "0.60728425", "0.6050467", "0.58967304", "0.58083045", "0.57776046", "0.57776046", "0.56964916", "0.5691871", "0.56699854", "0.5663012", "0.563007", "0.5625022", "0.5620409", "0.5615857", "0.5613...
0.5898498
8
Return booking request list where your user ID is equal to the client ID on the booking = Requests you've made on spaces.
def my_booking_requests my_booking_requests = CONNECTION.exec("SELECT id FROM bookings WHERE client_id='#{@user_id}'") return my_booking_requests end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def all_booking_of_client\n\t\t@bookings = Booking.where(client_id: params[:client_id])\n\t\trender json: @bookings, status: 200\n\tend", "def my_space_requests\n my_space_requests = CONNECTION.exec(\"SELECT id FROM bookings WHERE owner_id='#{@user_id}'\")\n return my_space_requests\n end", "def recieve...
[ "0.6396313", "0.63608074", "0.57924014", "0.56113684", "0.5597698", "0.55717677", "0.55717677", "0.55717677", "0.5549683", "0.5516849", "0.5508632", "0.55073", "0.54674083", "0.5437219", "0.54329133", "0.5396922", "0.5394028", "0.53838533", "0.53683054", "0.5334283", "0.53265...
0.6759875
0
return sum[:price] each loop
def food_stand(hash) sum = 0 hash.each do |k, v| # hash[k] = v sum += v end return sum end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sum_all_the_prices(products)\n sum = 0\n products.each do |product|\n sum = sum + ( product[:price] * product[:quantity])\n end\n sum\nend", "def total_price\n items.map(&:price).sum\n end", "def meal_price\n price = 0\n PRIX.each do |k, v|\n v.each do |key, value|\n price = value + pr...
[ "0.7748594", "0.75055885", "0.7471449", "0.7450148", "0.74266905", "0.74094176", "0.7394778", "0.7373244", "0.73697275", "0.7341706", "0.7295452", "0.72255766", "0.7223427", "0.7213727", "0.7177079", "0.71136034", "0.7085814", "0.70823234", "0.7076936", "0.7053037", "0.699738...
0.0
-1
multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. Find the sum of all the multiples of 3 or 5 below 1000.
def multiples(num) result = [] sum = 0 i = 1 while i < num if i % 3 == 0 || i % 5 == 0 result << i end i += 1 end result.each do |digit| sum += digit end sum end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def find_sum_of_multiples_of_3_and_5_below_1000\n answer = 0\n for number in 1...1000\n answer += number if number % 3 == 0 || number % 5 == 0\n end\n answer\nend", "def sum_of_multiples\n multiples_of_three_or_five = []\n\n for n in 3...1000\n if n % 3 == 0\n multiples_of_three_or_five.push(n)\...
[ "0.88275445", "0.8574988", "0.8506502", "0.84992254", "0.84837484", "0.84764296", "0.8449678", "0.84132767", "0.83429474", "0.8335162", "0.82663715", "0.82541883", "0.8225552", "0.8199828", "0.81876963", "0.80904967", "0.80895674", "0.80883884", "0.80879295", "0.80578434", "0...
0.7515662
75
:reek:NestedIterators def records_hash_for(appeal) exported_records(map)|table_name, records| next unless records.is_a?(Array) filtered_records = records.select do |record| record.find do |attrib_name, value| value == appeal["id"] && attrib_name.end_with?("_id") end end [table_name, filtered_records] end.compact.to_h end
def object_id_cache @object_id_cache ||= { # appeals: exported_records(Appeal).map { |appeal| [appeal["id"], appeal["name"]] }.to_h, orgs: exported_records(Organization).map { |org| [org["id"], org["name"]] }.to_h, users: exported_records(User).map { |user| [user["id"], user["css_id"]] }.to_h, tasks: exported_records(Task).map { |task| [task["id"], "#{task['type']}_#{task['id']}"] }.to_h } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def map_to_hash_by_primary_key(result) \n hash = {}\n\n result.each do |record|\n hash[record[@primary_key]] = record\n end\n\n hash\n end", "def dissect_to_record_hashes\n end", "def to_hash\n data = Hash.new\n Dynamic.tables.each do |name, value|\n data[name]...
[ "0.6210552", "0.6148506", "0.601981", "0.59854835", "0.5954271", "0.5804866", "0.57598376", "0.5604132", "0.55972487", "0.55809176", "0.551764", "0.55114865", "0.54975814", "0.54942936", "0.54919124", "0.54716235", "0.54705215", "0.54705215", "0.5441023", "0.54372656", "0.543...
0.57643807
6
Use callbacks to share common setup or constraints between actions.
def set_mascot @mascot = Mascot.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_...
[ "0.6163163", "0.6045976", "0.5946146", "0.591683", "0.5890051", "0.58349305", "0.5776858", "0.5703237", "0.5703237", "0.5652805", "0.5621621", "0.54210985", "0.5411113", "0.5411113", "0.5411113", "0.5391541", "0.53794575", "0.5357573", "0.53402257", "0.53394014", "0.53321576"...
0.0
-1
Only allow a trusted parameter "white list" through.
def mascot_params params.require(:mascot).permit(:name, :age, :location, :description, :gender, :friendly_with_kids, :friendly_with_other_dogs, :friendly_with_cats, :species, :race) 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
Changes attributes hash to remove relationship keys Raises an error if there are any keys left which haven't been defined as properties on the model TODO: use declared_properties instead of self.attributes
def validate_attributes!(attributes) return attributes if attributes.blank? invalid_properties = attributes.keys.map(&:to_s) - self.attributes.keys invalid_properties.reject! { |name| self.respond_to?("#{name}=") } fail UndefinedPropertyError, "Undefined properties: #{invalid_properties.join(',')}" if !invalid_properties.empty? end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def extract_relationship_attributes!(attributes)\n attributes.keys.inject({}) do |relationship_props, key|\n relationship_props[key] = attributes.delete(key) if self.has_relationship?(key)\n\n relationship_props\n end\n end", "def clean_dirty_attributes!\n @dirty_attri...
[ "0.7159003", "0.6859239", "0.6776377", "0.6567105", "0.6541112", "0.652634", "0.6514838", "0.6472304", "0.6464073", "0.63433325", "0.6324257", "0.63209885", "0.62974554", "0.62890095", "0.62642246", "0.6249989", "0.62353367", "0.6228171", "0.6221949", "0.6208002", "0.6191699"...
0.6020705
54
Gives support for Rails date_select, datetime_select, time_select helpers.
def process_attributes(attributes = nil) return attributes if attributes.blank? multi_parameter_attributes = {} new_attributes = {} attributes.each_pair do |key, value| if key.match(DATE_KEY_REGEX) match = key.to_s.match(DATE_KEY_REGEX) found_key = match[1] index = match[2].to_i (multi_parameter_attributes[found_key] ||= {})[index] = value.empty? ? nil : value.send("to_#{$3}") else new_attributes[key] = value end end multi_parameter_attributes.empty? ? new_attributes : process_multiparameter_attributes(multi_parameter_attributes, new_attributes) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def datetime_select(method, options = T.unsafe(nil), html_options = T.unsafe(nil)); end", "def date_select(method, options = T.unsafe(nil), html_options = T.unsafe(nil)); end", "def datetime_select(time, options)\n date_select(time, options) + '&nbsp;at&nbsp;' + time_select(time, options)\n end", "def ti...
[ "0.7479079", "0.72656107", "0.6811067", "0.6689487", "0.6653435", "0.66466427", "0.6522379", "0.63429296", "0.6305174", "0.6287751", "0.62832165", "0.6280898", "0.6262042", "0.61046004", "0.6096559", "0.605428", "0.60249424", "0.60212934", "0.59925574", "0.59812355", "0.59708...
0.0
-1
Defines a property on the class See active_attr gem for allowed options, e.g which type Notice, in Neo4j you don't have to declare properties before using them, see the neo4jcore api.
def property(name, options = {}) invalid_option_keys = options.keys.map(&:to_sym) - VALID_PROPERTY_OPTIONS fail ArgumentError, "Invalid options for property `#{name}` on `#{self.name}`: #{invalid_option_keys.join(', ')}" if invalid_option_keys.any? build_property(name, options) do |prop| attribute(prop) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def define_property(name, options={})\n # check if this property is going to casted\n options[:casted] = !!(options[:cast_as] || options[:type])\n property = CouchRest::Property.new(name, (options.delete(:cast_as) || options.delete(:type)), options)\n create_property_get...
[ "0.69129276", "0.68325984", "0.67294145", "0.6689274", "0.66746354", "0.6592311", "0.659212", "0.65770894", "0.65770894", "0.6516001", "0.6458364", "0.6383337", "0.6347126", "0.6341483", "0.6312778", "0.62948406", "0.6286025", "0.6173045", "0.6136639", "0.6128448", "0.6127587...
0.5842526
48
Reads keypresses from the user including 2 and 3 escape character sequences.
def read_char STDIN.echo = false STDIN.raw! input = STDIN.getc.chr if input == "\e" then input << STDIN.read_nonblock(3) rescue nil input << STDIN.read_nonblock(2) rescue nil end ensure STDIN.echo = true STDIN.cooked! return input end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def key_pressed\n if STDIN.ready?\n input = STDIN.read_nonblock(1) rescue nil\n if input == \"\\e\" \n input << STDIN.read_nonblock(3) rescue nil\n input << STDIN.read_nonblock(2) rescue nil\n end\n end\n # STDIN.cooked!\n input\n\nend", "def pressKey\n STDIN.echo = false\n STDIN.raw!\n ...
[ "0.717189", "0.71680975", "0.70763326", "0.7075197", "0.70361507", "0.6969546", "0.6937639", "0.6894975", "0.67837787", "0.6695388", "0.66821814", "0.66595066", "0.6654973", "0.6571633", "0.6534268", "0.6489353", "0.6481354", "0.6472208", "0.6462229", "0.64368916", "0.6412788...
0.6432087
20
oringal case statement from:
def show_single_key c = read_char case c when " " return "SPACE" when "\t" return "TAB" when "\r" return "RETURN" when "\n" return "LINE FEED" when "\e" return "ESCAPE" when "\e[A" return "UP ARROW" when "\e[B" return "DOWN ARROW" when "\e[C" return "RIGHT ARROW" when "\e[D" return "LEFT ARROW" when "\177" return "BACKSPACE" when "\004" return "DELETE" when "\e[3~" return "ALTERNATE DELETE" when "\u0003" return "CONTROL-C" exit 0 when /^.$/ return "SINGLE CHAR HIT: #{c.inspect}" else return "SOMETHING ELSE: #{c.inspect}" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def keyword\n 'case'\n end", "def keyword\n 'case'\n end", "def case!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 23 )\n\n type = CASE\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\...
[ "0.7592934", "0.7592934", "0.7328321", "0.7228909", "0.7008435", "0.699715", "0.6801803", "0.6780262", "0.67531717", "0.66994786", "0.6692678", "0.66745317", "0.6634266", "0.6627801", "0.6623401", "0.6601309", "0.6540547", "0.6497902", "0.64825416", "0.64476377", "0.6428734",...
0.0
-1
GET /game_ratings GET /game_ratings.json
def index @game_ratings = GameRating.all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ratings\n Birdman::Requester.get(\"movies/#{id}/ratings\")\n end", "def index\n @ratings = Rating.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ratings }\n end\n end", "def index\n @ratings = Rating.all\n\n respond_to do |format|\n...
[ "0.771419", "0.7032027", "0.7032027", "0.7032027", "0.7023711", "0.70226836", "0.69158506", "0.6869383", "0.6686899", "0.66244346", "0.66244346", "0.66244346", "0.662329", "0.66206205", "0.65967506", "0.658551", "0.65697235", "0.65697235", "0.65697235", "0.6553288", "0.654544...
0.7501716
1
GET /game_ratings/1 GET /game_ratings/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ratings\n Birdman::Requester.get(\"movies/#{id}/ratings\")\n end", "def index\n @game_ratings = GameRating.all\n end", "def index\n @ratings = Rating.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ratings }\n end\n end", "def index\...
[ "0.7604909", "0.73535615", "0.7030506", "0.7030506", "0.7030506", "0.7018404", "0.70103246", "0.69156855", "0.6829395", "0.6829395", "0.6829395", "0.68279225", "0.6776494", "0.671239", "0.6661828", "0.66460997", "0.66101944", "0.6605062", "0.6581689", "0.6581689", "0.6581689"...
0.0
-1
POST /game_ratings POST /game_ratings.json
def create @game_rating = GameRating.new(game_rating_params) respond_to do |format| if @game_rating.save format.html { redirect_to @game_rating, notice: 'Game rating was successfully created.' } format.json { render :show, status: :created, location: @game_rating } else format.html { render :new } format.json { render json: @game_rating.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def game_rating_params\n params.require(:game_rating).permit(:game_id, :rating)\n end", "def rating_params\n params.require(:rating).permit(:score, :game_id)\n end", "def evaluate\n puts params[:rating].inspect.yellow\n params[:ratings].each do |tenant, report|\n participant = @game....
[ "0.7197672", "0.7022388", "0.6925746", "0.67633516", "0.6507356", "0.6348106", "0.63153785", "0.6305905", "0.6299254", "0.62990385", "0.6297955", "0.6293861", "0.6279696", "0.62654066", "0.6264876", "0.6251327", "0.62446856", "0.62214065", "0.62188613", "0.62092495", "0.61877...
0.7137196
1
PATCH/PUT /game_ratings/1 PATCH/PUT /game_ratings/1.json
def update respond_to do |format| if @game_rating.update(game_rating_params) format.html { redirect_to @game_rating, notice: 'Game rating was successfully updated.' } format.json { render :show, status: :ok, location: @game_rating } else format.html { render :edit } format.json { render json: @game_rating.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\r\n rating = Rating.where(rater_id: current_user.id, ratee_id: params[:id]).first\r\n\r\n if rating.update(score: params[:score], comment: params[:comment], rater_id: current_user.id, ratee_id: params[:ratee_id])\r\n render json: rating\r\n else\r\n render json: { error: rating.errors...
[ "0.70348614", "0.6950785", "0.6945379", "0.69256663", "0.6916264", "0.6839343", "0.67661744", "0.6760663", "0.6705841", "0.67040485", "0.66811776", "0.6667291", "0.66468287", "0.6590141", "0.6578216", "0.65491855", "0.65368575", "0.6528095", "0.65101016", "0.65097815", "0.650...
0.7391049
0
DELETE /game_ratings/1 DELETE /game_ratings/1.json
def destroy @game_rating.destroy respond_to do |format| format.html { redirect_to game_ratings_url, notice: 'Game rating was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @rating.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def destroy\n @rating = Rating.find(params[:id])\n @rating.destroy\n\n respond_to do |format|\n format.html { redirect_to ratings_url }\n format.json { head :ok }\n end\n ...
[ "0.7305474", "0.72226065", "0.7190627", "0.71213555", "0.70387083", "0.6971562", "0.68876237", "0.6873108", "0.6873108", "0.6868143", "0.6737254", "0.6698981", "0.6692994", "0.66805327", "0.6652504", "0.66397953", "0.6626312", "0.6609389", "0.66038406", "0.6589429", "0.658470...
0.74243283
0
Use callbacks to share common setup or constraints between actions.
def set_game_rating @game_rating = GameRating.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 game_rating_params params.require(:game_rating).permit(:game_id, :rating) 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
private def input_is_not_already_assigned_to_food return true if self.food.nil? || self.input.nil? unless Input.where(food_id: self.food_id, input_id: self.input_id).to_a.empty? errors.add(:base, "Item is already in system") end end
def send_reminder if Date.today == expiration_date - 1 ReminderMailer.food_reminder_msg(@user).deliver flash[:notice] = "#{@user.username} has been notified by email." end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_for_foods\n foods = Food.where(:food_category_id => self.id)\n if foods.any?\n self.errors.add :base,\"Cannot delete food category while dependant foods exist.\"\n return false\n end\n end", "def precheck_clearancing_error\n potential_item = Item.find_by(id: @item_id)\n\n if !...
[ "0.6557811", "0.6472273", "0.6462116", "0.63951516", "0.6200444", "0.61385435", "0.6135749", "0.6123899", "0.60898685", "0.60869753", "0.60821474", "0.60813475", "0.60813475", "0.60813475", "0.60813475", "0.60396934", "0.6037503", "0.6023988", "0.5990279", "0.5976777", "0.596...
0.0
-1
GET /post316s/1 GET /post316s/1.xml
def show @post316 = Post316.find(params[:id]) respond_to do |format| format.html # show.html.erb format.xml { render :xml => @post316 } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n @post306 = Post306.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post306 }\n end\n end", "def show\n @post154 = Post154.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.x...
[ "0.65667033", "0.64826024", "0.6475384", "0.6451592", "0.6415183", "0.6383217", "0.6381178", "0.63731956", "0.63688684", "0.6352993", "0.63419676", "0.63406247", "0.6333633", "0.63286227", "0.6324045", "0.6321663", "0.63183653", "0.6312433", "0.6309652", "0.63031256", "0.6301...
0.6583203
0
GET /post316s/new GET /post316s/new.xml
def new @post316 = Post316.new respond_to do |format| format.html # new.html.erb format.xml { render :xml => @post316 } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @post306 = Post306.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post306 }\n end\n end", "def new\n @post227 = Post227.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post227 }\...
[ "0.7530846", "0.7428117", "0.7421778", "0.7418029", "0.74089366", "0.74083734", "0.7403376", "0.7396353", "0.7396012", "0.73938376", "0.7392765", "0.739177", "0.73851305", "0.73619413", "0.7353478", "0.73423994", "0.7336948", "0.7336151", "0.73351943", "0.7330803", "0.7321566...
0.7545023
0
POST /post316s POST /post316s.xml
def create @post316 = Post316.new(params[:post316]) respond_to do |format| if @post316.save format.html { redirect_to(@post316, :notice => 'Post316 was successfully created.') } format.xml { render :xml => @post316, :status => :created, :location => @post316 } else format.html { render :action => "new" } format.xml { render :xml => @post316.errors, :status => :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @post154 = Post154.new(params[:post154])\n\n respond_to do |format|\n if @post154.save\n format.html { redirect_to(@post154, :notice => 'Post154 was successfully created.') }\n format.xml { render :xml => @post154, :status => :created, :location => @post154 }\n else\n ...
[ "0.59064585", "0.5880296", "0.57913655", "0.578824", "0.5699257", "0.56484497", "0.5628692", "0.5627111", "0.5621102", "0.56096923", "0.5598626", "0.55933845", "0.5591631", "0.55877405", "0.55799884", "0.5578797", "0.55697846", "0.55695444", "0.5567126", "0.55658454", "0.5561...
0.63874596
0
PUT /post316s/1 PUT /post316s/1.xml
def update @post316 = Post316.find(params[:id]) respond_to do |format| if @post316.update_attributes(params[:post316]) format.html { redirect_to(@post316, :notice => 'Post316 was successfully updated.') } format.xml { head :ok } else format.html { render :action => "edit" } format.xml { render :xml => @post316.errors, :status => :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update opts = {}\n opts[:headers] ||= {}\n opts[:headers]['Content-Type'] ||= 'text/xml'\n post 'update', opts\n end", "def put(uri, xml)\r\n req = Net::HTTP::Put.new(uri)\r\n req[\"content-type\"] = \"application/xml\"\r\n req.body = xml\r\n request(req)\r\n end", "def put...
[ "0.6618808", "0.660381", "0.6345901", "0.6316003", "0.60030454", "0.5998591", "0.5975524", "0.5952672", "0.5943673", "0.5875332", "0.582114", "0.5790068", "0.5787935", "0.5778749", "0.57665855", "0.57647175", "0.5749505", "0.5741734", "0.5738316", "0.5736554", "0.57109785", ...
0.6000259
5
DELETE /post316s/1 DELETE /post316s/1.xml
def destroy @post316 = Post316.find(params[:id]) @post316.destroy respond_to do |format| format.html { redirect_to(post316s_url) } format.xml { head :ok } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @post154 = Post154.find(params[:id])\n @post154.destroy\n\n respond_to do |format|\n format.html { redirect_to(post154s_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @post156 = Post156.find(params[:id])\n @post156.destroy\n\n respond_to do |format|\n...
[ "0.71567976", "0.7102263", "0.7083098", "0.70823646", "0.70723945", "0.7012389", "0.69944006", "0.696753", "0.6954077", "0.6946694", "0.6944723", "0.6940121", "0.6938884", "0.69316936", "0.69251573", "0.69214976", "0.6911589", "0.689699", "0.6890636", "0.6889382", "0.6885239"...
0.6882626
21
For testing GET /orders
def index @orders = Order.all render json: @orders, status: 200 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def orders\n authenticated_post(\"auth/r/orders\").body\n end", "def getorders(args={})\n {\n :method=> \"GetOrders\"\n }.to_json\n end", "def orders\n authenticated_post(\"orders\").body\n end", "def get_all_orders() \n\tputs \"Getting all orders\"\n\tresponse = request_g...
[ "0.76108575", "0.7571871", "0.7565088", "0.7553564", "0.73893106", "0.71802455", "0.71285194", "0.71091425", "0.7107938", "0.70959866", "0.7094809", "0.7038703", "0.7029999", "0.6997396", "0.69355786", "0.6911513", "0.6893398", "0.6892263", "0.68564177", "0.68262166", "0.6821...
0.7104481
9
Place Order POST /orders Recurring order start from the day you place them Assuming Resturant sent belongs to the user region only
def create order_params = (place_order_params) order_params[:customer_id] = current_user.customer_id @order = Order.new(order_params) if @order.recurring? if((Time.now + 1.hour).strftime('%H:%M:%S') <= (Time.parse(@order.place_date + ' ' + @order.timeslot.start)).strftime('%H:%M:%S') && !@order.completed? ) # Add the auto generated entry @order.category = 'single' @order.created_by = 'auto' @order.save! end # Improve this if Order.create!(order_params) render json: @order, status: 201 else render json: {'errors': ['Order can no be placed']}, status: :unprocessable_entity end else if (Time.now + 1.hour <= Time.parse(@order.place_date + ' ' + @order.timeslot.start)) && @order.save! render json: @order, status: 201 else render json: {'errorrs': ['Order can not be placed']}, status: :unprocessable_entity end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def assign_order_date\n @booked_quotes = Quote.where(florist_id: session[\"found_florist_id\"]).where(status: \"Ordered\").where(wholesale_order_date: nil) + Quote.where(florist_id: session[\"found_florist_id\"]).where(status: \"Booked\").where(wholesale_order_date: nil)\n for booked_quote in @booked_quotes\...
[ "0.60226583", "0.60044086", "0.5978317", "0.5932185", "0.59172076", "0.58884907", "0.5885946", "0.5857208", "0.5855647", "0.58469707", "0.5816737", "0.57520276", "0.5719332", "0.5710581", "0.57015103", "0.5701419", "0.56888866", "0.56853765", "0.5673064", "0.56502813", "0.564...
0.71176016
0
Update order || Category can not be changed || Placed date || Time slot can not be changed |All ids are replaced| PATCH/PUT /orders/1 Assuming Resturant sent belongs to the user region only
def update if @order.single? if( (Time.now + 1.hour <= Time.parse(@order.place_date + ' ' + @order.timeslot.start)) && (!@order.completed? ) && @order.update(update_order_params) ) render json: @order, status: 200 else render json: {'errorrs': ['Order can not be updated']}, status: :unprocessable_entity end else if(@order.update(update_order_params)) render json: @order, status: 200 else render json: {'errorrs': ['Order can not be updated']}, status: :unprocessable_entity end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n if params[:order][:taxis][:taxi_id].blank?\n orders_taxi.destroy if orders_taxi = OrdersTaxi.where([\"order_id = ?\", @order.id]).first\n else\n unless OrdersTaxi.where([\"order_id = ? AND taxi_id = ?\", @order.id, params[:order][:taxis][:taxi_id]]).first\n unless @order.taxis.b...
[ "0.71665585", "0.6944809", "0.6906992", "0.6838878", "0.68093055", "0.6788424", "0.6773653", "0.6767925", "0.67581916", "0.6752395", "0.6752395", "0.67469424", "0.67360055", "0.6722087", "0.6717004", "0.6688588", "0.6687143", "0.6683587", "0.6683047", "0.66819257", "0.6661239...
0.77046275
0
get/order/customer_recurring_orders Gets All recurring order that are used to generate auto orders for a customer || Check status
def customer_recurring_orders # 1 represents @orders = Order.where(customer_id: current_user.customer_id, category: :recurring) render json: @orders, status: 200 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def all_orders(options)\n request :account, :get, 'allOrders', options\n end", "def list_customer_orders\n orders = current_user.restaurant.orders.where.not(\"status = ? OR status = ? OR status = ? OR status = ?\", 2, 7, 8, 9)\n\n if orders.where(status: 6).length > 0 || orders.where(status...
[ "0.6655822", "0.6456264", "0.62143826", "0.60961294", "0.60788256", "0.59696996", "0.595337", "0.5926247", "0.58955306", "0.5890947", "0.5888247", "0.5874496", "0.585628", "0.58253384", "0.5813705", "0.57688797", "0.57616186", "0.57507354", "0.5744033", "0.57139045", "0.56910...
0.7130487
0
get/order/customer_single_orders Get all single order regardless they are manual or auto for a customer
def customer_single_orders @orders = Order.where(customer_id: current_user.customer_id, category: :single) render json: @orders, status: 200 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @orders = Order.where(:customer_id => params[:customer_id])\n @order = @orders.first \n end", "def customer\n @orders = Spree::Order.where(user_id: current_spree_user.id, state: 'complete').where.not(shipment_state: 'shipped', state: 'returned').order(created_at: :desc)\n end", "def all...
[ "0.66842574", "0.6492773", "0.6374647", "0.63126725", "0.6172871", "0.615013", "0.61402535", "0.61110544", "0.6083359", "0.6062478", "0.6053173", "0.60333455", "0.6025719", "0.5997093", "0.59852153", "0.5981229", "0.59235555", "0.5920914", "0.5916245", "0.59034634", "0.588778...
0.73650944
0
get/order/driver_recurring_orders Gets recurring order that are used to generate auto orders for a driver
def driver_recurring_orders @orders = Timeslot.joins(:orders).where(orders: { category: :recurring}, timeslots: {region_id: current_user.driver.region_id}) render json: @orders, status: 200 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def next_recurring_order\n if actual_order = self.last_active_recurring_order\n self.orders.recurring.find(:all, :conditions => [\"orders.id > ?\", actual_order.id],\n :order => \"orders.id ASC\").first\n end\n end", "def list_orders(code)\n PsegRecurring::Order.new(@credentials).fetch_or...
[ "0.6323658", "0.5873915", "0.58131254", "0.5789864", "0.57825345", "0.56828517", "0.5634773", "0.5529241", "0.54923326", "0.5396034", "0.53715116", "0.53293836", "0.5292301", "0.52753055", "0.52412367", "0.5189769", "0.5189136", "0.51814663", "0.51620156", "0.5151022", "0.514...
0.66845405
0
get/order/driver_single_orders Get all single order regardless they are manual or auto for a driver
def driver_single_orders @orders = Timeslot.joins(:orders).where(orders: { category: :single}, timeslots: {region_id: current_user.driver.region_id}) render json: @orders, status: 200 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_orders\n orders\n end", "def orders\n return [] if !is_client?\n client.orders\n end", "def getorders(args={})\n {\n :method=> \"GetOrders\"\n }.to_json\n end", "def get_orders\n return ShopifyAPI::Order.all\n end", "def get_all_orders() \n\tputs \"Getting all...
[ "0.599514", "0.5944234", "0.58264637", "0.5820596", "0.57453036", "0.5741173", "0.57253313", "0.570094", "0.56805474", "0.5624305", "0.5595843", "0.5519352", "0.5471493", "0.5464744", "0.5426373", "0.5423127", "0.54051054", "0.5386229", "0.5369818", "0.5352874", "0.5347232", ...
0.6335111
0
put/order/1 Mark a order as complete by driver
def mark_order_complete order_params = (driver_order_params) order_params[:payable_attributes][:driver_id] = current_user.customer_id if @order.single? if( (Time.now >= Time.parse(@order.place_date + ' ' + @order.timeslot.start) || true) && (@order.pending? ) && @order.update(order_params) ) render json: @order, status: 200 else render json: {'errorrs': ['Order can not be completed']}, status: :unprocessable_entity end else if(@order.update(order_params)) render json: @order, status: 200 else render json: {'errorrs': ['Order can not be completed']}, status: :unprocessable_entity end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def mark_complete\n ActiveRecord::Base.transaction do\n find_order\n separate_shipment_costs\n assert_refund_adjustments params['refund_items'], true\n @order.update!\n end\n settle_payments_if_desired\n render text: @settlement_result...
[ "0.69553185", "0.6759722", "0.6741864", "0.6729067", "0.6714085", "0.66975635", "0.6635356", "0.6536199", "0.6515236", "0.6497", "0.64500105", "0.6392472", "0.63909906", "0.6379636", "0.6368655", "0.63317764", "0.6310971", "0.6308635", "0.6249706", "0.6230844", "0.6187945", ...
0.74576443
0
xroad_id may be either ClientId or ServerId.
def verify_xroad_instance(xroad_id) logger.debug("Instance verification: #{xroad_id}") unless @xroad_instance.eql?(xroad_id.xroad_instance) raise t("request.incorrect_instance") end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def verify_xroad_instance(xroad_id)\n logger.debug(\"Instance verification: #{xroad_id}\")\n\n unless @xroad_instance.eql?(xroad_id.xroad_instance)\n raise t(\"request.incorrect_instance\")\n end\n end", "def set_mainroad\n @mainroad = Mainroad.find(params[:id])\n end", "def set_road\n ...
[ "0.66138875", "0.5049378", "0.50263023", "0.48848465", "0.4846459", "0.47275993", "0.4703783", "0.4653071", "0.46315962", "0.46029252", "0.45669642", "0.45372003", "0.45358035", "0.453562", "0.45174667", "0.4458038", "0.44488096", "0.4443291", "0.44104835", "0.44089085", "0.4...
0.6561161
1
To determine whether a point is in a rect Use point.inside_rect? rect This is useful to determine if a click occurred in a rect
def tick args tick_instructions args, "Sample app shows how to determing if a click happened inside a rectangle." x = 460 args.outputs.labels << small_label(args, x, 15, "Click inside the blue box maybe ---->") box = { x: 785, y: 370, w: 50, h: 50, r: 0, g: 0, b: 170 } args.outputs.borders << box # Saves the most recent click into args.state # Unlike the other components of args, # args.state does not reset every tick. if args.inputs.mouse.click args.state.last_mouse_click = args.inputs.mouse.click end if args.state.last_mouse_click if args.state.last_mouse_click.point.inside_rect? box args.outputs.labels << small_label(args, x, 16, "Mouse click happened *inside* the box.") else args.outputs.labels << small_label(args, x, 16, "Mouse click happened *outside* the box.") end else args.outputs.labels << small_label(args, x, 16, "Mouse click has not occurred yet.") end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def pos_rect_nt?(x, y, rect)\r\r\n pos_rect?(x, y, rect) && !@through\r\r\n end", "def pointInside(point, withEvent:event)\n CGRectContainsPoint(actual_bounds, point)\n end", "def pointInside(point, withEvent:event)\n CGRectContainsPoint(actual_bounds, point)\n end", "def contains_point?(pt)\n ...
[ "0.7896517", "0.7896006", "0.7896006", "0.78128976", "0.7786337", "0.7745475", "0.77379644", "0.77063495", "0.7699067", "0.76848376", "0.7638694", "0.7638694", "0.7588619", "0.7548409", "0.7524754", "0.752382", "0.7438561", "0.7437344", "0.7437149", "0.7430438", "0.7379128", ...
0.0
-1
GET /agenciamadres/1 GET /agenciamadres/1.xml
def show @agenciamadre = Agenciamadre.find(params[:id]) respond_to do |format| format.html # show.html.erb format.xml { render :xml => @agenciamadre } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n @relatestagiario = Relatestagiario.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @relatestagiario }\n end\n end", "def download_xml\n\t\turi = URI.parse(\"http://www.esmadrid.com/opendata/tiendas_v1_es.xml\")\n\t\tresponse...
[ "0.6237832", "0.62087727", "0.6183817", "0.61069185", "0.6057191", "0.60394096", "0.6030785", "0.60258734", "0.5999758", "0.5983949", "0.59808916", "0.59781045", "0.5955818", "0.59473175", "0.59176636", "0.59057117", "0.5896805", "0.5892465", "0.5879226", "0.58749354", "0.587...
0.6580325
0
GET /agenciamadres/new GET /agenciamadres/new.xml
def new @agenciamadre = Agenciamadre.new respond_to do |format| format.html # new.html.erb format.xml { render :xml => @agenciamadre } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @relatestagiario = Relatestagiario.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @relatestagiario }\n end\n end", "def new\n @omatsuri = Omatsuri.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { ...
[ "0.7245398", "0.7164518", "0.71478367", "0.71264786", "0.712289", "0.70754814", "0.70577675", "0.7046149", "0.7043363", "0.7038602", "0.70277387", "0.7027488", "0.70097184", "0.70051676", "0.6998889", "0.69982636", "0.69962996", "0.6978991", "0.6969443", "0.69611156", "0.6948...
0.7411457
0
POST /agenciamadres POST /agenciamadres.xml
def create @agenciamadre = Agenciamadre.new(params[:agenciamadre]) respond_to do |format| if @agenciamadre.save format.html { redirect_to(@agenciamadre, :notice => 'Agencia Madre fue creada satisfactoriamente.') } format.xml { render :xml => @agenciamadre, :status => :created, :location => @agenciamadre } else format.html { render :action => "new" } format.xml { render :xml => @agenciamadre.errors, :status => :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def generate_tags\n uri = URI.parse(\"https://api.thomsonreuters.com/permid/calais\")\n http = Net::HTTP.new(uri.host, uri.port)\n http.use_ssl = true\n post_body = []\n post_body << \"<Document><Body>\"\n # stip html\n post_body << ActionView::Base.full_sanitizer.sanitize(params...
[ "0.568386", "0.5615961", "0.556143", "0.53071696", "0.5302942", "0.5282424", "0.5253082", "0.5227075", "0.51156545", "0.5100632", "0.50992155", "0.5084646", "0.50764245", "0.50733185", "0.5062335", "0.50605386", "0.50602293", "0.50296885", "0.50226015", "0.5014628", "0.496211...
0.5974314
0
PUT /agenciamadres/1 PUT /agenciamadres/1.xml
def update @agenciamadre = Agenciamadre.find(params[:id]) respond_to do |format| if @agenciamadre.update_attributes(params[:agenciamadre]) format.html { redirect_to(@agenciamadre, :notice => 'Agencia Madre fue actualizada satisfactoriamente.') } format.xml { head :ok } else format.html { render :action => "edit" } format.xml { render :xml => @agenciamadre.errors, :status => :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update opts = {}\n opts[:headers] ||= {}\n opts[:headers]['Content-Type'] ||= 'text/xml'\n post 'update', opts\n end", "def put(uri, xml)\r\n req = Net::HTTP::Put.new(uri)\r\n req[\"content-type\"] = \"application/xml\"\r\n req.body = xml\r\n request(req)\r\n end", "def res...
[ "0.6045064", "0.59739083", "0.5860993", "0.55995876", "0.5491728", "0.5446294", "0.5392827", "0.533744", "0.53059936", "0.53017974", "0.52958494", "0.52759635", "0.5268645", "0.5258632", "0.52217674", "0.52020234", "0.5199859", "0.5189394", "0.51755995", "0.51727647", "0.5169...
0.56144327
3
DELETE /agenciamadres/1 DELETE /agenciamadres/1.xml
def destroy @agenciamadre = Agenciamadre.find(params[:id]) @agenciamadre.estado = "1" @agenciamadre.save respond_to do |format| format.html { redirect_to(agenciamadres_url) } format.xml { head :ok } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def netdev_resxml_delete( xml )\n top = netdev_resxml_top( xml )\n par = top.instance_variable_get(:@parent)\n par['delete'] = 'delete'\n end", "def destroy\n RestClient.delete \"#{REST_API_URI}/contents/#{id}.xml\" \n self\n end", "def destroy\n @relatestagiario = Relatestagiario.find(para...
[ "0.7153138", "0.7004633", "0.6473098", "0.64406335", "0.64240724", "0.638133", "0.6367519", "0.62814295", "0.6275722", "0.62712455", "0.6257363", "0.6256633", "0.6238329", "0.6228341", "0.62267363", "0.62140846", "0.62014836", "0.61981595", "0.6177467", "0.61750394", "0.61674...
0.61546797
24
Handle post requests for sending text messages
def create to = params[:to] unless to raise IOError, "Incorrect params for sending text message" end @client = Twilio::REST::Client.new( CONFIG[:twilio_account_sid], CONFIG[:twilio_auth_token]) @account = @client.account @message = @account.sms.messages.create({ :from => CONFIG[:twilio_phone_number], :to => to, :body => "Happy Mining! #{CONFIG[:ios_app_link]}"}) rescue => ex handle_exception(ex) ensure respond_to do |format| format.json end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def post(message)\n puts message\n end", "def post(message)\n puts message\n end", "def post(content)\n post_to(\"/api/v1/messages/\", {:body => content})\n end", "def post_message(text)\n body ={\n \"title\" => @from_name,\n \"picture\" => @from_picture,\n \"messa...
[ "0.74691135", "0.7113999", "0.69869184", "0.67299336", "0.6676714", "0.66448104", "0.66046065", "0.6590959", "0.6490133", "0.6455664", "0.64418477", "0.64417773", "0.63449943", "0.6337639", "0.63321227", "0.6306471", "0.63018674", "0.63018674", "0.6275276", "0.6274512", "0.62...
0.0
-1
Executes arbitrary HTTP requests. You have to mount required Rack application before you can use it.
def request(method) unless REQUEST_METHODS.include? method raise NotSupportedError, "Rack adapter does not support custom HTTP methods" end if @request.proxy raise NotSupportedError, "Rack adapter does not support proxying" end if @request.auth.http? if @request.auth.basic? basic_auth = @request.auth.basic.join(':') encoded = Base64.encode64(basic_auth).gsub('\n', '') @request.headers['Authorization'] = "Basic #{encoded}" else raise NotSupportedError, "Rack adapter does not support HTTP #{@request.auth.type} auth" end end if @request.auth.ssl? raise NotSupportedError, "Rack adapter does not support SSL client auth" end if @request.on_body raise NotSupportedError, "Rack adapter does not support response streaming" end env = {} @request.headers.each do |header, value| env["HTTP_#{header.gsub('-', '_').upcase}"] = value end response = @client.request(method.to_s.upcase, @request.url.to_s, { :fatal => true, :input => @request.body.to_s }.merge(env)) Response.new(response.status, response.headers, response.body) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def run_request(method, url, body, headers); end", "def run\n make_request(@path)\n end", "def call(env)\n @req = Rack::Request.new(env)\n @res = Rack::Response.new\n handle_request\n @res.finish\n end", "def call(*args)\n if request = rack_request(*args)\n rack_response ...
[ "0.6697119", "0.66095304", "0.65307903", "0.6473269", "0.64649", "0.64602274", "0.64350945", "0.63960373", "0.63189906", "0.6285097", "0.6272864", "0.6218218", "0.6210282", "0.6210282", "0.6190711", "0.6143083", "0.6112389", "0.6091336", "0.6082706", "0.607482", "0.6044765", ...
0.0
-1
get next yahrzeit date on or after "from" date
def next_yahrzeit_date(from=Date.today) return unless death_date # TODO: use Marlena rules h_from = Hebruby::HebrewDate.new(from) h_death = Hebruby::HebrewDate.new(death_date) # yahrzeit date from year h_yahrzeit = Hebruby::HebrewDate.new(h_death.day, h_death.month, h_from.year) date = Date.jd(h_yahrzeit.jd) if date < from h_yahrzeit = Hebruby::HebrewDate.new(h_death.day, h_death.month, h_from.year+1) date = Date.jd(h_yahrzeit.jd) end date end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def next_yahrzeit_date(from=Date.today)\n return unless death_hebrew_date_day && death_hebrew_date_month\n @next_yahrzeit_date ||= begin\n # TODO: use Marlena rules\n h_from = Hebruby::HebrewDate.new(from)\n # yahrzeit date from year\n h_yahrzeit = Hebruby::HebrewDate.new(death_hebrew_dat...
[ "0.6988127", "0.69150674", "0.6720934", "0.6713743", "0.6561058", "0.654712", "0.651791", "0.65158767", "0.651048", "0.6485499", "0.64658606", "0.64643204", "0.64403236", "0.64092857", "0.640129", "0.6307372", "0.6299992", "0.6291768", "0.62493706", "0.6238404", "0.61948866",...
0.70579094
0
Sets attributes of the load balancer The following attributes can be set: CrossZoneLoadBalancing (enable/disable) ConnectionDraining (enable/disable and timeout) Idle Connection Timeouts Still requires: AccessLog configuration ==== Parameters lb_name Name of the ELB options 'ConnectionDraining': 'Enabled' whether to enable connection draining 'Timeout' max time to keep existing conns open before deregistering instances 'CrossZoneLoadBalancing': 'Enabled' whether to enable cross zone load balancing 'ConnectionSettings': 'IdleTimeout' time (in seconds) the connection is allowed to be idle (no data has been sent over the connection) before it is closed by the load balancer. ==== Returns response: body: 'ResponseMetadata': 'RequestId' Id of request
def modify_load_balancer_attributes(lb_name, options) attributes = Fog::AWS.serialize_keys 'LoadBalancerAttributes', options request(attributes.merge( 'Action' => 'ModifyLoadBalancerAttributes', 'LoadBalancerName' => lb_name, :parser => Fog::Parsers::AWS::ELB::Empty.new )) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def modify_load_balancer_attributes(lb_id, attributes)\n attributes = Fog::AWS.serialize_keys 'Attributes', attributes.map{ |property, value| { :Key => property, :Value => value } }\n request(attributes.merge(\n 'Action' => 'ModifyLoadBalancerAttributes',\n 'LoadBa...
[ "0.6881987", "0.63550526", "0.60747653", "0.5950793", "0.58297247", "0.5668725", "0.5498494", "0.54914826", "0.5449023", "0.54453933", "0.5378115", "0.53044623", "0.5206537", "0.5151398", "0.51446295", "0.51323014", "0.507111", "0.5070972", "0.50553644", "0.501969", "0.500384...
0.7620888
0
This method creates a new `Node` using `data`, and inserts it at the end of the list.
def add_to_tail(node) if head.nil? @head = node @tail = node else @tail.next = node @tail = node end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def insert(data)\n node = Node.new data\n\n if @head.nil?\n node.next_node = node\n else\n # the new node will have the same trailing node as old\n node.next_node = @head.next_node\n # the old head will become the tail\n @head.next_node = node\n end\n\n @...
[ "0.83078945", "0.82473487", "0.82388455", "0.8128866", "0.80914295", "0.80732775", "0.8063922", "0.8050075", "0.7922698", "0.7917784", "0.7903831", "0.7897407", "0.7881819", "0.78765535", "0.78673124", "0.7863668", "0.78496134", "0.7802962", "0.77256835", "0.7721887", "0.7711...
0.0
-1
This method removes the last node in the lists and must keep the rest of the list intact.
def remove_tail if @head == @tail @head = @tail = nil else placeholder = @head while placeholder.next != @tail placeholder = placeholder.next end placeholder.next = nil @tail = placeholder end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def pop() #delete last element in the LL\n return nil if @head == nil #if list is empty return nil\n return @head = nil if self.list_size == 1 #list has 1 element(head) assign head to nil\n temp_node = @head #if list has more then 1 element, travres till last element\n #stop conditon is when second ele...
[ "0.7568641", "0.7224027", "0.7224027", "0.71167296", "0.7110339", "0.70931035", "0.6979028", "0.6891833", "0.68793046", "0.6867553", "0.68380266", "0.6771133", "0.6754616", "0.67509097", "0.6727357", "0.6705762", "0.66904026", "0.6668838", "0.6598453", "0.65727836", "0.655843...
0.6612462
18
This method prints out a representation of the list.
def print placeholder = @head list = "" while placeholder.next list += placeholder.data + "\n" placeholder = placeholder.next end list += placeholder.data + "\n" # the plus "\n" added because of the way the spec is written. printf list end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def print_list; end", "def print_list\n @list.each { |item, qty| puts \"#{qty} #{item}\" }\n end", "def print_list\n @list.each { |item, qty| puts \"#{qty} #{item}\" }\n end", "def print_list\n\t puts \"\"\n\t puts \"\"\n\t\tputs \"#{@list_name}\"\n\t\tprint \"-\" * 40\n\t\t@grocery_list.ea...
[ "0.78825545", "0.7745042", "0.7745042", "0.75637954", "0.74398595", "0.7367223", "0.7222104", "0.71936995", "0.71448636", "0.71383715", "0.71383715", "0.71307075", "0.71196485", "0.71172297", "0.7097041", "0.70625097", "0.70543265", "0.7036249", "0.700103", "0.700103", "0.699...
0.7270045
6
This method removes `node` from the list and must keep the rest of the list intact.
def delete(node) if @head.data == node.data remove_front elsif @tail.data == node.data remove_tail else previousNode = @head placeholder = @head.next while placeholder.data != node.data if placeholder.next previousNode = placeholder placeholder = placeholder.next else return 'node not found' end end previousNode.next = placeholder.next end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def remove(node)\n end", "def remove_node(node)\n\t\t\tif has_node?(node)\n\t\t\t\tpull_edges_of(node)\n\t\t\t\t@nodes.delete(node)\n\t\t\t\t@order -= 1\n\t\t\tend\n\t\t\tself\n\t\tend", "def node_remove(node)\n return unless node_present? node\n nodes.delete prepare_key(node)\n end", "def re...
[ "0.7828169", "0.7667009", "0.75958735", "0.7578272", "0.75130004", "0.7486729", "0.74340457", "0.74335665", "0.74332124", "0.7410218", "0.74037397", "0.7380275", "0.735023", "0.73313725", "0.7330209", "0.7279806", "0.7270355", "0.72691506", "0.7254728", "0.7246497", "0.724469...
0.6996781
36
This method adds `node` to the front of the list and must set the list's head to `node`.
def add_to_front(node) node.next = @head @head = node end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_to_front(node)\n node.next = self.head # previous head becomes second, after the node\n self.head = node # the node becomes the new head\n if self.tail == nil\n self.tail = node # if the list was empty, then the node is also the new tail\n end\n end", "def add_to_front(node)\n node.s...
[ "0.8646671", "0.86239403", "0.85174453", "0.85093665", "0.85093665", "0.8501696", "0.8482765", "0.8475305", "0.844926", "0.844926", "0.844926", "0.84252894", "0.84223384", "0.84223384", "0.84198016", "0.8379058", "0.833121", "0.833121", "0.833121", "0.8299411", "0.8297976", ...
0.8510079
3
This method removes and returns the first node in the Linked List and must set Linked List's head to the second node.
def remove_front placeholder = @head @head = placeholder.next return placeholder end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def remove_front\n value = self.head # save the first element\n self.head = value.next # the second element becomes the new first element\n value.next = nil # no longer in the list, so no next\n return value\n end", "def remove_head\n\t\t\n\t\told_head = @head\n\n\t\tif old_head == nil\n\t\t\treturn...
[ "0.77232677", "0.7394622", "0.7327053", "0.7322324", "0.730469", "0.7237489", "0.7228943", "0.7220719", "0.7160315", "0.71064734", "0.70911103", "0.7088415", "0.70429856", "0.70345116", "0.69969636", "0.69936895", "0.6984492", "0.6982301", "0.69277763", "0.6914034", "0.690821...
0.6729741
33
use this function to repair / build your lists.
def repair_list(scope={}) return false unless scope.keys.all?{|s| list_options[:scope].include?(s) || s == :order } all({:order => [:position.asc]}.merge(scope)).each_with_index{ |item,i| item.position = i+1; item.save } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def repair_list\n self.class.repair_list(list_scope)\n end", "def repair_list\n model.repair_list(list_scope)\n end", "def safelists; end", "def build_lists\n @callday = [' ','SUNDAY', 'MONDAY', 'TUESDAY', 'WEDNESDAY', 'THURSDAY', 'FRIDAY']\n @callback = [' ', 'SUNDA...
[ "0.70567656", "0.6887271", "0.62495327", "0.6060513", "0.6006566", "0.5834209", "0.5745101", "0.5727862", "0.57046217", "0.5699143", "0.5583915", "0.5583915", "0.5583915", "0.5553152", "0.55244637", "0.55119187", "0.55119187", "0.55119187", "0.54799175", "0.5466885", "0.54325...
0.0
-1
repair the list this item belongs to
def repair_list self.class.repair_list(list_scope) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def repair_list\n model.repair_list(list_scope)\n end", "def fix_items\n valid_items = EquipmentModel.where(id: items.keys).collect(&:id)\n self.items = items.select { |em, _count| valid_items.include? em }\n end", "def remove_from_list\n # if in_list?\n # decrement_positions...
[ "0.76052976", "0.6876154", "0.63864297", "0.632772", "0.61386406", "0.6077444", "0.60354894", "0.60253173", "0.6018955", "0.6008113", "0.5993467", "0.5975745", "0.5974182", "0.59669507", "0.59631884", "0.5959673", "0.59484965", "0.5943476", "0.59429574", "0.59238696", "0.5908...
0.76322925
0
reorder the list this item belongs to
def reorder_list(order) self.class.repair_list(list_scope.merge(:order => order)) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def reorder_list(order)\n model.repair_list(list_scope.merge(:order => order))\n end", "def reorder_queue_items\n queue_items.each_with_index do |queue_item,index|\n queue_item.update_attributes(list_order: index + 1)\n end\n end", "def reorder(positions)\n\t SortableList.new(self....
[ "0.761894", "0.72861505", "0.6808553", "0.6429333", "0.63515824", "0.63418937", "0.62593096", "0.6160428", "0.6114032", "0.6087117", "0.6077317", "0.6066348", "0.60639775", "0.60224295", "0.601586", "0.5976452", "0.5976452", "0.5970553", "0.5920123", "0.58942634", "0.5885365"...
0.7510975
1
move item to a position in the list. position should _only_ be changed through this
def move(vector) move_without_saving(vector) && save end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def move_to_position(new_position)\n old_position = self.send(position_column)\n unless new_position == old_position\n if new_position < old_position\n # Moving higher in the list (up) \n new_position = [1, new_position].max\n increment_positions_between(new_positi...
[ "0.7173106", "0.70128834", "0.68796986", "0.68556774", "0.67750704", "0.6688125", "0.66359854", "0.6534813", "0.6507391", "0.6486664", "0.64813644", "0.64677054", "0.6454275", "0.6412659", "0.6405844", "0.6404367", "0.63928306", "0.63774353", "0.63674104", "0.6349017", "0.630...
0.0
-1
Sr, Mst, Jr, Cat, Beg, Exp
def short_name Category.short_name name end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def stderrs; end", "def schumann; end", "def name; termid;end", "def text_sr_csd1_sinters_cont\n #\n # search * text * columns in .. table\n #\n # http://stackoverflow.com/questions/17980410/rails-get-the-names-of-all-a-tables-columns-of-a-certain-data-type-column\n # ModelClass.columns.select{ |c| c....
[ "0.5762351", "0.5433011", "0.540814", "0.5402696", "0.52553093", "0.5249595", "0.52339363", "0.5179001", "0.51565325", "0.51446575", "0.51356655", "0.5135644", "0.5135644", "0.5135644", "0.5135644", "0.5135644", "0.5135644", "0.5135644", "0.5135644", "0.5135644", "0.5135644",...
0.0
-1
Find best matching competition race for category. Iterate through traits (weight, equipment, ages, gender, abilities) until there is a single match (or none).
def best_match_in(event) logger.debug "Category#best_match_in #{name} in #{event.name}: #{event.categories.map(&:name).join(', ')}" candidate_categories = event.categories equivalent_match = candidate_categories.detect { |category| equivalent?(category) } logger.debug "equivalent: #{equivalent_match&.name}" return equivalent_match if equivalent_match candidate_categories = candidate_categories.select { |category| weight == category.weight } logger.debug "weight: #{candidate_categories.map(&:name).join(', ')}" candidate_categories = candidate_categories.select { |category| equipment == category.equipment } logger.debug "equipment: #{candidate_categories.map(&:name).join(', ')}" candidate_categories = candidate_categories.select { |category| ages_begin.in?(category.ages) } logger.debug "ages: #{candidate_categories.map(&:name).join(', ')}" candidate_categories = candidate_categories.reject { |category| gender == "M" && category.gender == "F" } logger.debug "gender: #{candidate_categories.map(&:name).join(', ')}" candidate_categories = candidate_categories.select { |category| ability_begin.in?(category.abilities) } logger.debug "ability: #{candidate_categories.map(&:name).join(', ')}" return candidate_categories.first if candidate_categories.one? return nil if candidate_categories.empty? if junior? junior_categories = candidate_categories.select { |category| category.junior? } logger.debug "junior: #{junior_categories.map(&:name).join(', ')}" return junior_categories.first if junior_categories.one? if junior_categories.present? candidate_categories = junior_categories end end if masters? masters_categories = candidate_categories.select { |category| category.masters? } logger.debug "masters?: #{masters_categories.map(&:name).join(', ')}" return masters_categories.first if masters_categories.one? if masters_categories.present? candidate_categories = masters_categories end end # E.g., if Cat 3 matches Senior Men and Cat 3, use Cat 3 # Could check size of range and use narrowest if there is a single one more narrow than the others candidate_categories = candidate_categories.reject { |category| category.all_abilities? } logger.debug "reject wildcards: #{candidate_categories.map(&:name).join(', ')}" return candidate_categories.first if candidate_categories.one? return nil if candidate_categories.empty? # "Highest" is lowest ability number highest_ability = candidate_categories.map(&:ability_begin).min if candidate_categories.one? { |category| category.ability_begin == highest_ability } highest_ability_category = candidate_categories.detect { |category| category.ability_begin == highest_ability } logger.debug "highest ability: #{highest_ability_category.name}" return highest_ability_category end candidate_categories = candidate_categories.reject { |category| gender == "F" && category.gender == "M" } logger.debug "exact gender: #{candidate_categories.map(&:name).join(', ')}" return candidate_categories.first if candidate_categories.one? return nil if candidate_categories.empty? logger.debug "no wild cards: #{candidate_categories.map(&:name).join(', ')}" return candidate_categories.first if candidate_categories.one? return nil if candidate_categories.empty? raise "Multiple matches #{candidate_categories.map(&:name)} for #{name} in #{event.categories.map(&:name).join(', ')}" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def best_match_in(event_categories, result_age = nil)\n debug \"Category#best_match_in for #{name} in #{event_categories.map(&:name).join(', ')}\"\n\n candidate_categories = event_categories.dup\n\n equivalent_matches = candidate_categories.select { |category| equivalent?(category) }\n debug \"...
[ "0.5972105", "0.5694107", "0.55712306", "0.5510315", "0.5304478", "0.5271997", "0.5234641", "0.5234431", "0.52040195", "0.51542526", "0.51541793", "0.5127752", "0.509658", "0.5092023", "0.5078666", "0.50630593", "0.50441486", "0.50382066", "0.50222635", "0.50100756", "0.49888...
0.6049323
0
Compare by position, then by name
def <=>(other) return -1 if other.nil? return super unless other.is_a?(Category) return 0 if self[:id] && self[:id] == other[:id] diff = (position <=> other.position) if diff == 0 name <=> other.name else diff end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def <=>(other)\n return 0 if self[:id] && self[:id] == other[:id]\n diff = (position <=> other.position)\n if diff == 0\n name <=> other.name\n else\n diff\n end\n end", "def get_position (item)\r\n position = 0\r\n self.items.each_with_index {|val, index|\r\n if (val.g...
[ "0.6098727", "0.56552356", "0.5651304", "0.5634825", "0.56164724", "0.56066626", "0.559979", "0.5567032", "0.55200934", "0.5510207", "0.5510207", "0.5474416", "0.5457802", "0.54541147", "0.54541147", "0.54392105", "0.5429191", "0.5424356", "0.5393678", "0.53846025", "0.537653...
0.54896104
11
of initialize Start sniffing packets
def sniff(queue = false) # sniff_queue if queue # potential optimization, turned off for now # Now read each packet and process it right away @sniffer.each_packet do |pkt| @event_collector.pkt_count += 1 @event_collector.bytes += pkt.caplen @event_collector.last_pkt = pkt case pkt when @tcp_traffic @tcp_handler.packet(pkt) if @tcp_handler when @udp_traffic @udp_handler.packet(pkt) if @udp_handler and pkt.udp? # INVESTIGATE! end end # of each_packet end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def initialize(args={})\n\t\t\t@array = [] # Where the packet array goes.\n\t\t\t@stream = [] # Where the stream goes.\n\t\t\t@iface = args[:iface] || Pcap.lookupdev || 'lo' \n\t\t\t@snaplen = args[:snaplen] || 0xffff\n\t\t\t@promisc = args[:promisc] || false # Sensible for some Intel wifi cards\n\t\t\t@timeout = ...
[ "0.67021465", "0.6464243", "0.6373231", "0.6279811", "0.6204968", "0.6192718", "0.6171683", "0.6126819", "0.6118835", "0.6113423", "0.6091746", "0.6075763", "0.6041054", "0.59792006", "0.59775686", "0.5962371", "0.5936485", "0.5920503", "0.5900025", "0.58803695", "0.5871472",...
0.0
-1
of sniff Version of the sniffer that uses multiple threads, may be better for bursty but otherwise low traffic environments.
def sniff_queue queue = Queue.new # Spin up a thread that just queues packets (a buffer, if you will) qthread = Thread.new do @sniffer.each_packet do |pkt| queue.push pkt unless queue.length > 1000 end end # of qthread # Now read each of those packets loop do pkt = queue.pop @event_collector.pkt_count += 1 @event_collector.bytes += pkt.caplen case pkt when @tcp_traffic @tcp_handler.packet(pkt) if @tcp_handler when @udp_traffic @udp_handler.packet(pkt) if @udp_handler and pkt.udp? # INVESTIGATE! end end # of each_packet end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def multithreaded\n get_value :multithreaded\n end", "def thread; end", "def thread; end", "def thread; end", "def do_sendtrain(train)\n # send the train\n $threadLock.synchronize {\n\twhile $activeThreads >= $maxThreads\n\t\t$threadCond.wait($threadLock)\t# wait until there is one less thread\n\...
[ "0.5767929", "0.5718602", "0.5718602", "0.5718602", "0.5625441", "0.55687666", "0.55488056", "0.55488056", "0.55488056", "0.54524916", "0.53529274", "0.5319013", "0.53042847", "0.5265917", "0.52533245", "0.52300936", "0.5217938", "0.52061605", "0.518276", "0.5179148", "0.5173...
0.5941943
0
Printable version of the state object
def to_s "#{str_ip(@src)}:#{@sport} - #{str_ip(@dst)}:#{@dport}" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def dump_state\n $log.debug \"State: [#{state.to_pretty_s}]\"\n end", "def inspect\n \"#{name}=#{state.inspect} #{location}\"\n end", "def to_s\n \"#{name}#{state}\"\n end", "def to_pretty_s\n \"#{type}:#{name} is #{state}\"\n end", "def show_state\n\t\tputs \"#{self.name} a...
[ "0.80072206", "0.7737337", "0.7633257", "0.75813806", "0.75032306", "0.7476722", "0.744327", "0.74336755", "0.7405574", "0.73759025", "0.73651224", "0.7357852", "0.7345984", "0.73437554", "0.731156", "0.73028475", "0.7274397", "0.7273967", "0.7270597", "0.7261709", "0.725933"...
0.0
-1
END OF TCP ONLY UDP STATE ONLY!
def udp_init(pkt, event_collector) @event_collector = event_collector @app_state = { :up => {}, :down => {} } @layer_4 = :udp end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def udp?\n return (proto == 'udp')\n end", "def socket?() end", "def udp?\n @udp_header\n end", "def test_ipv6_udp_local_server\n @@received_data = nil\n @local_port = next_port\n @@remote_ip = nil\n setup_timeout(2)\n\n EM.run do\n EM.open_datagram_socket(@@public_ipv...
[ "0.66795516", "0.6243401", "0.6168989", "0.60164624", "0.6008139", "0.5950736", "0.58950216", "0.58724046", "0.58172077", "0.58134234", "0.57394034", "0.5680634", "0.5666197", "0.56624615", "0.5659669", "0.56551105", "0.56325483", "0.56307197", "0.56221354", "0.56221354", "0....
0.5425003
34
Handle an incoming packet should be called by the child classes
def packet(pkt) if ((pkt.ip_mf? or pkt.ip_off > 0 )) $stderr.puts "*** Fragmented packet #{@event_collector.pkt_count}" @event_collector.send(:ip_fragmented_packet) do { :src_ip => pkt.src, :dst_ip => pkt.dst, :ip_id => pkt.ip_id, :ip_proto => pkt.ip_proto, :ip_off => pkt.ip_off, :ip_body => pkt.ip_data } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def processPacket(packet)\n\t\tbegin\n\t\t\thandle_packet(USAR::Packet.new(packet))\n\t\trescue Exception => e\n\t\t\t# Must keep these out of the Iridium handler\n\t\t\t$stderr.puts(\"While dispatching events: #{e.message}\")\n\t\t\te.backtrace.each { |line| $stderr.puts(\" at #{line}\") }\n\t\tend\n\tend", "d...
[ "0.722283", "0.717477", "0.6516462", "0.6402768", "0.6332344", "0.6320425", "0.6203065", "0.61291564", "0.61185133", "0.6096709", "0.6069891", "0.6041931", "0.5996417", "0.59771067", "0.5944253", "0.5910182", "0.58927655", "0.58531326", "0.5831442", "0.5829273", "0.5800635", ...
0.0
-1
Identify if this is a new stream or part of one that exists
def identify_state(pkt, type, make_state = true) # Create the id tuple (assumes TCP or UDP currently) s_ip, d_ip, sport, dport = pkt.src.to_i, pkt.dst.to_i, pkt.sport, pkt.dport # Make sure the same state is identified regarless of direction if s_ip > d_ip s_ip, d_ip, sport, dport = d_ip, s_ip, dport, sport end id = [ s_ip, d_ip, type, sport, dport ] # Existing state? state = @states[id] if state state.last_seen = pkt.time state.pkt = pkt end return state if state # New state state = StreamState.new(*id) @states[id] = state if make_state #$stderr.print "States: #{@states.length} " if make_state state.last_seen = pkt.time state.pkt = pkt state end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def stream?\n return false\n end", "def stream?\n !!@stream\n end", "def stream?\n !!@stream\n end", "def stream?\n @stream\n end", "def stream?\n @stream\n end", "def streaming?\n !stream.nil?\n end", "def declared_stream?(index)\n\t @streams && (@str...
[ "0.71916246", "0.7118464", "0.7118464", "0.6946211", "0.6946211", "0.6738565", "0.66923714", "0.6683005", "0.6583282", "0.6457821", "0.6413664", "0.6386765", "0.6381043", "0.63544476", "0.62808883", "0.6273944", "0.61971295", "0.6083237", "0.60686564", "0.60528374", "0.604328...
0.0
-1
Delete an existing state
def delete_state(state) @states.reject! { |_,v| v == state } #$stderr.print "States: #{@states.length} " end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete_state(state)\n states.remove(state)\n end", "def destroy\n @state.destroy\n end", "def destroy\n @state.destroy\n end", "def delete_state(node)\n # => Find the Node\n existing = find_state(node)\n return 'Node not present in state' unless existing\n # => Delete ...
[ "0.8555764", "0.82718337", "0.82718337", "0.75003797", "0.7347857", "0.73146665", "0.72802216", "0.7214706", "0.7214706", "0.7193557", "0.70991397", "0.7049778", "0.69601226", "0.69601226", "0.6918623", "0.6828458", "0.68117195", "0.679827", "0.67634714", "0.67495763", "0.672...
0.7615763
3
Receive an incoming packet. Return true if parsed, false if not.
def packet(pkt) super(pkt) # Only process packets with length right now return nil unless pkt.udp_data.length > 0 # Determine the packet's direction (up == src -> dst) dir = pkt.src.to_i < pkt.dst.to_i ? :up : :down # First, identify if this is a new stream or part of one on which we are # already keeping state. state = identify_state(pkt, :udp, false) state.udp_init(pkt, @event_collector) unless state.layer_4 @protos.parse(pkt.udp_data, state, dir) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def receive_packet\n\t\treturn parser.recv(self.sock)\n\tend", "def receive?\n type == 'receive'\n end", "def received?\n status.received? || status.read?\n end", "def recv\n data = String.new\n data << @socket.gets until data.match(/\\r\\n$/)\n Parser.parse(data)\n end", "def...
[ "0.6855456", "0.6343555", "0.6154703", "0.5993474", "0.59458494", "0.59374386", "0.5933196", "0.5866103", "0.5865824", "0.58347625", "0.5820895", "0.5754267", "0.5732191", "0.57225776", "0.57075965", "0.57003146", "0.56852853", "0.56744826", "0.5656433", "0.56099737", "0.5600...
0.52522725
38
Receive an incoming packet. Return true if parsed, false if not.
def packet(pkt) super(pkt) ret = nil # Let's ignore (for now) packets that are simply ACKs and nothing else return nil unless pkt.tcp_syn? or pkt.tcp_fin? or pkt.tcp_rst? or pkt.tcp_data_len > 0 # Should we be raising a STREAM event? if pkt.tcp_data_len > 0 and @event_collector.stream_capture @event_collector.stream_capture.each do |sc| if (sc[0].nil? or sc[0] == pkt.src.to_i) and # source IP (sc[2].nil? or sc[2] == pkt.dst.to_i) and # destination IP (sc[1].nil? or sc[1] == pkt.sport) and # source port (sc[3].nil? or sc[3] == pkt.dport) # destination port @event_collector.send(sc[4]) do state = identify_state(pkt, :tcp, false) { :content => pkt.tcp_data, :syn_seen => !!state.syn_seen, :src_ip => @protos.str_ip(pkt.src.to_i), :dst_ip => @protos.str_ip(pkt.dst.to_i), :src_port => pkt.sport, :dst_port => pkt.dport } end end # of if match end # of each stream_capture end # of if stream event # Determine the packet's direction (up == src -> dst) dir = pkt.src.to_i < pkt.dst.to_i ? :up : :down # First, identify if this is a new stream or part of one on which we are # already keeping state. make_state = !(pkt.tcp_fin? or pkt.tcp_rst?) state = identify_state(pkt, :tcp, make_state) state.ack_seen = pkt.tcp_ack? unless pkt.tcp_rst? # Check to see if we need to prune some state objects if pkt.time.to_i > @next_prune @next_prune = pkt.time.to_i + 60 # one minute prune interval syn_timeout = pkt.time - @event_collector.syn_timeout_delay stream_timeout = pkt.time - @event_collector.stream_timeout_delay @states.each do |_,chk| if chk.last_seen < syn_timeout # Is this state only a syn so far? if not chk.ack_seen @event_collector.send(:tcp_connect_failed) do { :timeout => true, :src_ip => @protos.str_ip(chk.src.to_i), :dst_ip => @protos.str_ip(chk.dst.to_i), :src_port => chk.sport, :dst_port => chk.dport, :rst => false } end delete_state(chk) # Okay, there's been some traffic. Has a full timeout occured? elsif chk.last_seen < stream_timeout @event_collector.send(:tcp_stream_end) do { :syn_seen => !!chk.syn_seen, :timeout => true, :src_ip => @protos.str_ip(chk.src.to_i), :dst_ip => @protos.str_ip(chk.dst.to_i), :rst => false, :dst_port => chk.dport, :src_port => chk.sport, :sync => false, :fin => false } end delete_state(chk) end # of if stream_timeout end # of syn_timeout end end # Is this state brand new? If so, add some TCP-specific information state.tcp_init(pkt, @event_collector) unless state.layer_4 # Let's make sure the sequence numbers are what we expect ret = validate_sequence_numbers(pkt, state, dir) if state.app_state return nil unless ret # If this is a connection we've seen in its entirety, hand it up to # the next stage - the protocol parser (layer 7) if state.app_state and pkt.tcp_data and pkt.tcp_data.length > 0 @protos.parse(pkt.tcp_data, state, dir) end # Is this a FIN or a RST? Should we close out this state? if pkt.tcp_fin? state.fin_up = true if dir == :up state.fin_down = true if dir == :down @protos.conclude(state, dir) # Signal the end of this direction end if pkt.tcp_rst? or (state.fin_up and state.fin_down) if not state.ack_seen # Explicit connection rejection @event_collector.send(:tcp_connect_failed) do { :timeout => false, :src_ip => @protos.str_ip(pkt.dst.to_i), :dst_ip => @protos.str_ip(pkt.src.to_i), :src_port => pkt.dport, :dst_port => pkt.sport, :rst => true } end else # regular connection termination @event_collector.send(:tcp_stream_end) do { :syn_seen => !!state.syn_seen, :src_ip => @protos.str_ip(pkt.src.to_i), :dst_ip => @protos.str_ip(pkt.dst.to_i), :src_port => pkt.sport, :dst_port => pkt.dport, :rst => pkt.tcp_rst?, :sync => false, :fin => (state.fin_up and state.fin_down), :timeout => false } end @protos.conclude(state, :up) # Signal the end of the stream in @protos.conclude(state, :down) # both directions. end delete_state(state) end # Finally, if we have a queued packet to inject, inject it now. This must # be done last! packet(ret) if ret.class <= ::Pcap::TCPPacket true end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def receive_packet\n\t\treturn parser.recv(self.sock)\n\tend", "def receive?\n type == 'receive'\n end", "def received?\n status.received? || status.read?\n end", "def recv\n data = String.new\n data << @socket.gets until data.match(/\\r\\n$/)\n Parser.parse(data)\n end", "def...
[ "0.6855456", "0.6343555", "0.6154703", "0.5993474", "0.59458494", "0.59374386", "0.5933196", "0.5866103", "0.5865824", "0.58347625", "0.5820895", "0.5754267", "0.5732191", "0.57225776", "0.57075965", "0.57003146", "0.56852853", "0.56744826", "0.5656433", "0.56099737", "0.5600...
0.49270847
94
of packet() If the sequence number is valid, update the stream attributes. If not, perform the appropriate response but don't update the stream. Return true if valid and should continue parsing, false if it shouldn't, and a pkt if there is a queued next packet that needs to be injected into the stream.
def validate_sequence_numbers(pkt, state, dir) expected_seq = dir == :up ? state.seq_up : state.seq_down # If we don't have an expected sequence number yet, set one expected_seq = pkt.tcp_seq if expected_seq == 0 # If we did not expect this sequence number, handle dissonance if pkt.tcp_seq != expected_seq return nil if pkt.tcp_seq < expected_seq # OS would ignore this packet # The sequence number is high - save it for later? if pkt.tcp_seq - expected_seq < FORWARD_WINDOW segments = dir == :up ? state.segments_up : state.segments_down segments[pkt.tcp_seq] = pkt else # This packet is too far in advance, we're aborting on this steram @event_collector.send(:tcp_stream_end) do { :syn_seen => !!state.syn_seen, :src_ip => @protos.str_ip(pkt.src.to_i), :dst_ip => @protos.str_ip(pkt.dst.to_i), :src_port => pkt.sport, :dst_port => pkt.dport, :rst => false, :fin => false, :sync => true, :timeout => false } end @protos.conclude(state, :up) # Kill the stream in both directions @protos.conclude(state, :down) state.app_state = nil # not parsing anymore #delete_state(state) # don't delete the state, FIN/RST will do it. end return nil # in either case, we don't process the packet right now # Sequence number was what we expected, this is part of our stream else # If this was a SYN packet, increase next expected sequence number by 1 # as specified by the TCP RFC. expected_seq += 1 if pkt.tcp_syn? # Adjust our next expected sequence number if dir == :up state.seq_up = (expected_seq + pkt.tcp_data_len) % 4294967296 else state.seq_down = (expected_seq + pkt.tcp_data_len) % 4294967296 end # Do we have a queued packet that we received out of order? segments = dir == :up ? state.segments_up : state.segments_down if segments.length > 0 queued_pkt = segments[expected_seq] segments.reject! { |k,_| k <= expected_seq } # delete all passed segs if queued_pkt return queued_pkt end end # of if segments.length > 0 end true end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def valid?\n return false if !@display_name.nil? && @display_name.to_s.length > 255\n return false if !@description.nil? && @description.to_s.length > 1024\n return false if @tcp_closed.nil?\n return false if @tcp_closed > 4320000\n return false if @tcp_closed < 10\n return false if @...
[ "0.54812187", "0.53521025", "0.53457576", "0.53096867", "0.5280621", "0.52769667", "0.52022445", "0.51943576", "0.51724285", "0.5150046", "0.5149561", "0.51452684", "0.5095811", "0.50434756", "0.5041339", "0.5025787", "0.50133234", "0.49645808", "0.4958033", "0.49557388", "0....
0.66046137
0
GET /wishes/1 GET /wishes/1.json
def show @wish = Wish.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render json: @wish } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n wishes = Wish.all.with_attached_image.where(is_secret: false)\n render json: { wishes: generate_image_url(wishes) }\n end", "def show\n render json: { wishes: generate_image_url([@wish]) }\n end", "def index\n @wishes = Wish.all\n end", "def index\n @wishes = Wish.all\n end", ...
[ "0.7184839", "0.7171834", "0.70841974", "0.70841974", "0.6775281", "0.671499", "0.6584657", "0.6511361", "0.64823955", "0.64786065", "0.64765525", "0.6347091", "0.6222626", "0.6214253", "0.61965126", "0.61599934", "0.61227614", "0.6074405", "0.6032576", "0.60155964", "0.60014...
0.70457643
4
GET /wishes/new GET /wishes/new.json
def new @wish = Wish.new respond_to do |format| format.html # new.html.erb format.json { render json: @wish } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @wishlistitem = Wishlistitem.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @wishlistitem }\n end\n end", "def new\n @wish_list_item = WishListItem.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { r...
[ "0.75034636", "0.7397594", "0.712135", "0.712135", "0.6997838", "0.6956595", "0.69218665", "0.6855291", "0.6832216", "0.6832216", "0.680942", "0.6806758", "0.6797136", "0.6782294", "0.67808294", "0.6780439", "0.6733088", "0.67297685", "0.6728313", "0.67146295", "0.67120075", ...
0.7856075
0
POST /wishes POST /wishes.json
def create @wish = current_user.wishes.build(params[:wish]) if @wish.save flash[:success] = "Wish created!" redirect_to root_url else @feed_items = [] render 'static_pages/home' end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @wish = Wish.create(wish_params)\n\n respond_to do |format|\n if @wish.save\n format.html { redirect_to @wish, notice: 'Wish was successfully created.' }\n format.json { render :show, status: :created, location: @wish }\n else\n format.html { render :new }\n ...
[ "0.6912995", "0.6840946", "0.6729906", "0.6561722", "0.6483702", "0.63777417", "0.63369393", "0.62611157", "0.6222567", "0.6171183", "0.61618245", "0.6150779", "0.6122475", "0.6095343", "0.60716784", "0.6065541", "0.6029707", "0.59819096", "0.5970839", "0.5970839", "0.5953641...
0.7107845
0
PUT /wishes/1 PUT /wishes/1.json
def update @wish = Wish.find(params[:id]) respond_to do |format| if @wish.update_attributes(params[:wish]) format.html { redirect_to @wish, notice: 'Wish was successfully updated.' } format.json { head :no_content } else format.html { render action: "edit" } format.json { render json: @wish.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n respond_to do |format|\n if @wish.update(wish_params)\n format.html { redirect_to @wish, notice: 'Wish was successfully updated.' }\n format.json { render :show, status: :ok, location: @wish }\n else\n format.html { render :edit }\n format.json { render json: @...
[ "0.6478893", "0.6446402", "0.6404435", "0.62265486", "0.62234676", "0.61401874", "0.61304915", "0.61304915", "0.61304915", "0.6079557", "0.6057336", "0.6011446", "0.59815335", "0.59564936", "0.5954274", "0.5932123", "0.5930394", "0.58973336", "0.5880298", "0.58720905", "0.585...
0.65631545
0
DELETE /wishes/1 DELETE /wishes/1.json
def destroy @wish.destroy redirect_to root_url end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @wish.destroy\n respond_to do |format|\n format.html { redirect_to wishes_url, notice: 'Wish was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete\n client.delete(\"/#{id}\")\n end", "def destroy\n @wishlistitem = Wishlistitem.f...
[ "0.7290465", "0.69545513", "0.6870536", "0.6861001", "0.68501", "0.684075", "0.6759711", "0.6735063", "0.673466", "0.673466", "0.6734169", "0.6734169", "0.6733039", "0.67086095", "0.6700075", "0.6683056", "0.66720235", "0.66648376", "0.66495174", "0.6647099", "0.6643405", "...
0.66857314
15
GET /aktions/1 GET /aktions/1.xml
def show @aktion = Aktion.find(params[:id]) respond_to do |format| format.html # show.html.erb format.xml { render :xml => @aktion } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @kontakties = Kontakty.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @kontakties }\n end\n end", "def show\n @arc = Arc.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render ...
[ "0.6348968", "0.61060447", "0.5890238", "0.583558", "0.5822921", "0.5783563", "0.57820463", "0.57705635", "0.5753406", "0.57525", "0.5744738", "0.57319534", "0.57258654", "0.57128507", "0.56969434", "0.5695478", "0.56927633", "0.5690401", "0.5683251", "0.56711614", "0.5668034...
0.6412662
0
GET /aktions/new GET /aktions/new.xml
def new @aktion = Aktion.new respond_to do |format| format.html # new.html.erb format.xml { render :xml => @aktion } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @atom = Atom.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @atom }\n end\n end", "def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => new_vurl }\n end\n end", "def new\n @newz...
[ "0.6836664", "0.66961354", "0.6647385", "0.6611461", "0.6600876", "0.6588805", "0.6579335", "0.6578438", "0.65678596", "0.6561316", "0.6546243", "0.6540222", "0.6532622", "0.6532622", "0.6532622", "0.6523455", "0.65155053", "0.6515044", "0.6496029", "0.64893603", "0.6485425",...
0.7027073
0
POST /aktions POST /aktions.xml
def create @aktion = Aktion.new(params[:aktion]) respond_to do |format| if @aktion.save flash[:notice] = 'Aktion was successfully created.' format.html { redirect_to(@aktion) } format.xml { render :xml => @aktion, :status => :created, :location => @aktion } else format.html { render :action => "new" } format.xml { render :xml => @aktion.errors, :status => :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @akt = Akt.new(akt_params)\n\n respond_to do |format|\n if @akt.save\n format.html { redirect_to @akt, notice: 'Акт створено.' }\n format.json { render :show, status: :created, location: @akt }\n else\n format.html do\n prepare_form_data\n render ...
[ "0.5446658", "0.5281343", "0.5253184", "0.5202324", "0.51885104", "0.5118851", "0.5112516", "0.508409", "0.5081446", "0.5081028", "0.5074932", "0.50144464", "0.5013193", "0.50059336", "0.49958107", "0.49835205", "0.49536613", "0.4944312", "0.49390098", "0.49359998", "0.493529...
0.5885438
0
PUT /aktions/1 PUT /aktions/1.xml
def update @aktion = Aktion.find(params[:id]) respond_to do |format| if @aktion.update_attributes(params[:aktion]) flash[:notice] = 'Aktion was successfully updated.' format.html { redirect_to(@aktion) } format.xml { head :ok } else format.html { render :action => "edit" } format.xml { render :xml => @aktion.errors, :status => :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update opts = {}\n opts[:headers] ||= {}\n opts[:headers]['Content-Type'] ||= 'text/xml'\n post 'update', opts\n end", "def test_should_update_link_via_API_XML\r\n get \"/logout\"\r\n put \"/links/1.xml\", :link => {:user_id => 1,\r\n :title => 'API Link 1',\...
[ "0.5846597", "0.5741908", "0.56314933", "0.56169415", "0.55770534", "0.5570146", "0.5535835", "0.55105174", "0.5508029", "0.54939276", "0.53676236", "0.5338769", "0.5329612", "0.53254646", "0.53153676", "0.530708", "0.5272382", "0.5258371", "0.52416664", "0.5218568", "0.52040...
0.58411115
1
DELETE /aktions/1 DELETE /aktions/1.xml
def destroy @aktion = Aktion.find(params[:id]) @aktion.destroy respond_to do |format| format.html { redirect_to(aktions_url) } format.xml { head :ok } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n RestClient.delete \"#{REST_API_URI}/contents/#{id}.xml\" \n self\n end", "def destroy\n @kontak = Kontak.find(params[:id])\n @kontak.destroy\n\n respond_to do |format|\n format.html { redirect_to(kontaks_url) }\n format.xml { head :ok }\n end\n end", "def delete()\n...
[ "0.67681015", "0.6438368", "0.63879585", "0.6378644", "0.6357101", "0.6355549", "0.63552016", "0.6332766", "0.63288426", "0.62855387", "0.62809", "0.62789476", "0.62674224", "0.62603086", "0.6244535", "0.6224033", "0.62123626", "0.6189972", "0.61838096", "0.6168901", "0.61669...
0.68998826
0
Sets flag to automatically capture after authorize
def add_purchase(post) post[:capture] = 'Y' end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def pre_authorize_cb=(_arg0); end", "def pre_authorize_cb; end", "def authorize\n end", "def authorize\n end", "def authorize(verb); send_or_default(\"authorize_#{verb}\",true) ; end", "def request_phase\n redirect authorize_endpoint_url\n end", "def authorize\n redirect_to root_path u...
[ "0.66869044", "0.6680191", "0.6661135", "0.6661135", "0.6496632", "0.647611", "0.62294614", "0.6065654", "0.6059518", "0.6055667", "0.6039504", "0.60253876", "0.6021499", "0.6017939", "0.5994822", "0.5992807", "0.5990933", "0.59710145", "0.59573424", "0.5952045", "0.59516984"...
0.0
-1
Sets flag to make create/update account the default account
def add_default_account(post) post[:defaultacct] = 'Y' end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_defaults\n self.state ||= 'ACTIVE'\n self.account_user_id ||= Gizmo::Util::Uuid.generate\n self.is_owner ||= false\n end", "def set_defaults\n self.state ||= 'NEW'\n self.account_id ||= Gizmo::Util::Uuid.generate\n self.account_name ||= self.subdomain\n end", "def set_...
[ "0.71875703", "0.6926933", "0.6569838", "0.6523224", "0.6505293", "0.6360575", "0.6339988", "0.6300126", "0.62328976", "0.6231819", "0.62196255", "0.6130573", "0.61287594", "0.61264807", "0.6109155", "0.61017406", "0.61017406", "0.6088548", "0.60852414", "0.60523975", "0.6046...
0.7921206
0
Adds profile to post and sets update flag
def add_profile(post, profile) post[:profile] = profile post[:profileupdate] = 'Y' end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_profile(body={})\n perform_post(\"/account/update_profile.json\", :body => body)\nend", "def set_post\n @profile = Profile.find(params[:id])\n end", "def update_profile(body)\n post(\"user/#{user_id}/profile.json\", body)\n end", "def update_profile(options={})\n perform_post...
[ "0.67057496", "0.66889435", "0.653363", "0.6407962", "0.63639706", "0.63453615", "0.62816125", "0.6268229", "0.6218425", "0.6208063", "0.62006456", "0.6168615", "0.6160453", "0.6145818", "0.61370856", "0.613005", "0.6107415", "0.61013746", "0.6100688", "0.60894877", "0.608503...
0.85272396
0
Parses profileid and acctid from profile, and adds it parameters, used for profile deletion
def add_profile_parameters(parameters, profile) profileid, acctid = profile.split('/') parameters[:profileid] = profileid parameters[:acctid] = acctid end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def profile_params\n params\n .require(:profile)\n .permit(:last_name, :first_name, :address, :phone, :age)\n .merge(:account_id => current_user.id)\n end", "def profile_params\n params.require(:profile).permit(:profile_first_name, :profile_last_name, :user_id, :profile_preferred_ri...
[ "0.67498636", "0.65747064", "0.6551823", "0.6509432", "0.6485902", "0.64439625", "0.6434388", "0.64103013", "0.6394292", "0.63849723", "0.633013", "0.63192815", "0.63086426", "0.630434", "0.6280754", "0.62768734", "0.6273976", "0.62671655", "0.626039", "0.6253733", "0.6248475...
0.82952243
0
GET /list_invites GET /list_invites.json
def index @list_invites = ListInvite.all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @invites = Invite.all\n end", "def index\n @invites = Invite.all\n end", "def index\n @invites = Invite.all\n end", "def index\n @invites = Invite.all\n end", "def index\n @invites = Invite.all\n end", "def index\n @invites = Invite.all\n\n respond_to do |format|\n ...
[ "0.7855363", "0.7855363", "0.7855363", "0.7855363", "0.7855363", "0.78424275", "0.78424275", "0.78424275", "0.7803815", "0.75770444", "0.7499979", "0.7492348", "0.7449011", "0.7435164", "0.73281956", "0.71798205", "0.7153547", "0.70924157", "0.70863575", "0.70551753", "0.6983...
0.7481334
12