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 |
|---|---|---|---|---|---|---|
DELETE /rubygems/1 DELETE /rubygems/1.json | def destroy
@rubygem = Rubygem.find(params[:id])
@rubygem.destroy
head :no_content
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @ruby_gem.destroy\n respond_to do |format|\n format.html { redirect_to ruby_gems_url, notice: 'Ruby gem was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def cmd_delete argv\n setup argv\n e = @hash['element']\n response = @api.delete(e)\n... | [
"0.6414446",
"0.63603926",
"0.63092405",
"0.62743425",
"0.62597483",
"0.619412",
"0.6181885",
"0.61412394",
"0.61015606",
"0.60950506",
"0.603945",
"0.60327744",
"0.6003717",
"0.59570956",
"0.59254724",
"0.58984596",
"0.5894893",
"0.5888762",
"0.5888762",
"0.5888762",
"0.5888... | 0.6731121 | 0 |
Used for capturing, which is currently not supported. | def add_reference(post, identification)
auth, trans_id = identification.split(';')
post[:authnum] = auth
post[:transid] = trans_id
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def capture(name); end",
"def captured?; @captured end",
"def captures\n end",
"def auto_capture?\n true\n end",
"def captures; end",
"def captures() end",
"def auto_capture?\n true\n end",
"def auto_capture?\n true\n end",
"def capture?\n true\n end",
"def match_capt... | [
"0.7438678",
"0.72289956",
"0.71225846",
"0.7115314",
"0.70948213",
"0.7092458",
"0.6826179",
"0.6826179",
"0.6681454",
"0.6629239",
"0.6605269",
"0.6499808",
"0.6498003",
"0.6497501",
"0.6465923",
"0.63952744",
"0.638429",
"0.637827",
"0.63782054",
"0.6368226",
"0.63548124",... | 0.0 | -1 |
returns the open/closed status of a menu either the active controller is used or the given status is returned | def controller_in_use_or(contr_name, status, klass)
if @controller.is_a? contr_name
:open
else
if status == :closed && (klass.count <= 3 )
# the box should be closed
# open it anyway if we have less than three
status = :open
end
status
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_status\n if draft\n :draft\n elsif closed || gross_amount <= paid_amount\n :closed\n elsif due_date and due_date > Date.today\n :opened\n else\n :overdue\n end\n end",
"def status\n STATUSES[self.status_id || 0]\n end",
"def status\n STATUSES[self.status_id]\n... | [
"0.6357593",
"0.6279441",
"0.6268635",
"0.6110707",
"0.6110499",
"0.6110499",
"0.6086054",
"0.6038338",
"0.6027947",
"0.60091645",
"0.59538573",
"0.5951731",
"0.5945187",
"0.5944002",
"0.5930695",
"0.59258974",
"0.5920019",
"0.5908869",
"0.5900328",
"0.58682406",
"0.58667517"... | 0.65415514 | 0 |
returns the display:none/visible attribute if the stages of a project should be shown | def show_stages_of_project(project)
a_stage_active = false
# check each stage
project.stages.each do |stage|
a_stage_active = true unless active_link_class(stage).blank?
end
# check project
a_stage_active = true unless active_link_class(project).blank?
a_stage_active ? '' : 'display:none;'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def visibility\n return nil if @visibility.nil?\n @visibility ? '1' : '0'\n end",
"def computed_visibility\n return \"embargoed\" if @embargoed\n return \"suppressed_workflow\" unless @public_readable_state\n @visibility\n end",
"def visible?\n @style.display != 'none'\n ... | [
"0.65476686",
"0.64009327",
"0.63229305",
"0.61531055",
"0.6119985",
"0.61047757",
"0.609648",
"0.6091929",
"0.6061885",
"0.60613036",
"0.6024697",
"0.6024697",
"0.6019333",
"0.5991026",
"0.5962016",
"0.59577036",
"0.5928653",
"0.5928653",
"0.5881005",
"0.5871015",
"0.5853473... | 0.81472385 | 0 |
returns a CSS class if the current item is an active item | def active_link_class(item)
active_class = 'active_menu_link'
found = false
case item.class.to_s
when 'Project'
found = true if (@project && @project == item) && (@stage.blank?)
when 'Host'
found = true if @host && @host == item
when 'Recipe'
found = true if @recipe && @recipe == item
when 'User'
found = true if @user && @user == item
when 'Stage'
found = true if @stage && @stage == item
end
if found
active_class
else
''
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def active_class(link_path)\n active = current_page?(link_path) ? \"active\" : \"no-active\"\n end",
"def active_class(link_path)\n active = current_page?(link_path) ? \"active\" : \"no-active\"\n end",
"def active_class(link_path)\n current_page?(link_path) ? \"active\" : \"\"\n end",
"def activ... | [
"0.77092534",
"0.77092534",
"0.7592172",
"0.7533669",
"0.73194563",
"0.7216001",
"0.7179645",
"0.71054256",
"0.6936378",
"0.69179064",
"0.6898548",
"0.67753005",
"0.6743486",
"0.6715099",
"0.6595075",
"0.65900767",
"0.65578",
"0.6510015",
"0.650153",
"0.6488306",
"0.6476714",... | 0.7714382 | 0 |
Set the factory class for this JointGroup. | def factoryClass=( jointClass )
raise TypeError, "No implicit conversion of #{jointClass.class.name} to Class" unless
(jointClass.nil? || jointClass.kind_of?( Class ))
@factoryClass = jointClass
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def default_factory=(factory); end",
"def set_klass\n @klass = params[:type].blank? ? Supergroup : params[:type].constantize\n end",
"def createJoint( *arguments )\n\t\t\traise RuntimeError, \"Not a factory JointGroup\" unless self.factory?\n\t\t\targuments.push( self )\n\t\t\treturn @factoryClass.new(... | [
"0.62166154",
"0.604645",
"0.5997043",
"0.5984858",
"0.561129",
"0.5498277",
"0.5472206",
"0.5472206",
"0.5407998",
"0.5366573",
"0.5335869",
"0.53222895",
"0.531192",
"0.5273381",
"0.52456045",
"0.5187663",
"0.5182551",
"0.5128813",
"0.51211345",
"0.5099122",
"0.50718313",
... | 0.7219851 | 0 |
Set the factory world for this JointGroup | def factoryWorld=( world )
raise TypeError, "No implicit conversion of #{world.class.name} to ODE::World" unless
(world.nil? || world.kind_of?( ODE::World ))
@factoryWorld = world
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def world=(world)\n @world = world\n end",
"def use_sdf_world\n world = sdf_world\n\n if @sdf_model\n model_in_world = resolve_model_in_world\n\n # Parse the whole world and massage it before we merge it in the\n #... | [
"0.6463787",
"0.5667107",
"0.56536186",
"0.5480278",
"0.5328095",
"0.5292323",
"0.5224079",
"0.5214773",
"0.51725924",
"0.512197",
"0.50778854",
"0.50735605",
"0.5068587",
"0.4989034",
"0.49541944",
"0.49433666",
"0.4937075",
"0.49336007",
"0.48755702",
"0.48311472",
"0.48311... | 0.71624106 | 0 |
Returns true if the JointGroup can act as a factory for member joints. | def factory?
return ! @factoryClass.nil? && ! @factoryWorld.nil?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def can_create_patient_laboratories?\n has_role?(:public_health) || has_role?(:public_health_enroller)\n end",
"def group_member?\n kind == 'group_member'\n end",
"def member_of?(entity)\n\t\tassociation_exists?(entity, \"membership\", \"joinable\", \"joined\")\n\tend",
"def is_member_of?(group)\n ... | [
"0.64376134",
"0.6431069",
"0.634846",
"0.63015765",
"0.6298697",
"0.62956804",
"0.618843",
"0.6176694",
"0.61455333",
"0.6124739",
"0.6119405",
"0.60674655",
"0.5978802",
"0.59779465",
"0.59752053",
"0.5966743",
"0.5952096",
"0.59476316",
"0.5933606",
"0.5931007",
"0.5911510... | 0.6001667 | 12 |
Create a new joint in the receiving JointGroup with the specified +arguments+. If the jointClass and world arguments weren't specified in this JointGroup's constructor, an exception is raised. | def createJoint( *arguments )
raise RuntimeError, "Not a factory JointGroup" unless self.factory?
arguments.push( self )
return @factoryClass.new( @factoryWorld, *arguments )
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_02_create_with_jointGroup\n\t\tprintTestHeader \"Test creation of Joints with JointGroups\"\n\n\t\tJointClasses.each {|klass|\n\t\t\tjoint = nil\n\n\t\t\tdebugMsg \"Creating a JointGroup.\"\n\t\t\tjointGroup = ODE::JointGroup.new\n\n\t\t\tassert_raises(TypeError, \"klass = #{klass.name}\") { klass.new(@wo... | [
"0.6115445",
"0.5990169",
"0.54785174",
"0.52358645",
"0.5149917",
"0.5131017",
"0.5125024",
"0.50894326",
"0.5028361",
"0.49634334",
"0.48370275",
"0.47814423",
"0.47791812",
"0.47713992",
"0.47483906",
"0.4715743",
"0.4709122",
"0.46851254",
"0.46564382",
"0.46529815",
"0.4... | 0.7410835 | 0 |
GET /tenant_family_members GET /tenant_family_members.json | def index
@rental = Rental.find(params[:rental_id])
@tenant_family_members = TenantFamilyMember.where(rental: @rental)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @family_members = @current_family.family_members\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @family_members }\n end\n end",
"def index\n @family_members = FamilyMember.all\n\n respond_to do |format|\n format.html # index.htm... | [
"0.7177736",
"0.7006969",
"0.67636585",
"0.67636585",
"0.6721574",
"0.65885437",
"0.65015125",
"0.6483629",
"0.64609534",
"0.64282846",
"0.6401663",
"0.63867366",
"0.6380566",
"0.63361233",
"0.6303328",
"0.6286744",
"0.62625855",
"0.62561315",
"0.62223893",
"0.62118804",
"0.6... | 0.63964164 | 11 |
GET /tenant_family_members/1 GET /tenant_family_members/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @family_member = FamilyMember.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @family_member }\n end\n end",
"def show\n @family_member = FamilyMember.find(params[:id])\n\n respond_to do |format|\n format.html # sho... | [
"0.706485",
"0.706485",
"0.7059206",
"0.70161474",
"0.697682",
"0.65226746",
"0.6469784",
"0.6428728",
"0.6421804",
"0.6356584",
"0.6311817",
"0.6263615",
"0.6260629",
"0.6242462",
"0.6238512",
"0.62258124",
"0.62244046",
"0.6220867",
"0.6180333",
"0.6134632",
"0.61316895",
... | 0.0 | -1 |
POST /tenant_family_members POST /tenant_family_members.json | def create
@rental = Rental.find(params[:rental_id])
@tenant_family_member = TenantFamilyMember.new(tenant_family_member_params)
@tenant_family_member.rental = @rental
respond_to do |format|
if @tenant_family_member.save
format.html { redirect_to @rental, notice: 'Tenant family member was successfully created.' }
format.json { render :show, status: :created, location: @tenant_family_member }
else
format.html { render :new }
format.json { render json: @tenant_family_member.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @family = Family.new(family_params)\n addMembers\n respond_to do |format|\n if @family.save\n format.html { redirect_to @family, notice: 'Family was successfully created.' }\n format.json { render :show, status: :created, location: @family }\n else\n format.html... | [
"0.7046893",
"0.7038084",
"0.6837247",
"0.68192756",
"0.673264",
"0.6719451",
"0.65465885",
"0.64146936",
"0.6361114",
"0.6349505",
"0.62932557",
"0.6270882",
"0.62672985",
"0.6056618",
"0.60484934",
"0.60452485",
"0.6002349",
"0.5998404",
"0.59940463",
"0.5978669",
"0.597866... | 0.66444147 | 6 |
PATCH/PUT /tenant_family_members/1 PATCH/PUT /tenant_family_members/1.json | def update
respond_to do |format|
if @tenant_family_member.update(tenant_family_member_params)
format.html { redirect_to @tenant_family_member, notice: 'Tenant family member was successfully updated.' }
format.json { render :show, status: :ok, location: @tenant_family_member }
else
format.html { render :edit }
format.json { render json: @tenant_family_member.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_tenant_family_member\n @tenant_family_member = TenantFamilyMember.find(params[:id])\n end",
"def update\n addMembers\n respond_to do |format|\n if @family.update(family_params)\n format.html { redirect_to @family, notice: 'Family was successfully updated.' }\n format.json... | [
"0.72184116",
"0.6887298",
"0.6674627",
"0.66294056",
"0.6567918",
"0.65296996",
"0.63307375",
"0.6300418",
"0.62557447",
"0.6123825",
"0.6080556",
"0.6008508",
"0.5992174",
"0.5990674",
"0.5970895",
"0.59698033",
"0.5957347",
"0.5915989",
"0.5881432",
"0.58685476",
"0.586366... | 0.76475054 | 0 |
DELETE /tenant_family_members/1 DELETE /tenant_family_members/1.json | def destroy
@tenant_family_member.destroy
respond_to do |format|
format.html { redirect_to :back, notice: 'Tenant family member was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_user_for_tenant(args = {}) \n delete(\"/tenants.json/#{args[:tenantId]}/users/#{args[:userId]}\", args)\nend",
"def destroy\n @family_member = FamilyMember.find(params[:id])\n @family_member.destroy\n\n respond_to do |format|\n format.html { redirect_to family_members_url }\n format... | [
"0.73631614",
"0.7323393",
"0.7323393",
"0.7283642",
"0.72771966",
"0.7269657",
"0.7148438",
"0.7042683",
"0.68375343",
"0.6832011",
"0.67702717",
"0.67645717",
"0.67474324",
"0.67302847",
"0.67117846",
"0.67102325",
"0.66929317",
"0.6683902",
"0.6673718",
"0.6673718",
"0.665... | 0.80630445 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_tenant_family_member
@tenant_family_member = TenantFamilyMember.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 tenant_family_member_params
params.require(:tenant_family_member).permit(:ss, :name, :member_type, :marital_status, :gender, :dob)
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 |
POST /signup return authenticated token after signup | def create
user = User.new(user_params)
if user.save
payload = { user_id: user.id }
hmac_secret = 'my$ecretK3ys'
auth_token = JWT.encode(payload, hmac_secret)
render json: { message: 'Account created successfully', auth_token: auth_token }
else
render json: { message: 'Something went wrong', errors: user.errors }, status: :unprocessable_entity
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def signup\n client.signup(\n params[:user],\n params[:password]\n )\n end",
"def sign_up\n user = User.new(signup_params)\n if user.save\n response = {success: true, result: user.id}\n render json: response, status: :created\n else\n response = {success: false}\n re... | [
"0.69742364",
"0.678802",
"0.66966623",
"0.6647017",
"0.66465735",
"0.66291577",
"0.64985305",
"0.6495331",
"0.6446778",
"0.6418159",
"0.6418159",
"0.6332511",
"0.63305223",
"0.62660825",
"0.625975",
"0.6242341",
"0.62387866",
"0.62158424",
"0.6211459",
"0.6210461",
"0.619380... | 0.59604615 | 52 |
A few characters (i.e. 2..7) and public/private surrogates (i.e. 55296..57343). These don't play nicely with Ruby's regular expression engine, and I think we can safely disregard them. | def invalid_regexp_chars
@invalid_regexp_chars ||= TwitterCldr::Utils::RangeSet.new(
[2..7, 55296..57343]
)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def key_replace\n /[^a-z0-9?]+/\n end",
"def strip_nongsm_chars!(replacement = \"\")\n # Should this be a patch to String?\n\n # keeping them here in canse I need them\n # basic alpha\n # '@','£','$','¥','è','é','ù','ì','ò','Ç',\"\\n\",'Ø','ø',\"\\r\",'Å','å',\n # 'Δ','_','Φ','Γ','Λ','Ω','Π','... | [
"0.61972004",
"0.6114053",
"0.6072357",
"0.5927142",
"0.59120077",
"0.58916366",
"0.57950056",
"0.5758892",
"0.57359946",
"0.56977457",
"0.5682193",
"0.56519425",
"0.56486493",
"0.5596365",
"0.5581648",
"0.55754817",
"0.55729836",
"0.55729836",
"0.55635524",
"0.5517485",
"0.5... | 0.6300958 | 0 |
redefine your position_taken? method here, so that you can use it in the valid_move? method above. | def position_taken?(board, index)
board[index] == "X" || board[index] == "O"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def position_taken?(board, position)\n return false if valid_move?(board, position)\n return true unless valid_move?(board, position)\nend",
"def position_taken?\nend",
"def valid_move?(board, index)\n if index.between?(0, 8)\n # re-define your #position_taken? method here, so that you can use it in the #v... | [
"0.8409533",
"0.8161412",
"0.80915326",
"0.802741",
"0.80150443",
"0.78980684",
"0.7893883",
"0.7886275",
"0.78447807",
"0.7843449",
"0.7831682",
"0.78148174",
"0.7813732",
"0.7810363",
"0.78020334",
"0.7801113",
"0.7800951",
"0.7789361",
"0.7782831",
"0.777421",
"0.7774137",... | 0.0 | -1 |
Get user password Get word length Counter starts at 0, while counter is less than length keep looping indexes Will call .next on each character Declare a variable for password as an empty string, that adds each letter to the string as we go If they index is a space, it just needs to return the space and not .next in order to avoid the ! mark Puts the new password | def encryptor(user_pass)
counter = 0
output = ""
while counter < user_pass.length
if user_pass[counter] == " "
output += " "
elsif user_pass[counter] == "z"
# conditional for "z"
output += "a"
else
output += user_pass[counter].next
end
counter += 1
end
return output
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def encrypt(password)\n counter = 0\n result = \"\"\n while counter < password.length\n letter = password[counter]\n \n if letter == \" \"\n result << \" \"\n elsif letter == \"z\"\n result << \"a\"\n else\n result << letter.next\n end\n counter += 1\n end\n result\nend",
"def next_pas... | [
"0.71894157",
"0.70625377",
"0.6995681",
"0.6992447",
"0.6787891",
"0.6780326",
"0.67153853",
"0.6697874",
"0.66783667",
"0.66739887",
"0.6673464",
"0.665798",
"0.66516274",
"0.66436964",
"0.66138333",
"0.66067094",
"0.66036403",
"0.65993434",
"0.65663266",
"0.6566135",
"0.65... | 0.73361635 | 0 |
Decrypt Get word length Counter starts at 0, while counter is less than length keep looping indexes Set variable to alphabet with string input az Go through each character in alphabet string, check the index of current letter against it | def decryptor(user_decpt)
counter = 0
output = ""
alphabet = "abcdefghijklmnopqrstuvwxyz"
while counter < user_decpt.length
if user_decpt[counter] == " "
output += " "
else
# While
temp = user_decpt[counter]
# puts alphabet.index(temp)
# Check alphabet index counter
ind = alphabet.index(temp)
output += alphabet[ind-1]
# alphabet.index(temp)
end
counter += 1
end
return output
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def decrypt(word)\n counter = 0\n password = \"\"\n\n until counter == word.length\n alphabet = \"abcdefghijklmnopqrstuvwxyz\"\n letter = alphabet.index(word[counter]) - 1\n counter += 1\n password = alphabet[letter] + password\n\n end\n password.reverse\n end",
"def decrypt(str)\n\talp... | [
"0.75457",
"0.751251",
"0.7483407",
"0.73704594",
"0.7297076",
"0.7275832",
"0.72751397",
"0.7263677",
"0.72634864",
"0.7235411",
"0.7223568",
"0.7216204",
"0.7181569",
"0.7168768",
"0.7156502",
"0.7153277",
"0.71372557",
"0.7135981",
"0.71124965",
"0.7102372",
"0.70943034",
... | 0.7154395 | 15 |
this is a new method called fizz_buzz_to with an argument called limit | def fizz_buzz_to(limit)
#this signifies a loop stating that from 1 up to the inputed limit, the code will continue to execute
1.upto(limit).each do |num|
#prints the results of the previous method each time the loop is executed
puts fizzbuzz(num)
#ends the upto loop
end
#ends defined method
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fizz_buzz_to(limit)\n 1.upto(limit).each do |num|\n puts fizzbuzz(num)\n end\n end",
"def fizz_buzz_to(limit)\n 1.upto(limit).each do |num|\n puts fizzbuzz(num)\n end\nend",
"def fizz_buzz_to(limit)\n# This defines the variable \"fizz_buzz-to\" and explains in parenthesis what parameters c... | [
"0.8807376",
"0.8348959",
"0.7946808",
"0.7770547",
"0.76865476",
"0.76290077",
"0.7564138",
"0.74508256",
"0.7426141",
"0.73063815",
"0.7288593",
"0.71145016",
"0.7033709",
"0.7006987",
"0.7003468",
"0.6904741",
"0.6873737",
"0.6868348",
"0.6855291",
"0.6818868",
"0.6813667"... | 0.732101 | 9 |
Send out the latest bootcode to Nabaztag | def bootcode
# /vl/bc.jsp?v=0.0.0.10&m=00:19:db:9e:92:91&l=00:00:00:00:00:00&p=00:00:00:00:00:00&h=4
#
# Firmware version, e.g.0.0.0.10
@version = params[:v]
# MAC address
@serial = params[:m]
# Hardware model 4 == V2 model
@hardware = params[:h]
send_file Rails.public_path+'/'+'bc-nominal-segabor.bin',
:type => 'application/octet-stream'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def boot\n runcmd 'boot'\n end",
"def getup\n send_command 0x23, 0x2\n end",
"def change_bootorder(vid, bootorder)\n perform_request(:action => 'vserver-bootorder', :vserverid => vid, :bootorder => bootorder.to_s)\n end",
"def receive\n\t\t# send ready\n\t\tputs @ready_word\n\n\t\t# ini... | [
"0.530491",
"0.5225488",
"0.5187252",
"0.51833993",
"0.5106289",
"0.5097861",
"0.5094565",
"0.5094565",
"0.5065762",
"0.505501",
"0.5049577",
"0.5007291",
"0.500362",
"0.49819472",
"0.49540895",
"0.49473652",
"0.49210086",
"0.49168998",
"0.49157545",
"0.49091592",
"0.4866554"... | 0.70933545 | 0 |
Bunny requests the location of different services | def locate
# Object version, e.g. 18673 (BC version)
@version = params[:v]
# MAC address / serial
@serial = params[:sn]
# Hardware model 4 == V2 model
@hardware = params[:h]
if (HARDWARE[@hardware.to_i] == :v2)
resp = <<__TEXT
ping #{Rails.configuration.zone_ping}
broad #{Rails.configuration.broad}
xmpp_domain #{Rails.configuration.xmpp}
__TEXT
render :text => resp
else
# FIXME
render :text => ""
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def locations\n @client.get('/BikePoint')\n end",
"def locate(address)\n get :location => address\n end",
"def locations(place)\n get :loc => place\n end",
"def location\n @client.get(\"#{path}/location\")\n end",
"def locationLookup(currLoc) \n client = Weatherman::Client.new\n ... | [
"0.6346663",
"0.62082696",
"0.6095763",
"0.6051789",
"0.60020304",
"0.57933396",
"0.57913584",
"0.5754938",
"0.57352304",
"0.5722896",
"0.5722896",
"0.5712282",
"0.56710607",
"0.56218374",
"0.5605304",
"0.55622303",
"0.5538627",
"0.55345464",
"0.54894316",
"0.54865634",
"0.54... | 0.0 | -1 |
Allow all admins to read any data. Allow members to read only their own data. | def authorized_for_read?
return true if !existing_record_check?
if !current_user.nil?
if current_user.has_role?(:admin)
return true
else
return !current_user.groups.map{|g| g.is_a?(Group) ? g.id : g}.index(self.group_id).nil?
end
else
return false
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allowed_to_read_other_users\n return @allowed_to_read_other_users\n end",
"def allowed_to_read_other_users=(value)\n @allowed_to_read_other_users = value\n end",
"def permits_read_acccess_for(user)\n end",
"def read_permitted?\n return (acting_u... | [
"0.71296406",
"0.7069978",
"0.70094645",
"0.6954776",
"0.69525385",
"0.69349915",
"0.6791307",
"0.6769716",
"0.6769716",
"0.6749773",
"0.6724507",
"0.6709357",
"0.6692537",
"0.6683654",
"0.6678098",
"0.6648495",
"0.6648495",
"0.6648495",
"0.66042095",
"0.6600696",
"0.6598303"... | 0.0 | -1 |
stub so can use for event setting | def canonical_date
self.created_at
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def events=(_); end",
"def event; end",
"def event; end",
"def event; end",
"def define_event_helpers; end",
"def qualified_event; end",
"def qualified_event; end",
"def event_change\n\t\n\tend",
"def events; end",
"def events; end",
"def events; end",
"def events; end",
"def events; end",
... | [
"0.70350254",
"0.6906553",
"0.6906553",
"0.6906553",
"0.67888707",
"0.6629049",
"0.6629049",
"0.65791726",
"0.6537541",
"0.6537541",
"0.6537541",
"0.6537541",
"0.6537541",
"0.6537541",
"0.6537541",
"0.6537541",
"0.6513455",
"0.6513455",
"0.64841723",
"0.64197546",
"0.6318259"... | 0.0 | -1 |
Sets up the Routes app to be run | def app
routes = Routes
routes.set :public_folder, 'public'
routes.set :environment, :test
routes
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_routes!\n Router.new(self).generate(@app)\n end",
"def init_routes\n puts \"Adding the caboose store routes...\"\n \n filename = File.join(@app_path,'config','routes.rb')\n return if !File.exists?(filename)\n return if !@force\n \n str = \"\" \n str <<... | [
"0.7132192",
"0.69681126",
"0.69115686",
"0.6737827",
"0.6518207",
"0.64326555",
"0.64178246",
"0.63495195",
"0.630628",
"0.6263179",
"0.6249993",
"0.6249993",
"0.6249993",
"0.6249993",
"0.6249993",
"0.6249993",
"0.6249993",
"0.6249993",
"0.6249993",
"0.6249993",
"0.6249993",... | 0.72770435 | 0 |
Code to run before each test | def setup
DBHandler.establish_test_connection
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def before_test(test); end",
"def before_test(test); end",
"def before() ; end",
"def before\n end",
"def before_run; end",
"def setup(&block)\n before(:each, &block)\n end",
"def before_setup\n # do nothing by default\n end",
"def before_load(test_files); end",
"def before... | [
"0.8358595",
"0.8358595",
"0.7641491",
"0.7525786",
"0.7520464",
"0.75197846",
"0.75147015",
"0.7474896",
"0.74415815",
"0.74246985",
"0.74127597",
"0.7408981",
"0.72738487",
"0.7244817",
"0.719671",
"0.719594",
"0.7111414",
"0.7069569",
"0.695189",
"0.6869759",
"0.68656003",... | 0.0 | -1 |
Some of the contents of this method could have been split into another (privagte) method, etc. I tried to keep things simple however. | def data
file_contents = {}
File.read(@filename).split("\n").each do |line|
url = line.split(' ').first
ip_address = line.split(' ').last
file_contents[url] = [] unless file_contents.has_key? url
file_contents[url] << ip_address
end
file_contents
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def private; end",
"def probers; end",
"def internal; end",
"def schubert; end",
"def implementation; end",
"def implementation; end",
"def private_method\n end",
"def who_we_are\r\n end",
"def methods() end",
"def custom; end",
"def custom; end",
"def suivre; end",
"def isolated; end... | [
"0.7318843",
"0.6977644",
"0.64367354",
"0.6401782",
"0.639471",
"0.639471",
"0.6376193",
"0.6322862",
"0.6316693",
"0.6304587",
"0.6304587",
"0.6296633",
"0.62083983",
"0.62083983",
"0.6189538",
"0.6189538",
"0.6189538",
"0.6184126",
"0.6171374",
"0.6171374",
"0.6171374",
... | 0.0 | -1 |
Args : +public_key+ > elliptic curve public key +payload+ > event payload in the request body +signature+ > signature value obtained from the 'XTwilioEmailEventWebhookSignature' header +timestamp+ > timestamp value obtained from the 'XTwilioEmailEventWebhookTimestamp' header | def verify_signature(public_key, payload, signature, timestamp)
verify_engine
timestamped_playload = "#{timestamp}#{payload}"
payload_digest = Digest::SHA256.digest(timestamped_playload)
decoded_signature = Base64.decode64(signature)
public_key.dsa_verify_asn1(payload_digest, decoded_signature)
rescue StandardError
false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def verify_webhook_signature\n their_signature_header = request.env['HTTP_X_HUB_SIGNATURE'] || 'sha1='\n method, their_digest = their_signature_header.split('=')\n our_digest = OpenSSL::HMAC.hexdigest(method, WEBHOOK_SECRET, @payload_raw)\n halt 401 unless their_digest == our_digest\n\n # ... | [
"0.6344173",
"0.62988865",
"0.61561894",
"0.59845436",
"0.58991593",
"0.5874673",
"0.5853681",
"0.5817075",
"0.58070016",
"0.58016264",
"0.5777645",
"0.57625085",
"0.57345855",
"0.57125884",
"0.5666045",
"0.5649906",
"0.5641626",
"0.56211394",
"0.5572981",
"0.5557843",
"0.554... | 0.5721131 | 13 |
Returns the read_capacity for this table. | def read_capacity
options[:read_capacity] || Dynamoid::Config.read_capacity
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_capacity\n rpc_get_fact_direct('capacity').to_f\n end",
"def capacity\n\t\t\t\t\treturn self.send(\"capacity_#{self.capacity_type.to_s}\")\n\t\t\t\tend",
"def capacity\n return @capacity\n end",
"def capacity\n data[:capacity]\n end",
"def capacity\n @... | [
"0.69557774",
"0.67469424",
"0.67459863",
"0.66560924",
"0.6626779",
"0.6481283",
"0.63985896",
"0.63225794",
"0.6296261",
"0.6238506",
"0.61659205",
"0.60804844",
"0.6043774",
"0.6035073",
"0.6026312",
"0.60107714",
"0.60032046",
"0.59982765",
"0.59574884",
"0.5943415",
"0.5... | 0.79020256 | 1 |
Returns the write_capacity for this table. | def write_capacity
options[:write_capacity] || Dynamoid::Config.write_capacity
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def capacity\n return @capacity\n end",
"def capacity\n @capacity\n end",
"def capacity\n\t\t\t\t\treturn self.send(\"capacity_#{self.capacity_type.to_s}\")\n\t\t\t\tend",
"def capacity\n data[:capacity]\n end",
"def get_capacity\n rpc_get_fact_direct('capacit... | [
"0.6823094",
"0.6776425",
"0.6703071",
"0.6564977",
"0.65127313",
"0.64323705",
"0.64146906",
"0.63625246",
"0.6303116",
"0.6262304",
"0.62171245",
"0.62125856",
"0.6211626",
"0.6211626",
"0.6191594",
"0.6188096",
"0.6184436",
"0.60822016",
"0.5990612",
"0.5960849",
"0.594373... | 0.7693461 | 1 |
Returns the id field for this class. | def hash_key
options[:key] || :id
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def id\n fields['id']\n end",
"def id\n read_attribute(self.class.primary_key)\n end",
"def id\n read_attribute(self.class.primary_key)\n end",
"def id\n @attributes[\"#{self.class.to_s.split('::').last.underscore.downcase}_id\".to_sym]\n end",
"def get_id()\... | [
"0.82249796",
"0.81449354",
"0.81449354",
"0.79128593",
"0.7858401",
"0.7843164",
"0.7792553",
"0.7764056",
"0.77451116",
"0.7741279",
"0.7707888",
"0.7675162",
"0.76506954",
"0.76368356",
"0.7607914",
"0.76050615",
"0.7554595",
"0.7545074",
"0.7515869",
"0.7515869",
"0.75077... | 0.0 | -1 |
Returns the number of items for this class. | def count
Dynamoid.adapter.count(table_name)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def item_count\n @items.length\n end",
"def count_items\n @items.size\n end",
"def count\r\n items.size\r\n end",
"def item_count\n return @item_count\n end",
"def count\n @item_list.size\n end",
"def size\n\n @items.size\n end",
"de... | [
"0.8916682",
"0.88133454",
"0.86688715",
"0.8467468",
"0.84143597",
"0.83306366",
"0.8318026",
"0.8318026",
"0.8312499",
"0.8264976",
"0.82457376",
"0.82375705",
"0.8212539",
"0.8204931",
"0.8204931",
"0.81821203",
"0.8172911",
"0.8154701",
"0.81498647",
"0.81491",
"0.8142714... | 0.0 | -1 |
Initialize a new object and immediately save it to the database. | def create(attrs = {})
if attrs.is_a?(Array)
attrs.map { |attr| create(attr) }
else
build(attrs).tap(&:save)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize\n save\n end",
"def initialize \n save\n end",
"def initialize\n self.save\n end",
"def initialize(*args)\n\t\t\t\t\tself.track_changed_attributes = true\n\t\t\t\t\tself.changed_attributes_aado = []\n\n\t\t\t\t\tsuper(*args)\n\t\t\t\t\t\n\t\t\t\t\trequire \"obdb/AR_Databas... | [
"0.7522409",
"0.73761046",
"0.72401816",
"0.6648427",
"0.65201825",
"0.6501229",
"0.6458453",
"0.64292604",
"0.6337485",
"0.62961787",
"0.6293484",
"0.6293484",
"0.62817866",
"0.62620264",
"0.62482804",
"0.62304956",
"0.6219112",
"0.62186897",
"0.62057006",
"0.62018317",
"0.6... | 0.0 | -1 |
Initialize a new object and immediately save it to the database. Raise an exception if persistence failed. | def create!(attrs = {})
if attrs.is_a?(Array)
attrs.map { |attr| create!(attr) }
else
build(attrs).tap(&:save!)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize\n save\n end",
"def initialize \n save\n end",
"def initialize\n self.save\n end",
"def save\n Ribs.with_handle(self.database) do |h|\n if self.class.persistent?(self.model)\n h.update_obj(self.model)\n else\n h.insert_obj(sel... | [
"0.67960376",
"0.6632419",
"0.6565173",
"0.63643354",
"0.6236041",
"0.6177525",
"0.61292624",
"0.6009838",
"0.60096246",
"0.60096246",
"0.60096246",
"0.5980818",
"0.594657",
"0.59184355",
"0.5909367",
"0.590391",
"0.5888432",
"0.5863612",
"0.5841626",
"0.57850736",
"0.5778702... | 0.0 | -1 |
Initialize a new object. | def build(attrs = {})
attrs[:type] ? attrs[:type].constantize.new(attrs) : new(attrs)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize() end",
"def initialize\n initialize!\n end",
"def initialize\n initialize!\n end",
"def initialize()\n end",
"def initialize\n end",
"def initialize(obj); end",
"def initialize\n end",
"def initialize\n end",
"def initialize\n end",
"de... | [
"0.82675546",
"0.81509084",
"0.81509084",
"0.8112277",
"0.8054054",
"0.80489457",
"0.8032879",
"0.8032879",
"0.8032879",
"0.8032879",
"0.8032879",
"0.8032879",
"0.80202717",
"0.80183256",
"0.80096203",
"0.80096203",
"0.80096203",
"0.80096203",
"0.80096203",
"0.791662",
"0.791... | 0.0 | -1 |
Does this object exist? | def exists?(id_or_conditions = {})
case id_or_conditions
when Hash then where(id_or_conditions).first.present?
else
begin
find(id_or_conditions)
true
rescue Dynamoid::Errors::RecordNotFound
false
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def exists?(object); end",
"def exists?(object); end",
"def exists?\n assert_exists\n true\n rescue UnknownObjectException\n false\n end",
"def exist?\n true\n end",
"def object_exist?(object_key)\n return get_objects.has_key?(object_key)\n end",
"def exists?()\n ... | [
"0.856896",
"0.856896",
"0.8176319",
"0.8040835",
"0.79606336",
"0.794399",
"0.7852454",
"0.78505534",
"0.78490895",
"0.7804561",
"0.77818733",
"0.7760379",
"0.7680516",
"0.7680516",
"0.7651702",
"0.76503956",
"0.76452565",
"0.7623805",
"0.7621136",
"0.7617387",
"0.7601271",
... | 0.0 | -1 |
Update document with provided values. Instantiates document and saves changes. Runs validations and callbacks. | def update(hash_key, range_key_value = nil, attrs)
model = find(hash_key, range_key: range_key_value, consistent_read: true)
model.update_attributes(attrs)
model
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n save_doc\n end",
"def update_document(fields, safe = false)\n collection.update({\"_id\" => self.id}, fields, :safe => safe)\n reload\n end",
"def update\n document = Document.find(params[:id])\n document.update!(update_params)\n render json: {}\n end",
"def ... | [
"0.7540587",
"0.69950986",
"0.68449026",
"0.67626595",
"0.6735612",
"0.6732099",
"0.67231625",
"0.6690932",
"0.6662069",
"0.6621141",
"0.66006136",
"0.66006136",
"0.65901315",
"0.65175784",
"0.65134716",
"0.6513461",
"0.6496654",
"0.64643735",
"0.64583373",
"0.6454102",
"0.64... | 0.0 | -1 |
Update existing document or create new one. Similar to `.update_fields`. The only diffirence is creating new document. Uses efficient lowlevel `UpdateItem` API call. Changes attibutes and loads new document version with one API call. Doesn't run validations and callbacks. Can make conditional update. If specified conditions failed returns `nil` | def upsert(hash_key_value, range_key_value = nil, attrs = {}, conditions = {})
optional_params = [range_key_value, attrs, conditions].compact
if optional_params.first.is_a?(Hash)
range_key_value = nil
attrs, conditions = optional_params[0..1]
else
range_key_value = optional_params.first
attrs, conditions = optional_params[1..2]
end
options = if range_key
value_casted = TypeCasting.cast_field(range_key_value, attributes[range_key])
value_dumped = Dumping.dump_field(value_casted, attributes[range_key])
{ range_key: value_dumped }
else
{}
end
options[:conditions] = conditions
begin
new_attrs = Dynamoid.adapter.update_item(table_name, hash_key_value, options) do |t|
attrs.symbolize_keys.each do |k, v|
value_casted = TypeCasting.cast_field(v, attributes[k])
value_dumped = Dumping.dump_field(value_casted, attributes[k])
t.set(k => value_dumped)
end
end
attrs_undumped = Undumping.undump_attributes(new_attrs, attributes)
new(attrs_undumped)
rescue Dynamoid::Errors::ConditionalCheckFailedException
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update!(**args)\n @condition = args[:condition] if args.key?(:condition)\n @document_schema_name = args[:document_schema_name] if args.key?(:document_schema_name)\n end",
"def update!(**args)\n @conditions = args[:conditions] if args.key?(:conditions)\n @parameters ... | [
"0.6810581",
"0.6691096",
"0.66179526",
"0.6377603",
"0.63565606",
"0.6339557",
"0.6265456",
"0.6210852",
"0.6189191",
"0.61710703",
"0.614811",
"0.61039597",
"0.6101092",
"0.607687",
"0.60626763",
"0.6035509",
"0.6022581",
"0.60168743",
"0.6004779",
"0.598864",
"0.59541684",... | 0.0 | -1 |
Initialize a new object. | def initialize(attrs = {})
# we need this hack for Rails 4.0 only
# because `run_callbacks` calls `attributes` getter while it is still nil
@attributes = {}
run_callbacks :initialize do
@new_record = true
@attributes ||= {}
@associations ||= {}
self.class.attributes.each do |_, options|
if options[:type].is_a?(Class) && options[:default]
raise 'Dynamoid class-type fields do not support default values'
end
end
attrs_with_defaults = {}
self.class.attributes.each do |attribute, options|
attrs_with_defaults[attribute] = if attrs.key?(attribute)
attrs[attribute]
elsif options.key?(:default)
evaluate_default_value(options[:default])
end
end
attrs_virtual = attrs.slice(*(attrs.keys - self.class.attributes.keys))
load(attrs_with_defaults.merge(attrs_virtual))
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize() end",
"def initialize\n initialize!\n end",
"def initialize\n initialize!\n end",
"def initialize()\n end",
"def initialize\n end",
"def initialize(obj); end",
"def initialize\n end",
"def initialize\n end",
"def initialize\n end",
"de... | [
"0.82675546",
"0.81509084",
"0.81509084",
"0.8112277",
"0.8054054",
"0.80489457",
"0.8032879",
"0.8032879",
"0.8032879",
"0.8032879",
"0.8032879",
"0.8032879",
"0.80202717",
"0.80183256",
"0.80096203",
"0.80096203",
"0.80096203",
"0.80096203",
"0.80096203",
"0.791662",
"0.791... | 0.0 | -1 |
An object is equal to another object if their ids are equal. | def ==(other)
if self.class.identity_map_on?
super
else
return false if other.nil?
other.is_a?(Dynamoid::Document) && hash_key == other.hash_key && range_value == other.range_value
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def equal?(other)\n object_id == other.object_id\n end",
"def == other\n self.object_id == other.object_id\n end",
"def ==(object)\n self._id == object._id rescue false\n end",
"def == other\n self.id == other.id\n end",
"def ==(other)\n self.id == other.id\n end",
"def ==... | [
"0.8220613",
"0.81845176",
"0.81512064",
"0.8049561",
"0.799105",
"0.79666346",
"0.79458225",
"0.79458225",
"0.79458225",
"0.79458225",
"0.79453343",
"0.7944586",
"0.7845591",
"0.78013617",
"0.77995664",
"0.77868414",
"0.77868414",
"0.77805513",
"0.7765878",
"0.7732811",
"0.7... | 0.0 | -1 |
Reload an object from the database if you suspect the object has changed in the datastore and you need those changes to be reflected immediately, you would call this method. This is a consistent read. | def reload
options = { consistent_read: true }
if self.class.range_key
options[:range_key] = range_value
end
self.attributes = self.class.find(hash_key, options).attributes
@associations.values.each(&:reset)
self
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reload\n return false if !persisted?\n fresh_object = self.class.find(id)\n refresh_data fresh_object.instance_variable_get('@attributes')\n self\n end",
"def reload(obj, pk)\n return nil unless pk\n\n klass = obj.class\n raise \"Cannot reload unmanaged object\" unle... | [
"0.7474786",
"0.7430602",
"0.7402924",
"0.7363086",
"0.7172991",
"0.6917145",
"0.6850313",
"0.6847813",
"0.6757184",
"0.67240465",
"0.6687277",
"0.65954876",
"0.6595324",
"0.64965516",
"0.64965516",
"0.64331913",
"0.64266557",
"0.64104646",
"0.6333668",
"0.63289243",
"0.63053... | 0.61209714 | 34 |
Return an object's hash key, regardless of what it might be called to the object. | def hash_key
send(self.class.hash_key)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hash #:nodoc:\n __getobj__.hash ^ self.class.hash\n end",
"def _hashback_id_key\n self.__send__(self.class.__send__(:class_variable_get, :@@_key_method_sym))\n end",
"def hash_key(name); end",
"def hash_code; end",
"def hash\n object_id\n end",
"de... | [
"0.73707944",
"0.70565784",
"0.70427126",
"0.7037317",
"0.69684047",
"0.69328797",
"0.6932759",
"0.6905596",
"0.6837324",
"0.67446023",
"0.6643275",
"0.66346335",
"0.6621007",
"0.6596987",
"0.6573759",
"0.6551596",
"0.65201056",
"0.65062994",
"0.6463648",
"0.64467573",
"0.642... | 0.78648907 | 1 |
Assign an object's hash key, regardless of what it might be called to the object. | def hash_key=(value)
send("#{self.class.hash_key}=", value)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def will_create_new_hash(**hash)\n hash[:x] = 10 # Change\n p hash\n p hash.object_id \nend",
"def hash_key\n send(self.class.hash_key)\n end",
"def hash_key\n send(self.class.hash_key)\n end",
"def hash=(_arg0); end",
"def assign_key(obj)\n \tsuper(obj)\n \tcase \n \t\twhen obj.is_a?... | [
"0.6462615",
"0.6406066",
"0.6406066",
"0.63835776",
"0.6294902",
"0.628729",
"0.6254861",
"0.6211929",
"0.61919874",
"0.61484534",
"0.61484534",
"0.612837",
"0.6106625",
"0.6044632",
"0.5983251",
"0.58894306",
"0.58854085",
"0.58262515",
"0.5806784",
"0.57877934",
"0.5785013... | 0.67974055 | 1 |
Evaluates the default value given, this is used by undump when determining the value of the default given for a field options. | def evaluate_default_value(val)
if val.respond_to?(:call)
val.call
elsif val.duplicable?
val.dup
else
val
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def default\n #----------\n \n # the default field value; retrieve from the options\n default = options[ :default ]\n \n # is there are default value?\n unless default.nil?\n self.value_from( default.respond_to?( :call ) ? default.call : default )\n ... | [
"0.7548134",
"0.7438849",
"0.7261479",
"0.7077573",
"0.7077573",
"0.70040536",
"0.6966905",
"0.6926767",
"0.68679047",
"0.685929",
"0.685929",
"0.6849813",
"0.6835046",
"0.6831999",
"0.68242115",
"0.6807466",
"0.6722489",
"0.67023146",
"0.6700978",
"0.66852415",
"0.6671793",
... | 0.6651085 | 25 |
There MUST be a better way to do this. I can't think of one or find one right now, though. | def number
apartment_information[:number]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def private; end",
"def offences_by; end",
"def probers; end",
"def anchored; end",
"def schubert; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def offences_by=(_arg0); end",
"def ignores; end",
"def same; end",
"def first; end",
"def first; end",
"... | [
"0.61374736",
"0.5427445",
"0.5385523",
"0.52986115",
"0.5140074",
"0.51025176",
"0.51025176",
"0.51025176",
"0.51025176",
"0.50544214",
"0.49443233",
"0.4932699",
"0.4914317",
"0.4914317",
"0.49085474",
"0.4891897",
"0.48771557",
"0.48542222",
"0.4853504",
"0.485021",
"0.482... | 0.0 | -1 |
GET /form_chagas GET /form_chagas.json | def index
@form_chagas = FormChaga.all
query = queryGrafico('form_chagas')
#query = "SELECT date_trunc('month', created_at) as label, COUNT(*) AS value FROM form_chagas where form_chagas.created_at>='2016-01-01 00:00:00' and form_chagas.created_at<='2016-12-12 24:00:00' GROUP BY 1 ORDER BY label ASC"
@reporte_mensual_chagas = Paciente.find_by_sql(query)
gon.query = query
gon.reporte_mensual_chagas = @reporte_mensual_chagas
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @cec_forms = CecForm.sorted\n\n\t\tgon.highlight_first_form_field = false\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @cec_forms }\n end\n end",
"def new\n @cancha = Cancha.new\n\n respond_to do |format|\n format.html # new.htm... | [
"0.626117",
"0.6186894",
"0.61347777",
"0.60712236",
"0.6053473",
"0.5938363",
"0.5898611",
"0.58902735",
"0.58687794",
"0.58003247",
"0.5780371",
"0.5768383",
"0.5749453",
"0.57263815",
"0.5722013",
"0.5714689",
"0.5712489",
"0.5704951",
"0.5698708",
"0.5669798",
"0.5651299"... | 0.0 | -1 |
GET /form_chagas/1 GET /form_chagas/1.json | def show
query = "SELECT date_trunc('month', created_at) as label, COUNT(*) AS value FROM form_chagas where form_chagas.created_at>='2016-01-01 00:00:00' and form_chagas.created_at<='2016-12-12 24:00:00' GROUP BY 1 ORDER BY label ASC"
@reporte_mensual_chagas = Paciente.find_by_sql(query)
gon.query = query
gon.reporte_mensual_chagas = @reporte_mensual_chagas
respond_to do |format|
format.html
format.pdf do
render :pdf => "file_name",
:layout => 'pdf.html.erb',
:page_size => 'Letter',
:footer => {:right => '[page] de [topage]', :font_size => 7}
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @cec_forms = CecForm.sorted\n\n\t\tgon.highlight_first_form_field = false\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @cec_forms }\n end\n end",
"def new\n @cancha = Cancha.new\n\n respond_to do |format|\n format.html # new.htm... | [
"0.6428477",
"0.6421049",
"0.63573587",
"0.62639976",
"0.62271154",
"0.6174908",
"0.6134266",
"0.60415673",
"0.60345316",
"0.60301083",
"0.60237414",
"0.59664047",
"0.59505904",
"0.5940204",
"0.5923266",
"0.58962893",
"0.58938915",
"0.58676165",
"0.586754",
"0.5851469",
"0.58... | 0.0 | -1 |
POST /form_chagas POST /form_chagas.json | def create
@form_chaga = FormChaga.new(form_chaga_params)
begin
@paciente = Paciente.find(params[:form_chaga][:paciente_id])
@paciente.form_laboratorio_id=5
@paciente.save
rescue Exception => e
end
respond_to do |format|
if @form_chaga.save
format.html { redirect_to @form_chaga, notice: 'Form chaga was successfully created.' }
format.json { render :show, status: :created, location: @form_chaga }
else
format.html { render :new }
format.json { render json: @form_chaga.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @chamada = Chamada.new(chamada_params)\n\n respond_to do |format|\n if @chamada.save\n format.html { redirect_to @chamada, notice: 'Chamada was successfully created.' }\n format.json { render :show, status: :created, location: @chamada }\n else\n format.html { rend... | [
"0.64495206",
"0.638197",
"0.63386226",
"0.6337148",
"0.63299555",
"0.6246719",
"0.6179173",
"0.6163199",
"0.61488104",
"0.6147938",
"0.6145054",
"0.60040134",
"0.5990754",
"0.59765357",
"0.5975659",
"0.59454536",
"0.5906431",
"0.5898849",
"0.58853865",
"0.5855858",
"0.584239... | 0.6151445 | 8 |
PATCH/PUT /form_chagas/1 PATCH/PUT /form_chagas/1.json | def update
respond_to do |format|
if @form_chaga.update(form_chaga_params)
format.html { redirect_to @form_chaga, notice: 'Form chaga was successfully updated.' }
format.json { render :show, status: :ok, location: @form_chaga }
else
format.html { render :edit }
format.json { render json: @form_chaga.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n respond_to do |format|\n if @cha.update(cha_params)\n format.html { redirect_to @cha, notice: 'Cha was successfully updated.' }\n format.json { render :show, status: :ok, location: @cha }\n else\n format.html { render :edit }\n format.json { render json: @cha.e... | [
"0.64447844",
"0.64345074",
"0.6392209",
"0.6361854",
"0.6345501",
"0.6345015",
"0.6308348",
"0.6275887",
"0.62743545",
"0.6265264",
"0.6256773",
"0.6251628",
"0.62385446",
"0.6202162",
"0.61993366",
"0.6194446",
"0.6185752",
"0.6185114",
"0.6158743",
"0.61376",
"0.61358446",... | 0.72253263 | 0 |
DELETE /form_chagas/1 DELETE /form_chagas/1.json | def destroy
@form_chaga.destroy
respond_to do |format|
format.html { redirect_to form_chagas_url, notice: 'Form chaga was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @form_anat_citologica.destroy\n respond_to do |format|\n format.html { redirect_to form_anat_citologicas_url, notice: 'Form anat citologica was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @formaenvio.destroy\n respond_to do |f... | [
"0.72321725",
"0.715083",
"0.71459174",
"0.71411735",
"0.7136192",
"0.7135548",
"0.71297646",
"0.71184915",
"0.71095407",
"0.70904636",
"0.70850503",
"0.7077559",
"0.7064305",
"0.7046542",
"0.7037713",
"0.7019463",
"0.7019215",
"0.70025975",
"0.6998123",
"0.6997066",
"0.69954... | 0.7778715 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_form_chaga
@form_chaga = FormChaga.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.6163754",
"0.6045816",
"0.5944853",
"0.59169096",
"0.58892167",
"0.58342934",
"0.5776148",
"0.57057375",
"0.57057375",
"0.56534296",
"0.56209534",
"0.54244673",
"0.54101455",
"0.54101455",
"0.54101455",
"0.53951085",
"0.5378493",
"0.53563684",
"0.53399915",
"0.5338049",
"0... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def form_chaga_params
params.require(:form_chaga).permit(:paciente_id, :hospital_id, :muestra, :diag_serologico, :conclucion_diag, :diag_confir, :conclu_pueb_confir, :observaciones, :firma)
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.69811666",
"0.6782836",
"0.6747644",
"0.6742015",
"0.6735273",
"0.6593917",
"0.65037674",
"0.6498627",
"0.6482372",
"0.64795715",
"0.64566946",
"0.6439213",
"0.6380714",
"0.6378147",
"0.63657266",
"0.63206697",
"0.6300169",
"0.62992156",
"0.6295538",
"0.62943023",
"0.62915... | 0.0 | -1 |
GET /userprofiles GET /userprofiles.json | def index
@userprofiles = Userprofile.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def my_profiles\n @user = User.find(params[:user_id])\n @profiles = @user.profiles\n end",
"def profile(user_id: '-')\n return get(\"#{API_URI}/#{PROFILE_API_VERSION}/user/#{user_id}/profile.json\")\n end",
"def users_profile\n @usersProfile = User.find(params[:id]).to_json(:include => :user_... | [
"0.7805175",
"0.7762994",
"0.73275286",
"0.7315062",
"0.7291779",
"0.72763824",
"0.72763824",
"0.72703826",
"0.71754813",
"0.71603054",
"0.7153486",
"0.71489125",
"0.7075892",
"0.7074032",
"0.7073381",
"0.70722497",
"0.70681167",
"0.6935921",
"0.69126666",
"0.68907",
"0.68822... | 0.686731 | 22 |
GET /userprofiles/1 GET /userprofiles/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def my_profiles\n @user = User.find(params[:user_id])\n @profiles = @user.profiles\n end",
"def profile(user_id: '-')\n return get(\"#{API_URI}/#{PROFILE_API_VERSION}/user/#{user_id}/profile.json\")\n end",
"def profile\n check_auth :profile\n \n response = connection.post do |req|\... | [
"0.7886912",
"0.7792722",
"0.7486224",
"0.74365914",
"0.73223877",
"0.7302369",
"0.7278582",
"0.72743905",
"0.72743905",
"0.7236477",
"0.7225976",
"0.71899366",
"0.7184203",
"0.71776855",
"0.71288216",
"0.70743614",
"0.7068073",
"0.7064718",
"0.70102715",
"0.6980143",
"0.6979... | 0.0 | -1 |
POST /userprofiles POST /userprofiles.json | def create
@userprofile = Userprofile.new(userprofile_params)
respond_to do |format|
if @userprofile.save
format.html { redirect_to @userprofile, notice: 'Userprofile was successfully created.' }
format.json { render :show, status: :created, location: @userprofile }
else
format.html { render :new }
format.json { render json: @userprofile.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n # Buidles a profile in association witht eh user\n @user = User.find(current_user.id)\n @profile = @user.build_profile(params[:user])\n @profile.update_attributes(params[:profile])\n\n respond_to do |format|\n if @profile.save\n format.json { render json: @profile, status: :... | [
"0.7182854",
"0.71481985",
"0.7004761",
"0.7004761",
"0.6944884",
"0.69388413",
"0.6935419",
"0.6933057",
"0.6924664",
"0.68717194",
"0.68387413",
"0.6836593",
"0.68174875",
"0.68137765",
"0.6810961",
"0.67675364",
"0.6749934",
"0.6748219",
"0.6748219",
"0.67420834",
"0.67386... | 0.7016276 | 2 |
PATCH/PUT /userprofiles/1 PATCH/PUT /userprofiles/1.json | def update
respond_to do |format|
if @userprofile.update(userprofile_params)
format.html { redirect_to @userprofile, notice: 'Userprofile was successfully updated.' }
format.json { render :show, status: :ok, location: @userprofile }
else
format.html { render :edit }
format.json { render json: @userprofile.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @profiles = current_user.profiles.find(params[:id])\n\n respond_to do |format|\n if @profiles.update(profile_params)\n format.html { redirect_to profiles_path, notice: 'Profile was successfully updated.' }\n format.json { render :show, status: :ok, location: @profiles }\n ... | [
"0.73774505",
"0.7226759",
"0.714953",
"0.7144511",
"0.71225923",
"0.71225923",
"0.7086452",
"0.7066469",
"0.705258",
"0.7045005",
"0.7043534",
"0.702443",
"0.7017899",
"0.70128065",
"0.7011128",
"0.6987563",
"0.69439864",
"0.69259626",
"0.69259626",
"0.6905141",
"0.69015515"... | 0.6835996 | 29 |
DELETE /userprofiles/1 DELETE /userprofiles/1.json | def destroy
@userprofile.destroy
respond_to do |format|
format.html { redirect_to userprofiles_url, notice: 'Userprofile was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @user_profile = UserProfile.find(params[:id])\n @user_profile.destroy\n\n respond_to do |format|\n format.html { redirect_to user_profiles_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user_profile = UserProfile.find(params[:id])\n @user_profile... | [
"0.7747554",
"0.7747554",
"0.76835763",
"0.767701",
"0.75330746",
"0.7497255",
"0.74793273",
"0.74745905",
"0.74514097",
"0.74265933",
"0.73694336",
"0.7367411",
"0.73479396",
"0.7347816",
"0.7347816",
"0.73348236",
"0.7334787",
"0.73250455",
"0.73250455",
"0.73250455",
"0.73... | 0.74363834 | 9 |
Use callbacks to share common setup or constraints between actions. | def set_userprofile
@userprofile = Userprofile.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 userprofile_params
params.require(:userprofile).permit(:user_id, :smtp1, :port1, :email_acc1, :email_pass1, :smtp2, :port2, :email_acc2, :email_pass2, :smtp3, :port3, :email_acc3, :email_pass3)
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.6980629",
"0.67819995",
"0.67467666",
"0.67419875",
"0.67347664",
"0.65928614",
"0.6504013",
"0.6498014",
"0.64819515",
"0.64797956",
"0.64562726",
"0.64400834",
"0.6380117",
"0.6377456",
"0.63656694",
"0.6320543",
"0.63002014",
"0.62997127",
"0.629425",
"0.6293866",
"0.62... | 0.0 | -1 |
Override require_no_authentication method defined at DeviseController (parent of Devise::InvitationsController) The following filter gets executed any time GET /users/invitation/accept?invitation_token=valid_token is requested. It replaces the default error message from devise (e.g. You are already signed in.) if the user is signed in already while trying to access to that URL | def require_no_authentication
super
return unless flash[:alert].present?
flash[:alert] = nil
flash[:notice] = _('You are already signed in as another user. Please log out to activate your invitation.')
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def require_invite\n logger.debug \"ApplicationController::require_invite\"\n if require_no_user\n unless Invitation.verify?(params[:invitation_token])\n #store_location\n flash[:notice] = \"You need a valid invite code to access this page\"\n redirect_to invitation_enter_url\n ... | [
"0.6857858",
"0.6741364",
"0.6486414",
"0.6439612",
"0.6388745",
"0.6317138",
"0.6194467",
"0.61588705",
"0.6155364",
"0.6124863",
"0.60908425",
"0.60740054",
"0.60655254",
"0.6017625",
"0.60072017",
"0.5997055",
"0.59887284",
"0.595467",
"0.59490615",
"0.58923924",
"0.588873... | 0.67746085 | 1 |
Handle the user's Org selection rubocop:disable Metrics/AbcSize | def handle_org
attrs = update_resource_params
return unless attrs[:org_id].present?
# See if the user selected a new Org via the Org Lookup and
# convert it into an Org
lookup = org_from_params(params_in: attrs)
return nil unless lookup.present?
# If this is a new Org we need to save it first before attaching
# it to the user
if lookup.new_record?
lookup.save
identifiers_from_params(params_in: attrs).each do |identifier|
next unless identifier.value.present?
identifier.identifiable = lookup
identifier.save
end
lookup.reload
end
resource.update(org_id: lookup.id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def select_organization(*organizations)\n organization_select.click\n wait_for_core_options\n organizations.each do |core|\n core_options(text: /\\A#{core}\\Z/).first.click\n end\n page.find(\"body\").click # seems like Capybara page is available in this cont... | [
"0.6238251",
"0.6185785",
"0.60945064",
"0.588343",
"0.5821956",
"0.5796873",
"0.5707882",
"0.5694134",
"0.5685166",
"0.56499535",
"0.56286836",
"0.5625503",
"0.5586537",
"0.5581117",
"0.5576136",
"0.5565171",
"0.55445534",
"0.55363417",
"0.55124545",
"0.5465483",
"0.5432132"... | 0.60575604 | 3 |
Create an new S3 instance The access_key and secret_key are both required to do any meaningful work. If you want to get these keys from environment variables, you can do that in your code as follows: s3 = Awsum::S3.new(ENV['AWS_ACCESS_KEY_ID'], ENV['AWS_SECRET_ACCESS_KEY']) | def initialize(access_key = nil, secret_key = nil)
@access_key = access_key
@secret_key = secret_key
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize aws_access_key_id, aws_secret_access_key\n require 'right_aws'\n @s3 = RightAws::S3.new(aws_access_key_id, aws_secret_access_key)\n end",
"def connect_to_s3()\n\n Aws::S3::Client.new(\n access_key_id: ENV['S3_KEY'],\n secret_access_key: ENV['S3_SECRET'],\n region: ENV['AWS_R... | [
"0.78877246",
"0.7842519",
"0.7584797",
"0.7535952",
"0.75287974",
"0.7123127",
"0.70724946",
"0.706623",
"0.6996587",
"0.6992867",
"0.6966149",
"0.69574535",
"0.6942476",
"0.6929578",
"0.6925038",
"0.6895919",
"0.6875357",
"0.68664634",
"0.6858524",
"0.676855",
"0.6749766",
... | 0.0 | -1 |
List all the Bucket(s) | def buckets
response = send_s3_request
parser = Awsum::S3::BucketParser.new(self)
parser.parse(response.body)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list\n ::Taxi::S3.instance.list_buckets\n end",
"def list_buckets\n puts '> AWS Buckets'.yellow\n response = s3_client.list_buckets\n buckets = response.buckets.map do |bucket|\n \"#{bucket.name.yellow} - created: #{bucket.creation_date.to_s.greenish}\"\n end\n buc... | [
"0.8712768",
"0.85100335",
"0.8087822",
"0.7934444",
"0.7880567",
"0.78144586",
"0.78038144",
"0.77178234",
"0.7712402",
"0.76750463",
"0.7613469",
"0.7509081",
"0.75008094",
"0.7473409",
"0.74652857",
"0.7460813",
"0.7394623",
"0.7375749",
"0.73646706",
"0.7331684",
"0.73135... | 0.7239604 | 23 |
Create a new Bucket ===Parameters bucket_name The name of the new bucket location (optional) Can be :default, :us or :eu | def create_bucket(bucket_name, location = :default)
raise ArgumentError.new('Bucket name cannot be in an ip address style') if bucket_name =~ /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/
raise ArgumentError.new('Bucket name can only have lowercase letters, numbers, periods (.), underscores (_) and dashes (-)') unless bucket_name =~ /^[\w\d][-a-z\d._]+[a-z\d._]$/
raise ArgumentError.new('Bucket name cannot contain a dash (-) next to a period (.)') if bucket_name =~ /\.-|-\./
raise ArgumentError.new('Bucket name must be between 3 and 63 characters') if bucket_name.size < 3 || bucket_name.size > 63
data = nil
if location == :eu
data = '<CreateBucketConfiguration><LocationConstraint>EU</LocationConstraint></CreateBucketConfiguration>'
end
response = send_s3_request('PUT', :bucket => bucket_name, :data => data)
response.is_a?(Net::HTTPSuccess)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_bucket(bucket_name)\n send_request(PUT, bucket_name)\n end",
"def create_bucket bucket_name\n resp = connection.insert_bucket bucket_name\n if resp.success?\n Bucket.from_gapi resp.data, connection\n else\n fail ApiError.from_response(re... | [
"0.8937025",
"0.87299305",
"0.8451238",
"0.8442322",
"0.8298901",
"0.82935065",
"0.81284106",
"0.807588",
"0.7898113",
"0.7711056",
"0.74231577",
"0.72988963",
"0.7277967",
"0.7270574",
"0.7203891",
"0.713467",
"0.6987427",
"0.6929679",
"0.69086486",
"0.68817437",
"0.68758714... | 0.83407724 | 4 |
List the Key(s) of a Bucket ===Parameters bucket_name The name of the bucket to search for keys ====Options :prefix Limits the response to keys which begin with the indicated prefix. You can use prefixes to separate a bucket into different sets of keys in a way similar to how a file system uses folders. :marker Indicates where in the bucket to begin listing. The list will only include keys that occur lexicographically after marker. This is convenient for pagination: To get the next page of results use the last key of the current page as the marker. :max_keys The maximum number of keys you'd like to see in the response body. The server might return fewer than this many keys, but will not return more. :delimeter Causes keys that contain the same string between the prefix and the first occurrence of the delimiter to be rolled up into a single result element in the CommonPrefixes collection. These rolledup keys are not returned elsewhere in the response. | def keys(bucket_name, options = {})
paramters = {}
paramters['prefix'] = options[:prefix] if options[:prefix]
paramters['marker'] = options[:marker] if options[:marker]
paramters['max_keys'] = options[:max_keys] if options[:max_keys]
paramters['prefix'] = options[:prefix] if options[:prefix]
response = send_s3_request('GET', :bucket => bucket_name, :paramters => paramters)
parser = Awsum::S3::ObjectParser.new(self)
parser.parse(response.body)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list_keys(bucket, options = {})\n keys = bucket_data(bucket, options[:type])[:keys].keys\n\n if block_given?\n yield keys unless keys.empty?\n true\n else\n keys\n end\n end",
"def list_files_with_prefix bucket_name:, prefix:, delimiter: nil\n # Li... | [
"0.72898203",
"0.68283516",
"0.681839",
"0.6695523",
"0.655856",
"0.6555089",
"0.6543084",
"0.6485466",
"0.648331",
"0.6446725",
"0.62887985",
"0.62787056",
"0.6259674",
"0.6238176",
"0.6180802",
"0.61576015",
"0.61230946",
"0.6073384",
"0.603646",
"0.6004133",
"0.5988952",
... | 0.8092025 | 0 |
Create a new Object in the specified Bucket ===Parameters bucket_name The name of the Bucket in which to store the Key key The name/path of the Key to store data The data to be stored in this Object headers Standard HTTP headers to be sent along meta_headers Meta headers to be stored along with the key acl A canned access policy, can be one of :private, :public_read, :public_read_write or :authenticated_read | def create_object(bucket_name, key, data, headers = {}, meta_headers = {}, acl = :private)
headers = headers.dup
meta_headers.each do |k,v|
headers[k =~ /^x-amz-meta-/i ? k : "x-amz-meta-#{k}"] = v
end
headers['x-amz-acl'] = acl.to_s.gsub(/_/, '-')
response = send_s3_request('PUT', :bucket => bucket_name, :key => key, :headers => headers, :data => data)
response.is_a?(Net::HTTPSuccess)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_bucket(bucket_name)\n send_request(PUT, bucket_name)\n end",
"def create(bucket, object)\n c = @context\n url = \"#{c.serverUrl}/apps/#{c.appId}#{bucket.path}/objects\"\n\n client = c.getNewClient\n client.setUrl(url)\n client.setMethod(KiiH... | [
"0.78636205",
"0.76201135",
"0.728201",
"0.7224593",
"0.7214517",
"0.7208169",
"0.7137039",
"0.71335924",
"0.7053779",
"0.70210576",
"0.6852474",
"0.68506104",
"0.67435783",
"0.6718693",
"0.66069454",
"0.6576966",
"0.6548271",
"0.6532869",
"0.64392364",
"0.6385892",
"0.635366... | 0.8418326 | 0 |
Retrieve the headers for this Object All header methods map directly to the Net::HTTPHeader module | def object_headers(bucket_name, key)
response = send_s3_request('HEAD', :bucket => bucket_name, :key => key)
Headers.new(response)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getHeaders\n @headers\n end",
"def headers\n self.class.const_get(:HEADERS) rescue []\n end",
"def get_headers\n @headers = headers\n @headers\n end",
"def get_headers\n request_object.headers\n end",
"def headers\n @headers ||= HeaderHash.new(@http_response.to_h... | [
"0.83277404",
"0.81391084",
"0.8107993",
"0.8040039",
"0.79882073",
"0.7949995",
"0.7936194",
"0.7931577",
"0.7909972",
"0.7814138",
"0.7794562",
"0.7639661",
"0.7639598",
"0.76166815",
"0.7611665",
"0.76091534",
"0.759013",
"0.7586635",
"0.75730646",
"0.7559128",
"0.7537326"... | 0.0 | -1 |
Retrieve the data stored for the specified Object You can get the data as a single call or add a block to retrieve the data in chunks ==Examples data = s3.object_data('testbucket', 'key') or s3.object_data('testbucket', 'key') do |chunk| handle chunk puts chunk end | def object_data(bucket_name, key, &block)
send_s3_request('GET', :bucket => bucket_name, :key => key) do |response|
if block_given?
response.read_body &block
return true
else
return response.body
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def data(&block)\n @s3.object_data @bucket, @key, &block\n end",
"def data_stream(size=-1,offset=0,headers = {},&block)\n if size.to_i > 0\n range = sprintf(\"bytes=%d-%d\", offset.to_i, (offset.to_i + size.to_i) - 1)\n headers['Range'] = range\n end\n self.container.conn... | [
"0.77960455",
"0.6733501",
"0.6478907",
"0.63294566",
"0.6290589",
"0.6288801",
"0.6188374",
"0.6177645",
"0.61723614",
"0.6113247",
"0.6058998",
"0.6041152",
"0.6011693",
"0.5980759",
"0.5967943",
"0.5943739",
"0.5930573",
"0.5928796",
"0.5928257",
"0.59123087",
"0.58987314"... | 0.76248705 | 1 |
Deletes an Object from a Bucket | def delete_object(bucket_name, key)
response = send_s3_request('DELETE', :bucket => bucket_name, :key => key)
response.is_a?(Net::HTTPSuccess)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bucket_delete_object(key)\n http.delete(\"/#{key}\", bucket: bucket, key: key)\n end",
"def del(bucket) # s3://BUCKET/OBJECT\n send_command \"del\", bucket\n end",
"def delete_object(bucket, key, options = {})\n bucket_data(bucket, options[:type])[:keys].delete(key)\n ... | [
"0.8463566",
"0.82395536",
"0.7856064",
"0.7784297",
"0.7738546",
"0.77090424",
"0.76150674",
"0.75473857",
"0.7538229",
"0.74130744",
"0.7389716",
"0.7364472",
"0.73002744",
"0.7261673",
"0.7261165",
"0.7257182",
"0.7253513",
"0.7237064",
"0.7200461",
"0.7152739",
"0.7095440... | 0.80694455 | 2 |
Copy the contents of an Object to another key and/or bucket ===Parameters source_bucket_name The name of the Bucket from which to copy source_key The name of the Key from which to copy destination_bucket_name The name of the Bucket to which to copy (Can be nil if copying within the same bucket, or updating header data of existing Key) destination_key The name of the Key to which to copy (Can be nil if copying to a new bucket with same key, or updating header data of existing Key) headers If not nil, the headers are replaced with this information meta_headers If not nil, the meta headers are replaced with this information TODO: Need to handle copyif... headers | def copy_object(source_bucket_name, source_key, destination_bucket_name = nil, destination_key= nil, headers = nil, meta_headers = nil)
raise ArgumentError.new('You must include one of destination_bucket_name, destination_key or headers to be replaced') if destination_bucket_name.nil? && destination_key.nil? && headers.nil? && meta_headers.nil?
headers = {
'x-amz-copy-source' => "/#{source_bucket_name}/#{source_key}",
'x-amz-metadata-directive' => (((destination_bucket_name.nil? && destination_key.nil?) || !(headers.nil? || meta_headers.nil?)) ? 'REPLACE' : 'COPY')
}.merge(headers||{})
meta_headers.each do |k,v|
headers[k =~ /^x-amz-meta-/i ? k : "x-amz-meta-#{k}"] = v
end unless meta_headers.nil?
destination_bucket_name ||= source_bucket_name
destination_key ||= source_key
response = send_s3_request('PUT', :bucket => destination_bucket_name, :key => destination_key, :headers => headers, :data => nil)
if response.is_a?(Net::HTTPSuccess)
#Check for delayed error (See http://docs.amazonwebservices.com/AmazonS3/2006-03-01/RESTObjectCOPY.html#RESTObjectCOPY_Response)
response_body = response.body
if response_body =~ /<Error>/i
raise Awsum::Error.new(response)
else
true
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def copy_object(source_bucket_name, source_key, target_bucket_name, target_key, options={})\n headers = options\n headers[BCE_COPY_SOURCE_IF_MATCH] = headers['etag'] unless headers['etag'].nil?\n if headers['user-metadata'].nil?\n headers[BCE_COPY_MET... | [
"0.83699745",
"0.8026953",
"0.7523179",
"0.71672666",
"0.70134777",
"0.6993064",
"0.6881186",
"0.67521524",
"0.66863805",
"0.63147",
"0.62708604",
"0.6214237",
"0.61215186",
"0.6005749",
"0.5958162",
"0.59501314",
"0.58393",
"0.58347774",
"0.5800529",
"0.5796169",
"0.5741419"... | 0.8781833 | 0 |
private The host to make all requests against | def host
@host ||= 's3.amazonaws.com'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def host; end",
"def host; end",
"def host; end",
"def host; end",
"def host; end",
"def host; end",
"def host; end",
"def host; end",
"def host; end",
"def host\n request.host\n end",
"def host\n @host\n end",
"def host\n @request['Host']\n end",
"def host\n @hos... | [
"0.7571455",
"0.7571455",
"0.7571455",
"0.7571455",
"0.7571455",
"0.7571455",
"0.7571455",
"0.7571455",
"0.7571455",
"0.73801476",
"0.7297621",
"0.7272755",
"0.7243173",
"0.7243173",
"0.72320217",
"0.7226375",
"0.72012436",
"0.71298456",
"0.7059755",
"0.7020252",
"0.7019866",... | 0.0 | -1 |
Generates random 32bytes long key that will encrypt/decrypt attributes. Each db record gets it's own key. This key is then encrypted with KMS and stored inside `encrypted_key` column. Key must be 32bytes long since aes256gcm requires key that length. | def generate_random_key
SecureRandom.random_bytes(32)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_key\n self.key = SecureRandom.hex(KEY_LENGTH / 2)\n end",
"def generate_key\n self.key ||= SecureRandom.urlsafe_base64 32\n end",
"def generate_key\n SecureRandom.hex(32)\nend",
"def generate_key(seed)\n key = \"\"\n 1.upto(KEY_LENGTH) do\n key += (((seed = (214013 * seed + 2531011... | [
"0.7718343",
"0.7448034",
"0.7347463",
"0.7244148",
"0.7241014",
"0.71490526",
"0.71344715",
"0.7121063",
"0.7114418",
"0.7093697",
"0.7082931",
"0.7059032",
"0.7020104",
"0.6965791",
"0.6913615",
"0.6909428",
"0.6871716",
"0.68511254",
"0.67501",
"0.67501",
"0.6671166",
"0... | 0.7724878 | 0 |
Register for SF client updates via push topic. Add/update/remove users in Zoom as needed | def start_sync_job
EM.run do
@sf.client.subscribe PUBSUB_TOPIC do |push_message|
log_salesforce_push_update(push_message)
sf_user = SalesforceSync.sf_message_user(push_message)
if add_update_event?(push_message) && add_user_to_zoom?(sf_user)
next_call = @zoom_client.next_intro_call_occurrence
if next_call&.dig('start_time').present?
@zoom_client.add_intro_meeting_registrant(sf_user, next_call['occurrence_id'])
else
LOG.error('Could not find next intro call instance or instance..') unless next_call&.dig('start_time').present?
end
elsif delete_event?(push_message) && sf_user_in_zoom?(sf_user)
LOG.info("Delete event received. Not removing: #{sf_user.try(:attrs).try(:as_json)}")
# @zoom_client.remove_user!(zoom_user_from_sf_user(sf_user)['id'])
end
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def subscribed\n super\n increase_current_users\n stream_from channel\n end",
"def publish_to_users\n data = { users: users }.merge!(payload)\n client.post('publishes/users', data)\n end",
"def subscribe(user)\n @clients[user.signature] = user\n end",
"def websocket... | [
"0.624221",
"0.60880697",
"0.5760904",
"0.5734595",
"0.5722255",
"0.56803423",
"0.5626801",
"0.55592847",
"0.5533481",
"0.5526364",
"0.5498959",
"0.5497534",
"0.54769593",
"0.5473681",
"0.5471396",
"0.54706436",
"0.54428136",
"0.54306096",
"0.5421669",
"0.5416745",
"0.5415830... | 0.601772 | 2 |
cache all zoom users, use this rather than requerying. Maybe only need email address.. for now get everything TODO: clear cache on update of zoom TODO: ensure query honors zoom API query limit | def get_zoom_registrants
@zoom_registrants = @zoom_client.intro_call_registrants
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @zoom_users = ZoomUser.all\n end",
"def users\n result = Rails.cache.read([:ibiza, id, :users])\n get_users_only_once if result.nil?\n result\n end",
"def cache\n @cache[:user] ||= get 'user'\n end",
"def cache_users(stuff)\r\n query_result = stuff.slm.find_all(:user)\r... | [
"0.65684646",
"0.61547554",
"0.59180653",
"0.5900354",
"0.58579564",
"0.5699521",
"0.56285423",
"0.5579922",
"0.55637014",
"0.5551042",
"0.54845446",
"0.5452101",
"0.5419574",
"0.5419427",
"0.54101366",
"0.5374042",
"0.5371934",
"0.5350786",
"0.5341776",
"0.5335182",
"0.53176... | 0.59361833 | 2 |
SF user has all necessary fields and should be added based on intro call fields | def valid_user_for_zoom?(sf_user)
[sf_user.try(:FirstName), sf_user.try(:LastName)].all?(&:present?) &&
SalesforceSync.user_has_email_address?(sf_user) &&
@sf.valid_intro_call_date?(sf_user)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def assign_fields(user)\n self.screen_name = user.screen_name\n self.name = user.name\n description_urls = user.attrs[:entities].try(:fetch, :description).try(:fetch, :urls, nil)\n self.description = description_urls ? expand_urls(user.description, description_urls) : user.description\n self.locatio... | [
"0.6904705",
"0.6847584",
"0.6764674",
"0.65778404",
"0.65139484",
"0.6512401",
"0.6509851",
"0.6491224",
"0.6486567",
"0.6381705",
"0.6381509",
"0.63240594",
"0.63220245",
"0.6303453",
"0.62717915",
"0.6256959",
"0.6240817",
"0.62349296",
"0.6199524",
"0.6192895",
"0.6168538... | 0.0 | -1 |
expects a REXML::Text of the item | def initialize elem
@item_elem = elem
parse_item
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_raw_text(item); end",
"def update_raw_text(item); end",
"def special_list_item_line(text)\n end",
"def line_item_xml_data(line_item, xml)\n\n end",
"def update_raw_text(item)\n raw_text = +''\n\n append_text = lambda do |child|\n if child.type == :text\n raw... | [
"0.6778304",
"0.6778304",
"0.6408137",
"0.627398",
"0.622546",
"0.599327",
"0.5960705",
"0.5920691",
"0.5864736",
"0.5794316",
"0.5768942",
"0.57580984",
"0.5700972",
"0.5700972",
"0.5691101",
"0.56694144",
"0.5654428",
"0.5626477",
"0.5589593",
"0.55883276",
"0.55176705",
... | 0.0 | -1 |
Stick a string on the end of our input | def append(s)
if @input.nil?
@input = ""
end
@input += s + " "
@output.text = @input
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def append(s)\n if @input.nil?\n @input = \"\"\n end\n @input += s\n @output.text = @input\n end",
"def append(s)\n if @input.nil?\n @input = \"\"\n end\n @input += s\n @output.text = @input\n end",
"def append(s)\n if @input.nil?\n @input = \"\"\n end\n @input... | [
"0.6554718",
"0.6554718",
"0.6554718",
"0.6532805",
"0.64600044",
"0.6244153",
"0.6174057",
"0.6174057",
"0.5906884",
"0.5902277",
"0.5869753",
"0.58687586",
"0.5815713",
"0.57963574",
"0.57757413",
"0.5771104",
"0.5769233",
"0.5727515",
"0.57142437",
"0.5706634",
"0.5703872"... | 0.67379326 | 0 |
Evaluate the input we've got so far | def eval_expression
# Shoes.show_log
@numbers = @input.split(" ")
@first_number = @numbers.shift.to_f
@numbers.unshift(@first_number)
@last_number = @numbers.pop.to_f
@numbers.push(@last_number.to_s)
@input = @numbers.join
@input = eval(@input).to_s
@output.text = @input
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def evaluate\n\n end",
"def evaluate_input\n puts \"\\tInitial Stack and Input values:\\n\\n\"\n puts \"\\tStack: #{stack.inspect}\"\n puts \"\\tInput: #{input.inspect}\"\n puts \"\\t#{'_' * 80}\\n\\n\"\n _evaluate_input(@stack, @input)\n end",
"def evaluation(input)\n operand_output ... | [
"0.74685985",
"0.7227125",
"0.71833855",
"0.6949591",
"0.6901725",
"0.684737",
"0.67054963",
"0.65107614",
"0.6508407",
"0.6482467",
"0.6482467",
"0.6468002",
"0.6439383",
"0.6365151",
"0.6299676",
"0.62298125",
"0.622926",
"0.612248",
"0.6064463",
"0.6047056",
"0.60366416",
... | 0.5402492 | 96 |
searches for start node but not for the goal node the robot does not know where the goal node is but we need to find out where to start at | def parse_maze
x = 0
y = 0
z = 0 # will be used as a node number
@table_reversed.each do |row|
row.each do |item|
@start_node = z if item == "S"
# create a simple array with all values
@table_merged << item
@table_convert << [item, [x, y]]
y += 1
z += 1
end
x += 1
y = 0
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def path_finder(start_node=START_NODE, goal_node=GOAL_NODE)\n\t\n\t# INITIALIZE\n\tvalid = valid_nodes # largest set\n\treachable = [start_node] # nodes we can reach from current node\n\texplored = [] # nodes we've already considered\n\t# nodes reachable, valid, and not explored\n\topen_nodes = valid.select{|node|... | [
"0.6442505",
"0.6393843",
"0.6363798",
"0.6298817",
"0.6267682",
"0.6231205",
"0.6203254",
"0.613403",
"0.6105458",
"0.60912746",
"0.60246754",
"0.60078305",
"0.59187883",
"0.5905322",
"0.5884032",
"0.5858065",
"0.5852988",
"0.5840743",
"0.5840222",
"0.58222234",
"0.57803583"... | 0.0 | -1 |
parse_maze set table size values | def set_table_size
@table_x = @table_reversed[0].size
@table_y = @table_reversed.size
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_maze\n x = 0\n y = 0\n z = 0 # will be used as a node number\n @table_reversed.each do |row|\n row.each do |item|\n @start_node = z if item == \"S\"\n\n # create a simple array with all values\n @table_merged << item\n @table_convert << [item, [x, y]]\n ... | [
"0.70714504",
"0.6258243",
"0.6191562",
"0.60860246",
"0.5848129",
"0.57708246",
"0.5726122",
"0.56765103",
"0.5669936",
"0.55221635",
"0.54627496",
"0.54481405",
"0.5407897",
"0.5406602",
"0.5402932",
"0.5386347",
"0.537646",
"0.5370057",
"0.53364146",
"0.53364146",
"0.53096... | 0.69698673 | 1 |
append an incremental number for each node, for example [0,0] becomes 0, [0,1] becomes 1, [0,2] becomes 2 etc. | def create_nodes
@nodes = [*0...@table.flatten.length]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def increment(node)\n change_by node, 1\n end",
"def make_int_list(args)\n head = Node.new args[0]\n args[1..args.length - 1].each { |arg| head.append arg }\n head\nend",
"def gen_new_node_num()\n gen_uniq_rand($node_range, $nodes)\nend",
"def appendAndDict(some_list, some_dict, i, node)\n some_... | [
"0.64801973",
"0.6140908",
"0.6132658",
"0.60980695",
"0.60738045",
"0.5997194",
"0.5983144",
"0.59774816",
"0.5971081",
"0.59404117",
"0.59223026",
"0.58106554",
"0.5771366",
"0.574072",
"0.5724441",
"0.5676644",
"0.56617177",
"0.56554013",
"0.56544125",
"0.56437284",
"0.563... | 0.62268347 | 1 |
create the unvisited set of nodes but remove walls | def create_unvisited_set
@unvisited_set = @nodes.map { |r| r if @table_merged[r] != "X" }
@unvisited_set.delete(nil)
@unvisited_set
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_nodes!(tg,tiles)\n result = [Array.new,Array.new]\n\n tg[0].each_index {|n| # remove nodes\n tiles.each do |i|\n if i == tg[0][n][0]\n result[0].push(tg[0][n])\n tg[0][n] = nil\n break\n end \n end\n }\n tg[1].each_index {|e| # remove edges\n tile... | [
"0.6839447",
"0.67924005",
"0.6560947",
"0.65259767",
"0.6310719",
"0.6298605",
"0.6275308",
"0.6206775",
"0.61641365",
"0.6122182",
"0.61179",
"0.60603136",
"0.60491",
"0.6039304",
"0.5990707",
"0.5964948",
"0.5922937",
"0.5921194",
"0.58834654",
"0.58827496",
"0.5882184",
... | 0.7486514 | 0 |
create nodes check neighbours for edges | def check_edges(current_node)
# set values for neighbours
neighbours = []
left_node = current_node - @step
top_node = current_node + @table_x
right_node = current_node + @step
bottom_node = current_node - @table_x
# check If neighbours are not in the edges
if left_node > 0 && current_node % @table_x != 0 && @table_merged[left_node] != "X"
neighbours << left_node
end
if top_node < (@table_x * @table_y) && @table_merged[top_node] != "X"
neighbours << top_node
end
if bottom_node - @table_x >= 0 && @table_merged[bottom_node] != "X"
neighbours << bottom_node
end
if (current_node + @step) % @table_x != 0 && @table_merged[right_node] != "X"
neighbours << right_node
end
return neighbours
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_neighbours(current_node)\n moves = [[ 1, 2], [-1, 2], [ 1,-2], [-1,-2], [ 2, 1], [-2, 1], [ 2,-1], [-2,-1]]\n moves.each do |move|\n neigbour_helper(current_node, move[0], move[1])\n end\n end",
"def neighbors\n NodeWrapper.new @links.map(&:to)\n end",
"def add_edges(node, neigh... | [
"0.68463695",
"0.67882407",
"0.67748535",
"0.6762023",
"0.6664881",
"0.6569908",
"0.6468015",
"0.64646274",
"0.6426611",
"0.64056075",
"0.6349839",
"0.634061",
"0.6318069",
"0.63159",
"0.6294339",
"0.6287346",
"0.62802523",
"0.6252495",
"0.62500477",
"0.62458503",
"0.6230763"... | 0.64189535 | 9 |
check_edges does what it says ! | def solve_dijkstra
unvisited_set = @unvisited_set.dup
# create a queue for nodes to check
@queue = []
current_node = @start_node
@queue << current_node
# Stop If there are no unvisited nodes or the queue is empty
while unvisited_set.size > 0 && @queue.size > 0 do
# set the current node as visited and remove it from the unvisited set
current_node = @queue.shift
# remove visited node from the list of unvisited nodes
unvisited_set.delete(current_node)
# find the current node's neighbours and add them to the queue
rolling_node = @node_list.find { |hash| hash[:id] == current_node }
rolling_node[:neighs].each do |p|
# only add them if they are unvisited and they are not in the queue
if unvisited_set.index(p) && !@queue.include?(p)
@queue << p
# set the previous node as the current for its neighbours
change_node = @node_list.find { |hash| hash[:id] == p }
change_node[:prev] = current_node
# increase the distance of each node visited
change_node[:dist] = rolling_node[:dist] + @step
end
end
if current_node == @goal_node
find_shortest_path(rolling_node)
break
end
end
return @shortest_path_coords
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_edges(to_check)\n\n eps = 0.1\n\n border_size = @parameters[:im_border_size].to_f\n z_size = @parameters[:half_z_size].to_f\n\n range_x = border_size...(to_check.getParent.getDimensionSizes[:x] - border_size)\n range_y = border_size...(to_check.getParent.getDimensionSizes[:y] - b... | [
"0.73300886",
"0.69523877",
"0.67298007",
"0.6564754",
"0.648054",
"0.64716077",
"0.6455287",
"0.6376978",
"0.63752204",
"0.62458074",
"0.6241914",
"0.6221097",
"0.60859853",
"0.6065738",
"0.6030233",
"0.6024786",
"0.59957767",
"0.5985131",
"0.5957746",
"0.5922252",
"0.588000... | 0.0 | -1 |
solve_dijkstra Retrieves the shortest path by backtracking | def find_shortest_path(rolling_node)
@backtrack = []
@backtrack << @goal_node
# iterate until we arrive at the start node
while rolling_node[:prev] != nil do
temp_node = @node_list.find { |hash| hash[:id] == rolling_node[:prev] }
@backtrack << temp_node[:id]
rolling_node = temp_node
end
# create a table with the 1d and the 2d array node values
@shortest_path = []
@backtrack.each do |p|
@shortest_path << [p, @table_convert[p]]
@shortest_path_coords << @table_convert[p][1]
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def solve_dijkstra\n\n unvisited_set = @unvisited_set.dup\n\n # create a queue for nodes to check\n @queue = []\n current_node = @start_node\n @queue << current_node\n\n # Stop If there are no unvisited nodes or the queue is empty\n while unvisited_set.size > 0 && @queue.size > 0 do\n\n #... | [
"0.8495452",
"0.7880269",
"0.7482047",
"0.7469278",
"0.72764975",
"0.7246549",
"0.72157246",
"0.7140569",
"0.71323454",
"0.7121794",
"0.7104955",
"0.6975516",
"0.69252557",
"0.6921603",
"0.68909085",
"0.68717676",
"0.6868459",
"0.6860975",
"0.68273693",
"0.68261963",
"0.68218... | 0.56842315 | 96 |
rubocop:enable Metrics/MethodLength rubocop:enable Metrics/AbcSize | def mail_root
match_data = email.match(/(..*)*@/)
match_data[1]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def private; end",
"def probers; end",
"def implementation; end",
"def implementation; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def schubert; end",
"def refutal()\n end",
"def offences_by; end",
"def used?; end",
"def custom; end",
"def custom;... | [
"0.7737182",
"0.6451236",
"0.63296616",
"0.63296616",
"0.6260099",
"0.6260099",
"0.6260099",
"0.6260099",
"0.62556946",
"0.62258446",
"0.59956306",
"0.5976355",
"0.59622383",
"0.59622383",
"0.5946749",
"0.5938034",
"0.590236",
"0.590236",
"0.58727545",
"0.5845048",
"0.5827449... | 0.0 | -1 |
For absolute magnitudes, + method always returns a result framed in corresponding relative quantity. | def + m2
return magnitude amount + m2.amount if m2.quantity == quantity.relative
return quantity.relative.magnitude( amount + m2.amount ) if
quantity == m2.quantity
return self if m2.equal? SY::ZERO
# o1, o2 = m2.coerce( self )
# return o1 + o2
raise SY::QuantityError, "Unable to perform #{quantity} + #{m2.quantity}!"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add m2\n return magnitude( amount + m2.amount ) if quantity == m2.quantity\n return self if m2.equal? SY::ZERO\n # o1, o2 = m2.coerce( self )\n # return o1.add o2\n raise SY::QuantityError, \"Unable to perform #add with #{m2.quantity}!\"\n end",
"def relative_plus\n api_get(API_MAP[:re... | [
"0.6647114",
"0.6626407",
"0.6492695",
"0.64439255",
"0.6263766",
"0.61258006",
"0.6109041",
"0.6038073",
"0.6014096",
"0.600819",
"0.59944516",
"0.59935474",
"0.5987474",
"0.5981178",
"0.59627736",
"0.5958889",
"0.59336156",
"0.59188783",
"0.59052086",
"0.5862954",
"0.584130... | 0.7521455 | 0 |
Addition of absolute magnitudes that returns a result framed as absolute quantity. | def add m2
return magnitude( amount + m2.amount ) if quantity == m2.quantity
return self if m2.equal? SY::ZERO
# o1, o2 = m2.coerce( self )
# return o1.add o2
raise SY::QuantityError, "Unable to perform #add with #{m2.quantity}!"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def abs_sum()\n self.abs().sum()\n end",
"def abs2\n abs * abs\n end",
"def + m2\n return magnitude amount + m2.amount if m2.quantity == quantity.relative\n return quantity.relative.magnitude( amount + m2.amount ) if\n quantity == m2.quantity\n return self if m2.equal? SY::ZERO\... | [
"0.6636413",
"0.6485063",
"0.6465335",
"0.64170253",
"0.6343092",
"0.6296617",
"0.6260278",
"0.620197",
"0.6184468",
"0.60738784",
"0.60738784",
"0.6066637",
"0.59363574",
"0.59301174",
"0.59258735",
"0.59007144",
"0.5894515",
"0.5867949",
"0.5783581",
"0.57761455",
"0.571135... | 0.610661 | 9 |
For absolute magnitudes, method always returns a result framed in corresponding relative quantity. | def - m2
return magnitude amount - m2.amount if m2.quantity == quantity.relative
return quantity.relative.magnitude( amount - m2.amount ) if
quantity == m2.quantity
return self if m2.equal? SY::ZERO
# o1, o2 = m2.coerce( self )
# return o1 - o2
raise( SY::QuantityError, "Unable to perform #{quantity} - #{m2.quantity}!" )
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def magnitude()\n _nrm2()\n end",
"def unit \n\t\t\tunitq = self.dup\n\t\t\tmagnitude = self.abs\n\t\t\tunitq[0] /= magnitude\n\t\t\tunitq[1] /= magnitude\n\t\t\tunitq[2] /= magnitude\n\t\t\tunitq[3] /= magnitude\n\t\t\treturn unitq\n\t\tend",
"def magnitude\n Math.sqrt self.dot self\n end",
... | [
"0.66371596",
"0.66244066",
"0.6357301",
"0.6280109",
"0.6242948",
"0.62064797",
"0.6162621",
"0.61110556",
"0.6073125",
"0.60688365",
"0.60401654",
"0.596949",
"0.5967239",
"0.5967239",
"0.5962745",
"0.59538054",
"0.5923919",
"0.5817884",
"0.5788229",
"0.57242113",
"0.571360... | 0.6075709 | 8 |
Subtraction of absolute magnitudes that returns a result framed as absolute quantity. (With caller being responsible for the result being nonnegative.) | def subtract m2
return magnitude( amount + m2.amount ) if quantity == m2.quantity
return self if m2.equal? SY::ZERO
# o1, o2 = m2.coerce( self )
# return o1.subtract o2
raise( SY::QuantityError, "Unable to perform #add with #{m2.quantity}!" )
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def abs() end",
"def absolute(siffra)\n if siffra < 0\n output = -siffra\n else\n output = siffra\n end\n return output\nend",
"def - m2\n return magnitude amount - m2.amount if m2.quantity == quantity.relative\n return quantity.relative.magnitude( amount - m2.amount ) if\n ... | [
"0.70352834",
"0.69824475",
"0.6948351",
"0.69387",
"0.6842656",
"0.682557",
"0.6820147",
"0.6767819",
"0.6767819",
"0.66077507",
"0.65607524",
"0.6512736",
"0.64972454",
"0.6447712",
"0.63772666",
"0.6361354",
"0.6357166",
"0.6338141",
"0.63305664",
"0.63186496",
"0.63186496... | 0.6343295 | 17 |
"Subtraction" of absolute magnitudes, that never takes more thant the amount from which subtraction is being performed. But for this reason, unlike regular subtract, it is not known in advance what amount will be subtracted. Returns an array of two values: first one is the amount actually subtracted (which may differ from the amount asked for), and the second is the actual result of the subtraction (amount left). The latter will be zero if attempt is made to subtract greater amount from a smaller one. | def take other
actually_taken = [ self, other ].min
return [ actually_taken, other.subtract( take ) ]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def big_diff(array)\n value1 = array.max\n array.delete(array.max)\n value2 = array.max\n return (value1 - value2).abs\nend",
"def subtract(a, b)\n difference = a - b\n return difference\nend",
"def - other\n [ self[0] - other[0], self[1] - other[1] ]\n end",
"def subtract(*number)\n test_array = ... | [
"0.6508946",
"0.6284733",
"0.6202716",
"0.6153776",
"0.6036118",
"0.60152316",
"0.60108554",
"0.6007657",
"0.59895587",
"0.598907",
"0.59539175",
"0.5928699",
"0.5928075",
"0.5900563",
"0.5899622",
"0.58986574",
"0.5893266",
"0.58849126",
"0.58816165",
"0.5875671",
"0.5870597... | 0.0 | -1 |
String describing this class. | def çς
"Magnitude"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def inspect\n \"#{self.class}<#{@description.inspect}>\"\n end",
"def inspect\n return \"#<#{self.class.name}: #{self.name}>\"\n end",
"def inspect\n \"#<#{self.class.name}: #{to_s}>\"\n end",
"def desc\n self.class.desc || self.class.name\n end",
"def inspect\n ... | [
"0.7707436",
"0.7694005",
"0.7479235",
"0.74419206",
"0.74357766",
"0.7398053",
"0.73928726",
"0.7367961",
"0.73619634",
"0.7324704",
"0.7294986",
"0.72494525",
"0.716611",
"0.7138754",
"0.7135024",
"0.712769",
"0.7095728",
"0.70721227",
"0.70686495",
"0.70601696",
"0.7026792... | 0.0 | -1 |
Used in the site header | def count_links
@links_count = Link.count
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def header; end",
"def header; end",
"def header; end",
"def site_header\n @attributes[:site_header]\n end",
"def header\n end",
"def head\n HEADER\n end",
"def site_meta\n end",
"def site_meta\n end",
"def head \n meta_author \"Kane Baccigalupi... | [
"0.72516197",
"0.72516197",
"0.72516197",
"0.7230084",
"0.7167308",
"0.7162718",
"0.68381256",
"0.68381256",
"0.6751252",
"0.67146903",
"0.6649776",
"0.6638007",
"0.65879613",
"0.6506532",
"0.65027434",
"0.64609265",
"0.6409648",
"0.6400265",
"0.6400265",
"0.6400265",
"0.6400... | 0.0 | -1 |
Energy nodes define demand in MJ, while capacities are specified as MW. 1MW per hour equals 3600 MJ. Returns a numeric. | def capacity_to_demand_multiplier
3600.0
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def capacity_to_demand_multiplier\n 8760.0\n end",
"def theCost\n # calculate the energy in kWh used in 24 hours at this power level\n # using (24x60x60 secs/day)/(1000x60x60 J/kWh) = 0.024 (kWh/day)/W\n kWh_per_day = 0.024*power\n # convert to an equivalent cost in cents\n return kWh_... | [
"0.66511",
"0.64719874",
"0.6223097",
"0.6067694",
"0.60434186",
"0.60384536",
"0.5962399",
"0.5925703",
"0.5924339",
"0.58744174",
"0.5853518",
"0.5732308",
"0.5731107",
"0.5729898",
"0.5716251",
"0.5606233",
"0.55801547",
"0.5559398",
"0.554886",
"0.55146176",
"0.5508214",
... | 0.64545226 | 2 |
I worked on this challenge [by myself]. 1. Solution Write your comments on what each thing is doing. If you have difficulty, go into IRB and play with the methods. Also make sure each step is necessary. If you don't think it's necessary Try implementing the code without it. | def translate_to_cipher(sentence) # defining a method named, "translate_to_cipher" and passing a single argument to it
alphabet = ('a'..'z').to_a # converting all alphabets to an array
cipher = Hash[alphabet.zip(alphabet.rotate(4))] # creating a Hash
spaces = ["@", "#", "$", "%", "^", "&", "*"] # creating an array of special characters
original_sentence = sentence.downcase # setting the input sentence to all lowercase
encoded_sentence = [] # creates an empty array
original_sentence.each_char do |element| # iterate over each character in a string
if cipher.include?(element) #if an element in the Cipher Hash == an element in the input sentence
encoded_sentence << cipher[element] # push that element from the cipher Hash to an array named, "encoded_sentence"
elsif element == ' ' # if there is a space in the input sentence
encoded_sentence << spaces.sample # push one of the elements from spaces array to encoded_sentence array
else # if not
encoded_sentence << element #push the original sentence into encoded sentence array
end # end the if
end # end the iteration
return encoded_sentence.join # return the encoded sentence as a string
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def solution(s, p, q)\n # write your code in Ruby 2.2\n g = s.length + 1\n a = (s.length + 1)**3\n c = (s.length + 1)**2\n tmp = []\n res = []\n tmp.push 0\n o = 0\n s.split('').each do |i|\n o += if i == 'T'\n 1\n elsif i == 'G'\n g\n elsif i == 'C'\n c\n ... | [
"0.61544245",
"0.6077438",
"0.6055224",
"0.60496867",
"0.6024231",
"0.60066915",
"0.59449536",
"0.5898434",
"0.5892945",
"0.5887646",
"0.5876065",
"0.5842523",
"0.5815832",
"0.5796369",
"0.579631",
"0.57645327",
"0.5704193",
"0.5696498",
"0.5693238",
"0.56874895",
"0.56732064... | 0.0 | -1 |
Use callbacks to share common setup or constraints between actions. | def set_stage
@stage = Stage.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.6163443",
"0.604317",
"0.5943409",
"0.59143174",
"0.5887026",
"0.58335453",
"0.57738566",
"0.5701527",
"0.5701527",
"0.56534666",
"0.5618685",
"0.54237175",
"0.5407991",
"0.5407991",
"0.5407991",
"0.5394463",
"0.5376582",
"0.5355932",
"0.53376216",
"0.5337122",
"0.5329516"... | 0.0 | -1 |
Only allow a trusted parameter "white list" through. | def stage_params
params.fetch(:stage, {}).permit(:category_id, :name, :description)
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 |
validation method to check if a user has favourited a product or not this takes two arguments: 1. The id of the user which is logged in 2. The id of the product being shown if a query on the Favourite table, using the user and product ids, returns an array greater than 0 then the product has already been favourited | def user_favourites(current_user, product)
Favourite.where(user_id: current_user, product_id: product) > 0
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def favorite_check user, img\n user.favorites.each do |fav|\n if fav.image_id == img.id\n return true\n end\n end\n\n return false\n end",
"def favored?(user_id)\n return self.favorites.exists?(user_id: user_id)\n end",
"def favorited_by?(user)\n favorites.wh... | [
"0.7306989",
"0.71859485",
"0.71097153",
"0.70612013",
"0.6982459",
"0.6882795",
"0.68553734",
"0.6822679",
"0.68085563",
"0.6772273",
"0.67272025",
"0.6716431",
"0.67132276",
"0.6711016",
"0.6651877",
"0.6646187",
"0.6568438",
"0.6563348",
"0.6543042",
"0.6494076",
"0.646206... | 0.8129114 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.