query stringlengths 7 9.55k | document stringlengths 10 363k | metadata dict | negatives listlengths 0 101 | negative_scores listlengths 0 101 | document_score stringlengths 3 10 | document_rank stringclasses 102
values |
|---|---|---|---|---|---|---|
Use callbacks to share common setup or constraints between actions. | def set_product_claim
@product_claim = ProductClaim.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 product_claim_params
params.require(:product_claim).permit(:user_id, :supermarket, :category, :brand, :description, :abf, :organic, :grassfed, :never, :humane, :promo, :expiration_date, :image, :price)
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 |
Part 1: Access multiple elements of a nested array Pseudocode Initial Solution Refactored Solution DRIVER TESTS GO BELOW THIS LINE Reflection Part 2: Write a method that takes a row number and returns all the elements in the row. Pseudocode DEFINE method get_row with two ARGUMENTS board, row RETURN ELEMENT row1 of board Initial Solution | def get_row(board,row)
board[row-1]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_row(row,board)\n return board[row] \nend",
"def get_row(row,board) # row(x,*y)\n\tboard[row]\nend",
"def get_row(board, row)\n board[row]\nend",
"def get_row(board, row)\n board[row]\nend",
"def get_row(board, row)\n return board[row]\nend",
"def get_row_elements(row)\n @cells[row]\n ... | [
"0.71235335",
"0.7123354",
"0.71073055",
"0.71073055",
"0.7076405",
"0.6891618",
"0.68278486",
"0.67934525",
"0.67889214",
"0.67508507",
"0.67004585",
"0.64379793",
"0.6395111",
"0.6376297",
"0.6356874",
"0.6324448",
"0.6324448",
"0.6207936",
"0.6201748",
"0.6181573",
"0.6173... | 0.63405126 | 15 |
Use inside def initialize, to get object id | def init
super_init
@defaults = OSX::NSUserDefaults.standardUserDefaults
register_defaults_for_inbox('~/Movies/iTunes-inbox') # Note: The directory for the box
# will not be created until the program is actually run, so the user can change inbox location in the preferences.
register_defaults_for_processed( Pathstring.new(@defaults.objectForKey(:inbox)).parent / 'iTunes-processed' ) # This is the location
# of directories for files that has been processed, converted, failed, etc. Must be on the same volume!
return self
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def object_id() end",
"def __id; @id || @obj.id; end",
"def id() end",
"def id\n object_id\n end",
"def id\n __id\n end",
"def id\n object.object_id\n end",
"def id\n object.id\n end",
"def id\n object.id\n end",
"def id()\n #This is a stub, used for indexing\n ... | [
"0.81858164",
"0.80553377",
"0.7697184",
"0.7509359",
"0.7491644",
"0.7459179",
"0.742805",
"0.742805",
"0.74157655",
"0.7405285",
"0.74028724",
"0.74028724",
"0.74028724",
"0.73997164",
"0.7394876",
"0.7394876",
"0.73676115",
"0.7360355",
"0.73227686",
"0.73221153",
"0.72641... | 0.0 | -1 |
Checks that inbox and processed directories are on the same volume (since we want to be able to move these big files, not copy them) Potential BUG: What happens if I want to move both to a diffent volume. Maybe there should be a method for moving both at the same time..? | def register_defaults_for_processed(target_dir)
if Pathstring.new(inbox).volume == Pathstring.new(target_dir).volume then
@defaults.registerDefaults(:processed => Pathstring.new(target_dir) )
else
raise "Both inbox and processed directories must be on same volume."
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sync!\n\n destfiles = begin \n FsShellProxy.new.ls(@dest, true) \n rescue NoSuchFile \n {}\n end\n results = HSync::compare(LocalFs.new.ls(@source, true), destfiles)\n push_files(results.files_missing_in_b)\n # push_files(results.files... | [
"0.6007712",
"0.5982647",
"0.5902136",
"0.58897376",
"0.58830637",
"0.5802409",
"0.5801397",
"0.5757566",
"0.5729186",
"0.5717225",
"0.570425",
"0.5701741",
"0.5680437",
"0.5655928",
"0.56456745",
"0.5637089",
"0.56067216",
"0.5591601",
"0.5558157",
"0.5543967",
"0.5532435",
... | 0.5997536 | 1 |
Checks that inbox and processed directories are on the same volume | def register_defaults_for_inbox(inboxpath)
if processed then # If there is a default set for processed...
if not Pathstring.new(inboxpath).volume == Pathstring.new(processed).volume then # ...and it's not on the same volume as inboxpath
raise "Both inbox and processed directories must be on same volume."
end
end
@defaults.registerDefaults(:inbox => File.expand_path(inboxpath))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def register_defaults_for_processed(target_dir)\n if Pathstring.new(inbox).volume == Pathstring.new(target_dir).volume then\n @defaults.registerDefaults(:processed => Pathstring.new(target_dir) )\n else\n raise \"Both inbox and processed directories must be on same volume.\"\n end\n end",
"... | [
"0.6155193",
"0.5775255",
"0.56353587",
"0.5602444",
"0.5589934",
"0.5523069",
"0.55050296",
"0.5474742",
"0.54152274",
"0.5399029",
"0.5394972",
"0.53911865",
"0.53261644",
"0.5310736",
"0.5310015",
"0.5285441",
"0.5280536",
"0.52759796",
"0.52722025",
"0.5251967",
"0.522982... | 0.6028424 | 1 |
def set_preferences end Note that this points to the actual inboxdirectory | def inbox
return @defaults.objectForKey(:inbox)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_config\n @me = current_user\n @profile = Profile.find_by user_id: current_user.id\n @preference = Preference.find_by user_id: current_user.id\n end",
"def set_preferences\n unless current_user.preference\n pref = Preference.create(user_id: current_user.id,theme: \"default-ri... | [
"0.5875382",
"0.58229256",
"0.5787761",
"0.5693339",
"0.564578",
"0.55750924",
"0.55706257",
"0.5545923",
"0.5536221",
"0.55259997",
"0.55197316",
"0.55189574",
"0.54969394",
"0.54817104",
"0.54778826",
"0.5451697",
"0.53765494",
"0.53627497",
"0.53580713",
"0.5355904",
"0.53... | 0.0 | -1 |
But this points to a directory that will contain a set of different directories for processed files | def processed
return @defaults.objectForKey(:processed)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def for(file_or_dir); end",
"def directory(dir); end",
"def directories; end",
"def directories; end",
"def target_files_in_dir(base_dir = T.unsafe(nil)); end",
"def configure_directories\n processing_dir = @config['processing_dir']\n if @config['directory_formats']\n @spec['origdir'] = @conf... | [
"0.6881335",
"0.68804115",
"0.6790909",
"0.6790909",
"0.6760648",
"0.6584804",
"0.6532048",
"0.64980865",
"0.6406091",
"0.6361338",
"0.6361338",
"0.6322287",
"0.6317839",
"0.6317839",
"0.6274138",
"0.62534",
"0.6249712",
"0.6246378",
"0.62385124",
"0.6224984",
"0.6205412",
... | 0.0 | -1 |
GET /threats/1 GET /threats/1.xml | def show
@threat = Threat.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @threat }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @threds = Thred.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @threds }\n end\n end",
"def index\n @click_to_talks = ClickToTalk.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml... | [
"0.62674224",
"0.59927523",
"0.5965758",
"0.595783",
"0.59393615",
"0.59247285",
"0.5884636",
"0.5866884",
"0.5851609",
"0.58483505",
"0.5834604",
"0.5823494",
"0.5764516",
"0.57596314",
"0.5746658",
"0.57162845",
"0.5711153",
"0.5710144",
"0.5689824",
"0.5683754",
"0.5645016... | 0.6149487 | 1 |
GET /threats/new GET /threats/new.xml | def new
@threat = Threat.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @threat }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @coating }\n end\n end",
"def new\n @thred = Thred.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @thred }\n end\n end",
"def new\n ... | [
"0.6994002",
"0.68314433",
"0.6741578",
"0.6691571",
"0.66637546",
"0.6607414",
"0.658991",
"0.6585377",
"0.654986",
"0.6499361",
"0.6494669",
"0.64876175",
"0.6478503",
"0.6467655",
"0.6467655",
"0.6436838",
"0.641355",
"0.6393848",
"0.6389567",
"0.6387195",
"0.63831675",
... | 0.691455 | 1 |
POST /threats POST /threats.xml | def create
@threat = Threat.new(params[:threat])
respond_to do |format|
if @threat.save
format.html { redirect_to(@threat, :notice => 'Threat was successfully created.') }
format.xml { render :xml => @threat, :status => :created, :location => @threat }
else
format.html { render :action => "new" }
format.xml { render :xml => @threat.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def threats_answer_params\n params.require(:threats_answer).permit(:text, :threat_id)\n end",
"def create\n @threats_answer = ThreatsAnswer.new(threats_answer_params)\n @threat = Threat.find(@threats_answer.threat)\n @plano = current_user.plano\n @threats = @plano.threats\n respond_to do |... | [
"0.534782",
"0.53325224",
"0.5322265",
"0.5281594",
"0.5169899",
"0.51271677",
"0.51141894",
"0.5107345",
"0.50853515",
"0.50703764",
"0.5069859",
"0.5030495",
"0.5006207",
"0.5004209",
"0.5003594",
"0.50027865",
"0.49882177",
"0.49855292",
"0.49725974",
"0.49716353",
"0.4941... | 0.5544318 | 0 |
PUT /threats/1 PUT /threats/1.xml | def update
@threat = Threat.find(params[:id])
respond_to do |format|
if @threat.update_attributes(params[:threat])
format.html { redirect_to(@threat, :notice => 'Threat was successfully updated.') }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @threat.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update opts = {}\n opts[:headers] ||= {}\n opts[:headers]['Content-Type'] ||= 'text/xml'\n post 'update', opts\n end",
"def update\n @seat = Seat.find(params[:id])\n\n respond_to do |format|\n if @seat.update_attributes(params[:seat])\n format.html { redirect_to(@seat, :notice => ... | [
"0.62588763",
"0.5713151",
"0.56344104",
"0.5630028",
"0.55805975",
"0.55342805",
"0.5496455",
"0.5488505",
"0.54764646",
"0.5466151",
"0.5464442",
"0.53870195",
"0.5366518",
"0.5353993",
"0.5341912",
"0.53367",
"0.5331451",
"0.53199977",
"0.5311789",
"0.5303575",
"0.52901584... | 0.5673207 | 2 |
DELETE /threats/1 DELETE /threats/1.xml | def destroy
@threat = Threat.find(params[:id])
@threat.destroy
respond_to do |format|
format.html { redirect_to(threats_url) }
format.xml { head :ok }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n RestClient.delete \"#{REST_API_URI}/contents/#{id}.xml\" \n self\n end",
"def destroy\n @boat = Boat.find(params[:id])\n @boat.destroy\n\n respond_to do |format|\n format.html { redirect_to(boats_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @t1 =... | [
"0.6373573",
"0.6353274",
"0.63419706",
"0.6317276",
"0.6268632",
"0.6224476",
"0.6220366",
"0.62074035",
"0.62050295",
"0.62013686",
"0.6196077",
"0.6192619",
"0.6187081",
"0.61792195",
"0.6176768",
"0.61679584",
"0.61482346",
"0.61328286",
"0.6114421",
"0.60976565",
"0.6097... | 0.70137775 | 0 |
This ConnectTacToeplay method is given for free and does not need to be modified It is used to make your game playable. | def play
until @board.winner?(@player_1.token) || @board.winner?(@player_2.token)
@board.print
self.play_turn
p "--------------------"
end
self.switch_players!
@board.print
p @current_player.token + " has won!"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def connect4(boardClass)\n \tboard = boardClass.new\n players = Player.create\n players.\n \trefresh\n \tboard.testboard\n \t#board.game_mode #decide on PVP or AI and enter char names\n \trefresh\n \tboard.printCoords #outputs sample of game box to show how coords work\n \trefresh\n \tboard.printboar... | [
"0.64582855",
"0.6390269",
"0.61833715",
"0.61699545",
"0.6158984",
"0.61464894",
"0.61271465",
"0.6112989",
"0.6077604",
"0.60116607",
"0.6010722",
"0.60003346",
"0.59994644",
"0.597408",
"0.5971174",
"0.59674484",
"0.5945435",
"0.59450364",
"0.59306693",
"0.5925532",
"0.589... | 0.0 | -1 |
Given a hash with numeric values, return the key for the smallest value | def key_for_min_value(name_hash)
if name_hash.empty?
return nil
else
min_v = name_hash.first[1]
min_k = name_hash.first[0]
name_hash.each do
|k,v|
if v < min_v
min_v = v
min_k = k
end
end
min_k
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def key_for_min_value(hash)\n lowest_key = nil\n lowest_value = Float::INFINITY\n hash.each do |key, value|\n if value < lowest_value\n lowest_value = value\n lowest_key = key\n end\n end\n lowest_key\nend",
"def key_for_min_value(hash)\n lowest_key = nil\n lowest_value = Float::INFINITY\n... | [
"0.8821222",
"0.8777674",
"0.87769854",
"0.8745862",
"0.8689437",
"0.86553806",
"0.865241",
"0.86165065",
"0.8587693",
"0.8572328",
"0.85674095",
"0.8550907",
"0.8529734",
"0.8529734",
"0.85182345",
"0.84936565",
"0.8475531",
"0.8475531",
"0.8466132",
"0.8449126",
"0.84490585... | 0.0 | -1 |
Takes a range and yields pairs of [value, valid?] | def test_range(r)
yield [r.min-1, false]
yield [r.min, true]
yield [r.max, true]
yield [r.max+1, false]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def valid?(range)\n range[0] < range[1]\nend",
"def check_range(rng)\n new(rng).results\n end",
"def valid_result_range\n self.result && self.result > -2 ? true : false\n end",
"def verify_range(value)\n a = (20...30) === value\n if a != true\n puts \"#{value} is not in range of 20 to 30\"\n else... | [
"0.7365275",
"0.6794344",
"0.67521155",
"0.6719763",
"0.66497636",
"0.6432021",
"0.64070433",
"0.6315455",
"0.6294037",
"0.6239495",
"0.61764205",
"0.6081809",
"0.6081809",
"0.6062867",
"0.6060753",
"0.6056744",
"0.60563254",
"0.60561895",
"0.60397905",
"0.60256296",
"0.60225... | 0.7384472 | 0 |
Replace this with your real tests. | def setup
@task_submission = Factory.build(:task_submission)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def testing\n # ...\n end",
"def __dummy_test__\n end",
"def tests; end",
"def tests; end",
"def spec; end",
"def spec; end",
"def self_test; end",
"def self_test; end",
"def test \n end",
"def test_0_dummy\n\t\tend",
"def test\n\n end",
"def test\n end",
"def test\n end"... | [
"0.7446459",
"0.6956364",
"0.69155836",
"0.69155836",
"0.6864151",
"0.6864151",
"0.66406286",
"0.66406286",
"0.66253287",
"0.6547665",
"0.6524571",
"0.6484549",
"0.6484549",
"0.6484549",
"0.6403847",
"0.6389188",
"0.6389188",
"0.6389188",
"0.6389188",
"0.6389188",
"0.6389188"... | 0.0 | -1 |
check if student already applied this semester | def verify_unique_semester_application(current_applicant)
return true unless current_applicant.external_applied_for?(@settings.current_semester)
redirect_to students_apply_path, flash: { error: t('student_applications.create.resubmit') }
false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def isValidSemester?(semester)\n\t\tSEMESTERS.include? semester\n\tend",
"def student_team_already_existing\n return false if self.student.nil? || self.team.nil?\n if student_id_changed? || team_id_changed?\n assignment = StudentTeam.for_team(self.team).for_student(self.student)\n errors.add(:stu... | [
"0.72673243",
"0.70935845",
"0.689772",
"0.6868563",
"0.6817627",
"0.664665",
"0.6544057",
"0.6486318",
"0.6434375",
"0.64167",
"0.6378888",
"0.63492984",
"0.6346527",
"0.6346527",
"0.63438004",
"0.63396454",
"0.6258459",
"0.6231072",
"0.62131965",
"0.6208256",
"0.6169102",
... | 0.688842 | 3 |
Set the response status code and header | def redirect_to(url)
raise "already built response" if already_built_response?
@res.status = 302
@res["Location"] = url
@already_built_response = true
self.session.store_session(@res)
self.flash.store_flash(@res)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def status(code)\n @response.status = code\n end",
"def send_headers response_code\n end",
"def status(code)\n response.status = code\n end",
"def set_status_code\n if self.status_code.nil?\n self.status_code = \"200\"\n end\n end",
"def response_status(kind)\n response.... | [
"0.794432",
"0.78250635",
"0.78158605",
"0.757165",
"0.74761254",
"0.73475385",
"0.7225574",
"0.7152764",
"0.71213555",
"0.70445",
"0.6923586",
"0.6883578",
"0.68797094",
"0.68797094",
"0.687684",
"0.68444437",
"0.678412",
"0.6782564",
"0.6771085",
"0.6747486",
"0.67410016",
... | 0.0 | -1 |
Populate the response with content. Set the response's content type to the given type. Raise an error if the developer tries to double render. | def render_content(content, type)
raise "already built response" if already_built_response?
self.session.store_session(@res)
self.flash.store_flash(@res)
@res.content_type = type
@res.body = content
@already_built_response = true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def render_content(content, type)\n if already_built_response?\n raise\n else\n res.content_type = type\n res.body = content\n end\n @already_built_response = true\n @session.store_session(res) if @session\n @flash.store_flash(res) if @flash\n end",
"def ren... | [
"0.8146179",
"0.7987508",
"0.785869",
"0.77699715",
"0.7687297",
"0.76619387",
"0.7649412",
"0.7580971",
"0.75760704",
"0.7572346",
"0.7454495",
"0.74275774",
"0.7408022",
"0.740662",
"0.7404474",
"0.7379969",
"0.73241127",
"0.7267427",
"0.72407204",
"0.71585613",
"0.7132146"... | 0.76790184 | 5 |
use this with the router to call action_name (:index, :show, :create...) | def invoke_action(name)
self.send(name)
render(name) unless already_built_response?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def invoke_action(name)\n end",
"def invoke_action(name)\n end",
"def invoke_action(name)\n end",
"def index\r\n list\r\n render_action 'list'\r\n end",
"def route_index; end",
"def index\n list\n render_action 'list'\n end",
"def method_for_action(action_name); end",
"def action\n ... | [
"0.734207",
"0.734207",
"0.7341121",
"0.7079497",
"0.70227414",
"0.696795",
"0.6943637",
"0.6920887",
"0.69136906",
"0.6890334",
"0.68671626",
"0.6824139",
"0.6813997",
"0.6774912",
"0.67631173",
"0.6758284",
"0.67041564",
"0.6686834",
"0.6681827",
"0.6678034",
"0.665475",
... | 0.6560247 | 42 |
Create a reference resolver, options: :identifier_resolver: a proc which is called with an identifier and which should return the associated element in case the identifier is not uniq, the proc may return multiple values default: lookup element in internal map | def initialize(options={})
@identifier_resolver = options[:identifier_resolver]
@identifier_map = {}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def resolve_local(options={})\r\n resolver = RGen::Instantiator::ReferenceResolver.new\r\n index.each do |i|\r\n resolver.add_identifier(i[0], i[1])\r\n end\r\n @unresolved_refs = resolver.resolve(unresolved_refs, :use_target_type => options[:use_target_type])\r\n end",
"def resolve(unresolved_... | [
"0.68053854",
"0.6335437",
"0.6183314",
"0.5975405",
"0.596767",
"0.5909224",
"0.5889479",
"0.5782354",
"0.5683273",
"0.56790835",
"0.5677379",
"0.5665979",
"0.5617914",
"0.5509146",
"0.5482542",
"0.5465393",
"0.5461956",
"0.54489076",
"0.54489076",
"0.5427035",
"0.53324634",... | 0.5898166 | 6 |
Add an +identifer+ / +element+ pair which will be used for looking up unresolved identifers | def add_identifier(ident, element)
map_entry = @identifier_map[ident]
if map_entry
if map_entry.is_a?(Array)
map_entry << element
else
@identifier_map[ident] = [map_entry, element]
end
else
@identifier_map[ident] = element
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_identifier(val)\n return if val.nil?\n @identifiers.push(self.class.normalize_id(val)) unless @identifiers.index(self.class.normalize_id(val))\n end",
"def identify(sym, vals=nil)\n if vals.nil?\n identifiers_hash[sym]\n else\n identifiers_hash[sym] = vals\n ... | [
"0.6256824",
"0.6014995",
"0.6010768",
"0.59226495",
"0.5903451",
"0.58819604",
"0.5711026",
"0.5669221",
"0.56451416",
"0.56451416",
"0.56451416",
"0.56123066",
"0.55174124",
"0.54344827",
"0.5394895",
"0.53877884",
"0.5380361",
"0.5377576",
"0.536624",
"0.5353462",
"0.53534... | 0.81230694 | 0 |
Tries to resolve the given +unresolved_refs+. If resolution is successful, the proxy object will be removed, otherwise there will be an error description in the problems array. In case the resolved target element's type is not valid for the given feature, the +target_type_error+ flag will be set on the unresolved reference. Returns an array of the references which are still unresolved. Options: :problems an array to which problems will be appended :on_resolve a proc which will be called for every sucessful resolution, receives the unresolved reference as well as to new target element :use_target_type use the expected target type to narrow the set of possible targets (i.e. ignore targets with wrong type) :failed_resolutions a Hash which will receive an entry for each failed resolution for which at least one target element was found (wrong target type, or target not unique). hash key is the uref, hash value is the target element or the Array of target elements | def resolve(unresolved_refs, options={})
problems = options[:problems] || []
still_unresolved_refs = []
failed_resolutions = options[:failed_resolutions] || {}
unresolved_refs.each do |ur|
if @identifier_resolver
target = @identifier_resolver.call(ur.proxy.targetIdentifier)
else
target = @identifier_map[ur.proxy.targetIdentifier]
end
target = [target].compact unless target.is_a?(Array)
if options[:use_target_type]
feature = ur.element.class.ecore.eAllReferences.find{|r| r.name == ur.feature_name}
target = target.select{|e| e.is_a?(feature.eType.instanceClass)}
end
if target.size == 1
status = ResolutionHelper.set_uref_target(ur, target[0])
if status == :success
options[:on_resolve] && options[:on_resolve].call(ur, target[0])
elsif status == :type_error
ur.target_type_error = true
problems << type_error_message(target[0])
still_unresolved_refs << ur
failed_resolutions[ur] = target[0]
end
elsif target.size > 1
problems << "identifier #{ur.proxy.targetIdentifier} not uniq"
still_unresolved_refs << ur
failed_resolutions[ur] = target
else
problems << "identifier #{ur.proxy.targetIdentifier} not found"
still_unresolved_refs << ur
end
end
still_unresolved_refs
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def unresolve_refs(rrefs)\r\n # make sure any removed_urefs have been removed, \r\n # otherwise they will be removed later even if this method actually re-added them\r\n unresolved_refs\r\n rrefs.each do |rr|\r\n ur = rr.uref\r\n refs = ur.element.getGeneric(ur.feature_name)\r\n if refs.... | [
"0.7077182",
"0.62200445",
"0.56936824",
"0.56459904",
"0.56038684",
"0.5388018",
"0.5291449",
"0.52605325",
"0.49676314",
"0.49657717",
"0.4962931",
"0.49530134",
"0.49332288",
"0.4918868",
"0.48872533",
"0.48753232",
"0.4821397",
"0.4804002",
"0.47497967",
"0.47372916",
"0.... | 0.8583581 | 0 |
TODO: remove this method when we're on a version of devise_invitable which no longer expects it to exist (v1.2.1 onwards) | def build_resource
self.resource = resource_class.new(resource_params)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def invite_resource\n ## skip sending emails on invite\n # super do |u|\n # u.skip_invitation = true\n # end\n end",
"def fetchable_fields\n super - [:password, :password_confirmation]\n # if (context[:current_user].guest)\n # super - [:email]\n # else\n # super\n # end\n en... | [
"0.62042296",
"0.6148035",
"0.6088427",
"0.60879844",
"0.60226566",
"0.5949831",
"0.5934966",
"0.5934966",
"0.5880972",
"0.58695066",
"0.5849885",
"0.58398026",
"0.5837345",
"0.5821982",
"0.58006555",
"0.57847524",
"0.57737744",
"0.5766662",
"0.5740797",
"0.5715828",
"0.57071... | 0.0 | -1 |
TODO: once we've upgraded Devise and DeviseInvitable, `resource_params` hopefully won't be being called for actions like `new` anymore and we can change the following `params.fetch(:user)` to `params.require(:user)`. See and for details :) | def unsanitised_user_params
params.require(:user).permit(
:name,
:email,
:organisation_id,
:invitation_token,
:password,
:password_confirmation,
:require_2sv,
:role,
supported_permission_ids: [],
).to_h
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def resource_params\n strong_params = params.require(resource_name.to_sym).permit(*permit_attributes)\n strong_params.merge(user_id: current_user.id) if user_signed_in?\n end",
"def resource_params\n @resource_params ||= current_model_service.permit params\n end",
"def resource_params\n @... | [
"0.7556684",
"0.7339725",
"0.73241115",
"0.72351956",
"0.7197823",
"0.71927255",
"0.7071349",
"0.7027629",
"0.6970772",
"0.69608736",
"0.6958336",
"0.689695",
"0.6889622",
"0.68828034",
"0.6852137",
"0.6761511",
"0.67408776",
"0.6690889",
"0.66635764",
"0.66462874",
"0.662812... | 0.0 | -1 |
NOTE: `current_user` doesn't exist for `edit` and `update` actions as implemented in our current (outofdate) versions of Devise ( and DeviseInvitable ( With the old attr_accessible approach, this would fall back to the default whitelist (i.e. equivalent to the `:normal` role) and this this preserves that behaviour. In fact, a user accepting an invitation only needs to modify `password` and `password_confirmation` so we could only permit those two params for the `edit` and `update` actions. | def current_user_role
current_user.try(:role).try(:to_sym) || :normal
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def invite_params\n invite = params.require(:invite).permit(:name, :email, :role)\n current_user ? invite.merge(user_id: T.must(current_user).id) : invite\n end",
"def user_permitted_to_edit(item)\n item.user == current_user \n end",
"def edit_current_user\n end",
"def current_inviter\n if use... | [
"0.6833828",
"0.676723",
"0.66149086",
"0.65951777",
"0.6354091",
"0.6225729",
"0.6192588",
"0.61914057",
"0.6180591",
"0.6169742",
"0.6164466",
"0.6160427",
"0.61588216",
"0.61588216",
"0.61588216",
"0.61588216",
"0.61588216",
"0.61588216",
"0.61588216",
"0.61588216",
"0.615... | 0.0 | -1 |
returns true if the given token matches the digest. | def authenticated?(remember_token)
return false if remember_digest.nil?
# so here we compare the remember token, to the remember digest
BCrypt::Password.new(remember_digest).is_password?(remember_token)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def authenticated?(digest, token)\n digest = send(\"#{digest}_digest\")\n # Use metaprogramming to select the appropriate token attribute based on\n # the parameter digest.\n return false if digest.nil? # Digest does not exist in the database.\n BCrypt::Password.new(digest).is_password?(token)\n ... | [
"0.7914453",
"0.7654215",
"0.74407446",
"0.72914106",
"0.7161283",
"0.7161283",
"0.71551",
"0.69904083",
"0.69884264",
"0.6974271",
"0.68869066",
"0.687283",
"0.686985",
"0.6847443",
"0.6822308",
"0.6814704",
"0.67911905",
"0.67816776",
"0.67804825",
"0.6777267",
"0.67768365"... | 0.0 | -1 |
Originally written by Richard L. Apodaca | def get_text(random, alphabet = 'abcdefghijklmnopqrstuvwxyz', character_count = 6)
if character_count < 1 || character_count > 16
raise "Character count of #{character_count} is outside the range of 1-16"
end
input = "#{@secret}#{random}"
if alphabet != 'abcdefghijklmnopqrstuvwxyz' || character_count != 6
input << ":#{alphabet}:#{character_count}"
end
bytes = Digest::MD5.hexdigest(input).slice(0..(2*character_count - 1)).scan(/../)
text = ''
bytes.each { |byte| text << alphabet[byte.hex % alphabet.size].chr }
text
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def private; end",
"def probers; end",
"def schubert; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def berlioz; end",
"def terpene; end",
"def stderrs; end",
"def suivre; end",
"def offences_by; end",
"def formation; end",
"def verdi; end",
"def anc... | [
"0.74321735",
"0.6997013",
"0.65936744",
"0.6535431",
"0.6535431",
"0.6535431",
"0.6535431",
"0.63726467",
"0.6290715",
"0.6276794",
"0.621406",
"0.62074137",
"0.62059414",
"0.61825794",
"0.61589366",
"0.6087309",
"0.6086701",
"0.6061067",
"0.60419697",
"0.60411644",
"0.60110... | 0.0 | -1 |
skip can be used for work in progress | def test_raises_error_for_bad_argument
skip "to-do"
assert_raises(ArgumentError) {@fb.convert('foo')}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def skip\n end",
"def skip\n end",
"def skip\n @skip = true\n end",
"def skip!\n @skip ||= true\n end",
"def skipped!; end",
"def skipped; end",
"def skip\n @scanner.skip(@skip)\n end",
"def skip(skip = nil)\n set_option(:skip, skip)\n end",
"def skipped?; ... | [
"0.8477002",
"0.8477002",
"0.8225197",
"0.81066936",
"0.791982",
"0.7809044",
"0.77999854",
"0.7695461",
"0.76680577",
"0.76680577",
"0.76680577",
"0.76680577",
"0.7598539",
"0.7598539",
"0.7496644",
"0.74712086",
"0.7468461",
"0.74598306",
"0.74567366",
"0.74032295",
"0.7401... | 0.0 | -1 |
4) Method that will take us to the form to create an new instance | def new
@post = Post.new
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\r\n\r\n end",
"def new\r\n \r\n end",
"def new\r\n end",
"def new\r\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n ... | [
"0.7909018",
"0.78156126",
"0.7781826",
"0.7781826",
"0.7715552",
"0.7715552",
"0.7715552",
"0.7715552",
"0.7715552",
"0.7715552",
"0.7715552",
"0.7715552",
"0.7715552",
"0.7715552",
"0.7715552",
"0.7715552",
"0.7715552",
"0.7715552",
"0.7715552",
"0.7715552",
"0.7715552",
... | 0.0 | -1 |
Return all of the fences straight from mongo | def get_all_fences
@coll.find.to_a
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fetchAllDocuments(collection)\n return collection.find({})\n end",
"def collections\n Collection.find(:all, :find_through => [N::DCT.hasPart, self])\n end",
"def get_fences(*args)\n\tfences = @@vars['access_token'].request(:get, \"/api/v3/geo_fences\", HEADERS)\n\tresult = nil\n\tif a... | [
"0.5769389",
"0.57668024",
"0.574559",
"0.5696761",
"0.56550366",
"0.55680275",
"0.5538155",
"0.55051553",
"0.54959077",
"0.54875195",
"0.5479067",
"0.54726964",
"0.54434806",
"0.54212505",
"0.54137194",
"0.5397044",
"0.53674024",
"0.5364694",
"0.5359403",
"0.5359403",
"0.535... | 0.78418446 | 0 |
, :xml, :json GET /odiseo/reports/new GET /odiseo/reports/new.json GET /odiseo/reports/new.xml | def new
@balance_report = BalanceReport.new(current_company)
respond_to do |format|
format.html # .html.erb
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @report }\n end\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @report_type }\n end\n end",
"def new\n respond_to do |format|\... | [
"0.7522353",
"0.7345851",
"0.7345851",
"0.7226597",
"0.696384",
"0.696384",
"0.696384",
"0.696384",
"0.69319963",
"0.6924615",
"0.68323624",
"0.67997795",
"0.6795443",
"0.6787265",
"0.67549235",
"0.6745474",
"0.6707421",
"0.67070466",
"0.67058134",
"0.6678424",
"0.6659346",
... | 0.0 | -1 |
POST /odiseo/reports POST /odiseo/reports.json POST /odiseo/reports.xml | def create
@balance_report = BalanceReport.new(current_company, params[:odiseo_balance_report])
@accounts = @balance_report.accounts.page(params[:page])
flash.now[:notice] = t('flash.actions.index.notice') if @balance_report.valid? && @accounts.empty?
respond_to do |format|
format.html do
render :new
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reports\n @node = resource\n @reports = params[:kind] == \"inspect\" ? @node.reports.inspections : @node.reports.applies\n respond_to do |format|\n format.html { @reports = paginate_scope(@reports); render 'reports/index' }\n end\n end",
"def report(object)\n full_name = extract_full... | [
"0.6685929",
"0.64416784",
"0.6415169",
"0.63674515",
"0.6352543",
"0.634552",
"0.6327105",
"0.62638843",
"0.62291545",
"0.62281424",
"0.6210026",
"0.61944443",
"0.6191766",
"0.6180454",
"0.6174855",
"0.6172929",
"0.6172929",
"0.6161767",
"0.6132578",
"0.61313784",
"0.6122995... | 0.0 | -1 |
GET /users/1 GET /users/1.json | def show
@user = User.find(params[:id])
@sessionname = session[:current_user_id]
respond_to do |format|
format.html # show.html.erb
format.json { render json: @user }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n if params[:single]\n\t url = \"#{API_BASE_URL}/users/#{params[:id]}.json\"\n\t response = RestClient.get(url)\n\t @user = JSON.parse(response.body)\n\telse\n\t url = \"#{API_BASE_URL}/users.json\"\t \n response = RestClient.get(url)\n @users = JSON.parse(response.body)\t\t \n\tend\n ... | [
"0.81046426",
"0.7703556",
"0.77011716",
"0.76262826",
"0.7582106",
"0.74818",
"0.7461394",
"0.7446168",
"0.730656",
"0.7300699",
"0.72902125",
"0.72781444",
"0.72358584",
"0.72335744",
"0.72335744",
"0.72335744",
"0.72335744",
"0.72335744",
"0.72335744",
"0.72335744",
"0.722... | 0.0 | -1 |
GET /users/new GET /users/new.json | def new
@user = User.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @user }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @newuser = Newuser.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @newuser }\n end\n end",
"def new\n @usernew = Usernew.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @usernew }\n ... | [
"0.8287397",
"0.8169197",
"0.8155916",
"0.80483407",
"0.8022376",
"0.8021751",
"0.8009459",
"0.7950995",
"0.793078",
"0.793078",
"0.7873476",
"0.7873476",
"0.7873476"
] | 0.7860956 | 86 |
POST /users POST /users.json | def create
@user = User.new(params[:user])
respond_to do |format|
if @user.save
if session[:current_user_id].nil?
session[:current_user_id] = @user.id
#flash[:alert] = "You have successfully logged in"
#redirect_to :controller => "posts", :action => "index"
end
format.html { redirect_to @user, notice: 'User was successfully created.' }
format.json { render json: @user, status: :created, location: @user }
else
format.html { render action: "new" }
format.json { render json: @user.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def post_users(users)\n self.class.post('https://api.yesgraph.com/v0/users', {\n :body => users.to_json,\n :headers => @options,\n })\n end",
"def CreateUser params = {}\n \n APICall(path: 'users.json',method: 'POST',payload: params.to_json)\n \n end",
"def post b... | [
"0.77179813",
"0.75206673",
"0.73831296",
"0.72405374",
"0.719841",
"0.7140812",
"0.71038526",
"0.7058827",
"0.7041636",
"0.70236504",
"0.7003128",
"0.70021695",
"0.70021695",
"0.70021695",
"0.69936967",
"0.6990463",
"0.6980393",
"0.6979075",
"0.69788617",
"0.69788617",
"0.69... | 0.0 | -1 |
PUT /users/1 PUT /users/1.json | def update
@user = User.find(params[:id])
respond_to do |format|
if @user.update_attributes(params[:user])
format.html { redirect_to @user, notice: 'User was successfully updated.' }
format.json { head :ok }
else
format.html { render action: "edit" }
format.json { render json: @user.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n render json: Users.update(params[\"id\"], params[\"user\"])\n end",
"def update\n render json: User.update(params[\"id\"], params[\"user\"])\n end",
"def UpdateUser params = {}\n \n APICall(path: 'users.json',method: 'PUT',payload: params.to_json)\n \n end",
"de... | [
"0.74114245",
"0.73920554",
"0.73041475",
"0.7254177",
"0.7202618",
"0.70756376",
"0.70535713",
"0.7029043",
"0.70075685",
"0.69883573",
"0.6983195",
"0.694263",
"0.69409895",
"0.692315",
"0.6909438",
"0.687742",
"0.68486536",
"0.6834162",
"0.6821841",
"0.6801179",
"0.6770304... | 0.0 | -1 |
DELETE /users/1 DELETE /users/1.json | def destroy
@user = User.find(params[:id])
post = Post.find(:all, :conditions => ["user_id = ?", @user.id])
for n in 0 ... post.size do
Post.destroyCascade(post[n])
end
vote = Vote.find(:all, :conditions => ["user_id = ?", @user.id])
for n in 0 ... vote.size do
Vote.destroyCascade(vote[n])
end
comment = Comment.find(:all, :conditions => ["user_id = ?", @user.id])
for n in 0 ... comment.size do
Comment.destroyCascade(comment[n])
end
commentvote = CommentVote.find(:all, :conditions => ["user_id = ?", @user.id])
for n in 0 ... commentvote.size do
CommentVote.destroyCascade(commentvote[n])
end
@user.destroy
respond_to do |format|
format.html { redirect_to users_url }
format.json { head :ok }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def DeleteUser id\n \n APICall(path: \"users/#{id}.json\",method: 'DELETE')\n \n end",
"def delete\n render json: User.delete(params[\"id\"])\n end",
"def delete(id)\n request(:delete, \"/users/#{id}.json\")\n end",
"def delete\n render json: Users.delete(params[\"id\... | [
"0.78750724",
"0.77518034",
"0.7713981",
"0.7610077",
"0.747295",
"0.74073994",
"0.74073994",
"0.7369968",
"0.7346072",
"0.7340465",
"0.7328618",
"0.7309635",
"0.73095363",
"0.7306841",
"0.7297868",
"0.72917855",
"0.7291585",
"0.7289111",
"0.7284347",
"0.7250935",
"0.7250935"... | 0.0 | -1 |
Return a list of taxons from the publishing API with links included. Does not include the details hash of each taxon. | def taxon_content_items(page:, per_page:, query:, states:)
Services
.publishing_api
.get_content_items(
document_type: "taxon",
order: "-public_updated_at",
q: query || "",
search_in: %i[title base_path details.internal_name],
page: page || 1,
per_page: per_page || 50,
states: states || [],
)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_taxons_by_permalink(permalink)\n taxonomies = get_taxonomies.taxonomies\n taxons = []\n taxonomies.each do |taxonomy|\n taxons += taxonomy.root.taxons.select { |taxon| taxon.permalink == permalink }\n end\n taxons\n end",
"def index\n @taxons = Taxon.all\n end",
"... | [
"0.6518563",
"0.63746446",
"0.62156045",
"0.6212406",
"0.60188425",
"0.5924883",
"0.57575035",
"0.57350504",
"0.5601776",
"0.5588982",
"0.55861056",
"0.5584229",
"0.55757415",
"0.55521965",
"0.55432546",
"0.55419827",
"0.5521935",
"0.5507723",
"0.5479883",
"0.54660213",
"0.54... | 0.5996354 | 5 |
Create a new dataset edit | def create_edit(commit, key, value)
ActiveRecord::Base.transaction do
DatasetEdit.create!(
commit_id: commit.id,
key: key,
value: value
)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n authorize! :create, Dataset\n @dataset = Dataset.new(dataset_params)\n respond_to do |format|\n if @dataset.save\n format.html { redirect_to edit_dataset_path(@dataset.key) }\n format.json { render :edit, status: :created, location: edit_dataset_path(@dataset.key) }\n ... | [
"0.68801874",
"0.68705106",
"0.6591719",
"0.6581154",
"0.6516188",
"0.6506433",
"0.6491185",
"0.6483731",
"0.6472215",
"0.6436314",
"0.6412467",
"0.6405469",
"0.6388114",
"0.638208",
"0.6238408",
"0.6166315",
"0.6138559",
"0.6121323",
"0.6091757",
"0.60863113",
"0.6073443",
... | 0.7034984 | 1 |
Finds all commits belonging to a dataset with an edit to the given key. | def find_commits(dataset, edit_key)
dataset.commits
.joins(:dataset_edits)
.where(dataset_edits: { key: edit_key })
.order(updated_at: :desc)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_edit(dataset, edit_key)\n commits = find_commits(dataset, edit_key)\n\n return nil unless commits.any?\n\n DatasetEdit\n .where(commit_id: commits.pluck(:id), key: edit_key)\n .order(updated_at: :desc)\n .first\n end",
"def find_edit(dataset, edit_key)\n commits = find_commit... | [
"0.7414475",
"0.7414475",
"0.6316527",
"0.6316527",
"0.5576506",
"0.53682905",
"0.5332031",
"0.5199947",
"0.5138429",
"0.5011507",
"0.49512532",
"0.49512532",
"0.49301142",
"0.48456606",
"0.48201632",
"0.48169738",
"0.47939104",
"0.47882327",
"0.47566804",
"0.47307977",
"0.46... | 0.8118308 | 1 |
Finds the most recent edit of a key belonging to a dataset. | def find_edit(dataset, edit_key)
commits = find_commits(dataset, edit_key)
return nil unless commits.any?
DatasetEdit
.where(commit_id: commits.pluck(:id), key: edit_key)
.order(updated_at: :desc)
.first
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_commits(dataset, edit_key)\n dataset.commits\n .joins(:dataset_edits)\n .where(dataset_edits: { key: edit_key })\n .order(updated_at: :desc)\n end",
"def find_commits(dataset, edit_key)\n dataset.commits\n .joins(:dataset_edits)\n .where(dataset_e... | [
"0.7036318",
"0.7036318",
"0.5754164",
"0.56819737",
"0.5619952",
"0.56044763",
"0.55192584",
"0.5518867",
"0.54308164",
"0.5340288",
"0.5340288",
"0.5337979",
"0.533101",
"0.53158754",
"0.5237369",
"0.5227485",
"0.5189971",
"0.5189153",
"0.5186359",
"0.516649",
"0.5147567",
... | 0.8002472 | 1 |
Removes all dataset edits matching the `edit_key`. If the key is the only dataset belonging to the commit, the commit will also be removed. | def destroy_edits(dataset, edit_key)
commits = find_commits(dataset, edit_key)
return if commits.none?
commits.each do |commit|
if commit.dataset_edits.one?
commit.destroy
else
commit.dataset_edits.find_by_key(edit_key).destroy
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clear(opts = {}) \n save(setup_commit_options({:message => \"all clear\"}.merge(opts))) do |index|\n if tree = index.current_tree\n tree.contents.each do |entry|\n index.delete(key_for(entry.name))\n end\n end\n end\n end",
"def clear(opts = {}) \n save(setup_... | [
"0.56993616",
"0.56993616",
"0.55326927",
"0.5507723",
"0.5507723",
"0.54427415",
"0.5336602",
"0.5282212",
"0.52799416",
"0.5257944",
"0.52420187",
"0.52420187",
"0.52420086",
"0.52420086",
"0.52356845",
"0.5219676",
"0.5217735",
"0.52150834",
"0.5194139",
"0.5193831",
"0.51... | 0.82388973 | 1 |
Cart content management Used to implement ProductsList interface each method | def quantified_items
products.map { |product| [product.variant, product.quantity] }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def products\n end",
"def view_cart\n @products\n end",
"def show_cart_detail\n @products = Product.find(session[:cart])\n end",
"def index\n set_cart\n get_products_array\n end",
"def cart\n # Calculate price\n # Warn: Need to update cart price every time items changed in cart for ... | [
"0.68885434",
"0.679729",
"0.6707468",
"0.6682198",
"0.6550222",
"0.6547867",
"0.6538446",
"0.65215296",
"0.6502721",
"0.64763033",
"0.64118445",
"0.63991445",
"0.6287897",
"0.6266605",
"0.62369055",
"0.62369055",
"0.6233141",
"0.6221749",
"0.62062645",
"0.61998177",
"0.61985... | 0.0 | -1 |
Mass products assignement, from session hash | def products=(items)
if items.is_a? Array
@products = items.map do |product|
Product.new(product)
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def edit\n\t\t# @product = Product.new\n\t\tputs params\n @comparison = Comparison.find(params[:id])\n\t\t# @products_hash = Hash.new\n # @tributes_all_hash = Hash.new\n @user = current_user\n\t\t@user.comparisons += [@comparison]\n\t\t# @product = Product.create(url: session[0][:url_hash][:ur... | [
"0.65751374",
"0.59400374",
"0.5892504",
"0.5760927",
"0.57149035",
"0.56984293",
"0.5634715",
"0.5616302",
"0.56048393",
"0.5571613",
"0.55640316",
"0.5547466",
"0.55435264",
"0.55426425",
"0.553087",
"0.55282557",
"0.5516176",
"0.5511952",
"0.5510311",
"0.5494565",
"0.54618... | 0.0 | -1 |
Mass adjustments assignement, from session hash | def adjustments=(items)
if items.is_a? Array
@adjustments = items.map do |adjustment|
Adjustment.build(self, adjustment)
end.compact
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mod\n # get the grade params\n grade_params = Hash.new\n params.each{ |key, value|\n begin\n key = key.to_i\n if key.kind_of?(Fixnum) && key != 0\n grade_params[key] = value\n end\n rescue Error\n # ignore\n end\n }\n grade_params.each{ |key,... | [
"0.5585577",
"0.55624104",
"0.5513046",
"0.55000865",
"0.54717654",
"0.5445686",
"0.53606796",
"0.5336261",
"0.53207535",
"0.53205603",
"0.531966",
"0.53177094",
"0.5307758",
"0.52890116",
"0.5272111",
"0.52651477",
"0.5249088",
"0.5246537",
"0.5228947",
"0.52206343",
"0.5208... | 0.0 | -1 |
Quantities management Product scoped quantity update | def set_quantity product_id, quantity, options = {}
options.reverse_merge!(override: false)
quantity = quantity.to_i
return unless quantity > 0
# If product was in cart
if (product = self.product(product_id))
if options[:override]
product.quantity = quantity
else
product.quantity += quantity
end
else
@products << Glysellin::Cart::Product.new(
id: product_id,
quantity: quantity
)
end
# Refresh discount code adjustment
self.discount_code = discount_code
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_product_qty\n @order = Spree::Order.find_by_id(params[:order_id])\n @line_item = Spree::LineItem.find_by_id(params[:line_item_id])\n request_to_update_qty = params[:quantity].to_i\n # code to find the order_total\n if @order.market_place.present?\n case @order.mark... | [
"0.75993234",
"0.7597482",
"0.7406935",
"0.7183835",
"0.71742105",
"0.709927",
"0.70612174",
"0.70300794",
"0.7022384",
"0.6984835",
"0.69317746",
"0.69176215",
"0.6912161",
"0.6902257",
"0.68883896",
"0.6884053",
"0.6878218",
"0.68733764",
"0.68595797",
"0.68537545",
"0.6797... | 0.6819326 | 20 |
Remove product from cart, given its id | def remove product_id
products.reject! { |product| product.variant.id == product_id.to_i }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_from_cart\n Cart.remove_from_cart(session[:cart], params[:id])\n redirect_to show_cart_products_path\n end",
"def removeProduct\n id = params[:id]\n cart = session[:cart]\n cart.delete id\n redirect_to :action => :index\n \n end",
"def delete_product_to_cart\n \tid = params[:... | [
"0.81934404",
"0.80725896",
"0.8059468",
"0.7939361",
"0.7878694",
"0.7850877",
"0.7825493",
"0.78220546",
"0.7785838",
"0.77223897",
"0.7717683",
"0.77165973",
"0.7672113",
"0.7590824",
"0.7572497",
"0.7561115",
"0.7523862",
"0.7523843",
"0.7422722",
"0.735829",
"0.7342795",... | 0.7551595 | 16 |
General check to see if cart is valid | def update_quantities!
@products = products.reduce([]) do |products, product|
# If product is not published
if !product.variant.published
set_error(:item_not_for_sale, item: product.variant.name)
# If product is not in stock
elsif !product.variant.in_stock?
set_error(:item_out_of_stock, item: product.variant.name)
# If product's available stock is less than required quantity
elsif !product.variant.available_for(product.quantity)
set_error(
:not_enough_stock_for_item,
item: product.variant.name, stock: product.variant.in_stock
)
product.quantity = product.variant.in_stock
products << product if product.quantity > 0
# Else, keep product as is in cart
else product.variant.unlimited_stock || product.variant.in_stock >= product.quantity
products << product
end
products
end
# TODO: Doesn't work, think in something else ...
if discount_code == false
set_error(:invalid_discount_code)
end
reset! if @products.length == 0
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ensure_not_product_item\n\t\tif product_items.empty?\n\t\t\treturn true\n\t\telse\n\t\t\terrors.add(:base, 'This item is in a shopping cart')\n\t\t\treturn false\n\t\tend\n\t\t\t\n\t\t\t\n\tend",
"def cart_check\n puts \"cart checking\"\n \n sleep(2)\n mini_cart_text.click\n wait_f... | [
"0.73606306",
"0.7079607",
"0.7047941",
"0.6979637",
"0.69685185",
"0.69503045",
"0.6945538",
"0.6928824",
"0.6911176",
"0.6888914",
"0.68579835",
"0.68327284",
"0.67756546",
"0.6747164",
"0.6687966",
"0.6687386",
"0.6667642",
"0.6659361",
"0.6607726",
"0.65892345",
"0.656119... | 0.0 | -1 |
Address Allows setting use_another_address_for_shipping attribute, ensuring it is stored as a Boolean value and not a number string | def use_another_address_for_shipping=(val)
value = val.is_a?(String) ? (val.to_i > 0) : val
@use_another_address_for_shipping = value
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clone_shipping_address\n if Spree::AddressBook::Config[:show_bill_address_on_cc_form] == false\n if self.ship_address\n self.bill_address = self.ship_address\n end\n else\n if self.bill_address_id == nil\n self.bill_address = self.ship_address\n end\n end\n true\n ... | [
"0.7160694",
"0.707022",
"0.7040528",
"0.69067323",
"0.68452656",
"0.6739886",
"0.668143",
"0.6675411",
"0.64960355",
"0.64960355",
"0.64561355",
"0.6442628",
"0.6440753",
"0.6406462",
"0.64005226",
"0.64005226",
"0.638846",
"0.6365498",
"0.63600713",
"0.6350871",
"0.6248851"... | 0.8390254 | 0 |
Set the shipping method id on the cart by creating the corresponding adjustment at the same time to ensure cart price and recap takes shipping costs into account | def shipping_method_id=(val)
@shipping_method_id = val
if shipping_method_id
adjustments.reject! { |a| a.type == "shipping-method" }
adjustment = Glysellin::Cart::Adjustment::ShippingMethod.new(self,
shipping_method_id: shipping_method_id
)
adjustments << adjustment
end
@shipping_method_id
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_shipping_method\n @shipping_method = ShippingMethod.find(params[:id])\n end",
"def shipping_method=(method)\n raise ArgumentError.new(\"method cannot be nil\") unless method.present?\n self.shipping_name = method.name\n self.shipping_cost = method.cost\n end",
"def set_shipmentmethod\... | [
"0.7311231",
"0.69348556",
"0.6675137",
"0.65214896",
"0.64189833",
"0.6386776",
"0.63038546",
"0.6272877",
"0.62681246",
"0.6259641",
"0.6211111",
"0.6166128",
"0.6083758",
"0.6027638",
"0.60275894",
"0.601285",
"0.59340817",
"0.5926229",
"0.59045064",
"0.5890188",
"0.583392... | 0.8019703 | 0 |
Shortcut method to get shipping adjustments from adjustments list | def shipping
adjustments.find { |a| a.type == "shipping-method" }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def price_adjustments\n adjustments = []\n\n line_items.each do |line_item|\n adjustments.concat (line_item.adjustments - line_item.adjustments.gift_packaging)\n end\n\n adjustments\n end",
"def update_adjustments\n self.adjustments.reload.each do |adjustment|\n if adjustment.orig... | [
"0.68257123",
"0.6116949",
"0.595517",
"0.57656324",
"0.57333547",
"0.57320666",
"0.5691638",
"0.559194",
"0.5571389",
"0.5571389",
"0.5569709",
"0.55529946",
"0.55518365",
"0.55427825",
"0.5446775",
"0.54047704",
"0.54012316",
"0.53729624",
"0.536094",
"0.5332664",
"0.533144... | 0.73404694 | 0 |
Validates customer informations are correctly filled | def validate_customer_informations
validate_nested_resource(:customer)
validate_nested_resource(:billing_address)
if use_another_address_for_shipping
validate_nested_resource(:shipping_address)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate_pos_invoice\n if self.customer_id && !self.pos_invoice_addresses\n raise_error('Billing address Required!!!!')\n end\nend",
"def validate_billing_info\n errors = super.merge(validate_required(posted, ['password']))\n errors['password'] ||= error_for_passwords(posted['password'], p... | [
"0.6997937",
"0.6833675",
"0.6657448",
"0.65981555",
"0.640802",
"0.63878965",
"0.6309316",
"0.62906444",
"0.62375975",
"0.6229901",
"0.6203611",
"0.62035406",
"0.61952627",
"0.6194715",
"0.61937976",
"0.6193378",
"0.6192048",
"0.6161645",
"0.61593807",
"0.6143251",
"0.613239... | 0.73036194 | 0 |
Validates the selected country is eligible for the current cart contents to be shipped to | def validate_shippable
if !shipping || !shipping.valid
code = use_another_address_for_shipping ?
shipping_address.country : billing_address.country
country = Glysellin::Helpers::Countries::COUNTRIES_LIST[code]
errors.add(
:shipping_method_id,
I18n.t(
"glysellin.errors.cart.shipping_method_unavailable_for_country",
method: shipping_method.name,
country: country
)
)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new3 \n @order = Order.find( :first,\n :conditions => [\"user_id = ? and status = ? and id = ?\", self.current_user.id, \"incomplete\", params[:id]])\n begin\n @country = params[:order][:user_country]\n @order.step = \"step3\"\n logger.info(@country)\n #How ma... | [
"0.6430206",
"0.63863885",
"0.6351647",
"0.61710215",
"0.6063709",
"0.6032792",
"0.601626",
"0.6011317",
"0.60096824",
"0.59700227",
"0.59072745",
"0.5896389",
"0.5879385",
"0.58095425",
"0.5784177",
"0.5767197",
"0.57669985",
"0.57496136",
"0.5741747",
"0.57321084",
"0.57046... | 0.709786 | 0 |
Order management Generates an order from the current cart state and stores its id in the cart to be fetched back later | def generate_order
clean_order!
attrs = attributes(:json).reject do |key, _|
[:adjustments, :state, :order_id, :shipping_method_id].include?(key)
end
%w(billing shipping).each do |addr|
attrs[:"#{ addr }_address_attributes"] =
attrs.delete(:"#{ addr }_address")
end
unless use_another_address_for_shipping
attrs[:shipping_address_attributes] =
attrs[:billing_address_attributes]
end
# Append shipping method id after addresses so the latters are present
# when shipping adjustment is processed on order
attrs[:shipping_method_id] = shipping_method_id
attrs[:discount_code] = discount_code
self.order = Glysellin::Order.create!(attrs)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @order = Order.new(params[:order])\n @order.user_id = current_user.id\n @order.add_line_items_from_cart(current_cart)\n #logger.debug \"New order: #{@order.attributes.inspect}\"\n #logger.debug \"Order should be valid: #{@order.valid?}\"\n\n respond_to do |format|\n if @order.sa... | [
"0.7156335",
"0.7149351",
"0.7116741",
"0.705756",
"0.70562285",
"0.70512074",
"0.70152026",
"0.7002662",
"0.699866",
"0.69817525",
"0.6954266",
"0.69529325",
"0.6925748",
"0.6883563",
"0.686639",
"0.686195",
"0.6856604",
"0.68191713",
"0.68070155",
"0.68064046",
"0.67997366"... | 0.6939319 | 12 |
Retrieve order from database if it exists, or use cached version | def order
@order ||= Glysellin::Order.where(id: order_id).first
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_reusable_order\n return # FIXME: currently it may return address which is being used by other active order\n expired_orders = find_expired_orders_row\n if expired_orders.size >= Config.reuse_address_orders_threshold &&\n fetch_transactions_for(expired_orders.last.address).empty?\n ... | [
"0.6614834",
"0.65239745",
"0.6267619",
"0.6260162",
"0.6260162",
"0.62495434",
"0.62246215",
"0.6205484",
"0.6169941",
"0.6156872",
"0.5986064",
"0.59423125",
"0.59379375",
"0.5934422",
"0.5932394",
"0.5884787",
"0.5870997",
"0.5867054",
"0.5844494",
"0.5812997",
"0.5798022"... | 0.6616279 | 0 |
Assign order and order_id, if nil is explicitly passed, ensure we set order id to nil too | def order=(order)
self.order_id = order && order.id
@order = order
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_order\n if params[:customer_id].nil?\n @customer=nil\n else\n @customer=Customer.find(params[:customer_id])\n end\n @order = Order.find(params[:id])\n end",
"def set_transaction_order\n\n # if params[:order_id].nil?\n # @transaction_order = TransactionOr... | [
"0.72710454",
"0.70966864",
"0.7045644",
"0.7045644",
"0.6994384",
"0.696573",
"0.6947896",
"0.6939692",
"0.6892608",
"0.68920845",
"0.68920845",
"0.68920845",
"0.68920845",
"0.68920845",
"0.68920845",
"0.68920845",
"0.68920845",
"0.68920845",
"0.68920845",
"0.68920845",
"0.6... | 0.7348318 | 0 |
Cleans cart stored order if it exists | def clean_order!
if order
# Destroy current cart order if not paid already, cause
# we're creating a new one
order.destroy if order.state_name == :ready
# unset order
self.order = nil
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def shopping_cart_cleanup\n\n end",
"def remove!\n if order_item.destroy\n order_maker.handle_coupon!\n order_maker.destroy_empty_order!\n return_with(:success)\n else\n return_with(:error, error: order_maker.order_errors)\n end\n end",
"def empty_cart\n self... | [
"0.66634125",
"0.6385331",
"0.637041",
"0.6333764",
"0.6294137",
"0.6226806",
"0.6210823",
"0.6205874",
"0.6202296",
"0.6192225",
"0.6157101",
"0.6145244",
"0.6136879",
"0.6035419",
"0.6035146",
"0.6029133",
"0.6014464",
"0.59497297",
"0.5945101",
"0.59246194",
"0.5895154",
... | 0.7631401 | 0 |
a random timeout in range range between the min timeout and twice that | def random_timeout
@IS_TIMEOUT_RANDOM ? @MIN_TIMEOUT + rand(@MIN_TIMEOUT) : @MIN_TIMEOUT
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def random_spawn_countdown minimum\n 10.randomize(:ratio, :sign).to_i + 60\n end",
"def random_duration\n min_duration + rand(max_duration - min_duration + 1)\n end",
"def sleep_time(attempt)\n 1 + (2**attempt) + rand(2**attempt)\n end",
"def sleep_time(attempt)\n 1 + (2**attem... | [
"0.78033787",
"0.73239774",
"0.72195065",
"0.71458316",
"0.70204043",
"0.690771",
"0.6897245",
"0.68336684",
"0.6808144",
"0.6771992",
"0.670791",
"0.6695353",
"0.661104",
"0.6572053",
"0.6572053",
"0.656234",
"0.6558265",
"0.6538337",
"0.6526226",
"0.6515465",
"0.64321285",
... | 0.84588003 | 0 |
Store the result of a call to this method in a wellnamed variable. | def add_all_numbers(array)
array.inject(:+)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def store_result(result); end",
"def store_result()\n #This is a stub, used for indexing\n end",
"def result\n @@result\n end",
"def use_result\n store_result\n end",
"def result\n @result\n end",
"def result \n @result\n end",
"def result\n @result ||= ca... | [
"0.72776747",
"0.72734886",
"0.71498",
"0.69414014",
"0.6851137",
"0.6845181",
"0.6659066",
"0.6609834",
"0.65169895",
"0.64686984",
"0.6456065",
"0.644434",
"0.6433526",
"0.63321227",
"0.62526274",
"0.6168087",
"0.61555797",
"0.61484444",
"0.61484444",
"0.6140094",
"0.613790... | 0.0 | -1 |
GET /micgroposts/1 GET /micgroposts/1.xml | def show
@micgropost = Micgropost.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @micgropost }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list_posts(api_object)\r\n puts \"Current Post:\"\r\n doc = Nokogiri::XML.parse api_object.read\r\n contents= doc.xpath('posts/post/content').collect {|e| e.text }\r\n puts contents.join(\", \")\r\n puts \"\"\r\nend",
"def rss\n @events = Post.find(:all, {:conditions=> \"status=public\"},:order => \"... | [
"0.64805603",
"0.6318034",
"0.610561",
"0.6098771",
"0.6098771",
"0.6064818",
"0.60271066",
"0.5996181",
"0.5965618",
"0.5929459",
"0.5924352",
"0.59225595",
"0.59167206",
"0.59113735",
"0.5907472",
"0.5889489",
"0.5881653",
"0.58808565",
"0.5875829",
"0.586296",
"0.58510685"... | 0.67286974 | 0 |
GET /micgroposts/new GET /micgroposts/new.xml | def new
@micgropost = Micgropost.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @micgropost }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @post = Post.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post }\n end\n make_rss\n end",
"def new\n \n @post = Post.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post }\n... | [
"0.76479656",
"0.72440803",
"0.72060794",
"0.7205934",
"0.7177021",
"0.7155967",
"0.7155967",
"0.7155967",
"0.7155967",
"0.7155967",
"0.7155967",
"0.7155967",
"0.7155967",
"0.7155967",
"0.7155967",
"0.7155967",
"0.7155967",
"0.7155967",
"0.7155967",
"0.7155967",
"0.7155967",
... | 0.7325873 | 1 |
POST /micgroposts POST /micgroposts.xml | def create
@micgropost = Micgropost.new(params[:micgropost])
respond_to do |format|
if @micgropost.save
format.html { redirect_to(@micgropost, :notice => 'Micgropost was successfully created.') }
format.xml { render :xml => @micgropost, :status => :created, :location => @micgropost }
else
format.html { render :action => "new" }
format.xml { render :xml => @micgropost.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def post(xmldoc)\n headers = {'Content-Type' => 'text/xml'}\n check_response( @httpcli.post(@endpoint, xmldoc, headers) )\n end",
"def post(uri, xml)\r\n req = Net::HTTP::Post.new(uri)\r\n req[\"content-type\"] = \"application/xml\"\r\n req.body = xml\r\n request(req)\r\n end",
"d... | [
"0.6155047",
"0.59201044",
"0.5782277",
"0.57359266",
"0.5703269",
"0.56660265",
"0.5655883",
"0.5655153",
"0.5654222",
"0.5651607",
"0.5647657",
"0.56224954",
"0.5619249",
"0.560516",
"0.56026596",
"0.55709404",
"0.554982",
"0.55453354",
"0.5538349",
"0.5529064",
"0.552828",... | 0.6498641 | 0 |
PUT /micgroposts/1 PUT /micgroposts/1.xml | def update
@micgropost = Micgropost.find(params[:id])
respond_to do |format|
if @micgropost.update_attributes(params[:micgropost])
format.html { redirect_to(@micgropost, :notice => 'Micgropost was successfully updated.') }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @micgropost.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def put(uri, xml)\r\n req = Net::HTTP::Put.new(uri)\r\n req[\"content-type\"] = \"application/xml\"\r\n req.body = xml\r\n request(req)\r\n end",
"def update opts = {}\n opts[:headers] ||= {}\n opts[:headers]['Content-Type'] ||= 'text/xml'\n post 'update', opts\n end",
"def res... | [
"0.65979344",
"0.6386905",
"0.5944032",
"0.5832561",
"0.5784904",
"0.57095796",
"0.5648733",
"0.5559411",
"0.55315036",
"0.5522774",
"0.5519452",
"0.5389559",
"0.53839856",
"0.53803235",
"0.53702414",
"0.5341423",
"0.5325147",
"0.52990663",
"0.5298956",
"0.5296068",
"0.529569... | 0.6216489 | 2 |
DELETE /micgroposts/1 DELETE /micgroposts/1.xml | def destroy
@micgropost = Micgropost.find(params[:id])
@micgropost.destroy
respond_to do |format|
format.html { redirect_to(micgroposts_url) }
format.xml { head :ok }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n RestClient.delete \"#{REST_API_URI}/contents/#{id}.xml\" \n self\n end",
"def delete()\n response = send_post_request(@xml_api_delete_path)\n response.is_a?(Net::HTTPSuccess) or response.is_a?(Net::HTTPRedirection)\n end",
"def destroy\n @post = Post.find(params[:id])\n ... | [
"0.7028965",
"0.66621494",
"0.6616252",
"0.65773576",
"0.6575671",
"0.6520314",
"0.6482652",
"0.6482505",
"0.644823",
"0.63628",
"0.6312437",
"0.6298924",
"0.6296919",
"0.6296919",
"0.6296785",
"0.6293241",
"0.62746847",
"0.62592196",
"0.6258334",
"0.6256671",
"0.6255685",
... | 0.72923744 | 0 |
puts str.ljust linewidth + str.rjust linewidth | def remember(&a_block)
@block = a_block
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ljust(p0, padstr=\"\") end",
"def ljust(width, padstr = \" \") # from Rubinius\n justified = dup\n justified.justify(width, :left, padstr)\n end",
"def rjust(p0, padstr=\"\") end",
"def rjust(label)\n label = label.to_s\n if label.size > 20\n \"#{label}\\n#{' ' * 20}\"... | [
"0.7495089",
"0.7381788",
"0.7337256",
"0.7309876",
"0.7139323",
"0.70947397",
"0.69415736",
"0.69296736",
"0.692405",
"0.68075776",
"0.67884874",
"0.6783697",
"0.67781276",
"0.67634505",
"0.6727334",
"0.67118645",
"0.6709737",
"0.67047983",
"0.66916734",
"0.66885495",
"0.668... | 0.0 | -1 |
=> "Hello, Jon!" currying: create a more specific version of a generalized function | def div_gen(x)
return lambda {|y| return y/x}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def friendly_parrot (name, age)\n \"You are called #{name} and you are #{age}\"\nend",
"def greeter(name)\n return \"hello \" + name + \" its nice to see you.\"\nend",
"def greet(folks); \"Hi, #{folks}!\"; end",
"def greet(person)\n \"Hello, #{person}!\"\nend",
"def greet(name)\n \"Hello #{name.capit... | [
"0.639262",
"0.6346197",
"0.63045764",
"0.6295016",
"0.62318534",
"0.62318534",
"0.62265164",
"0.6224741",
"0.6180392",
"0.61452633",
"0.6131682",
"0.6131682",
"0.6124345",
"0.6120646",
"0.6108782",
"0.6095991",
"0.6083754",
"0.6067132",
"0.6065615",
"0.60551375",
"0.6052666"... | 0.0 | -1 |
the notions of an anonymous function (lambda), first class function and closure revolve around an unique capability of a functional programming language: that of dynamic code generation. a language supports first class functions if it has the builtin capabilities to construct a function dynamically, store it in memory, pass it as an argument to another function and return it as a value from a function. all of the above capabilities are natively available in a moduler programming language like C, via the use of a 'function pointer' or 'function reference'; except that of construction of a function dynamically. support for a first class function is usually built on top of the following builtin primitives of a functional programming language: 1. anonymous function aka a function literal 2. a closure which is an enclosed function object, which contains the function text and the storage for the private state the body of the function has references to. a closure may be viewed as a specific instance of a generic (parameterized) function, with the values of the parameters fully specified. parameters refer to the private state of the function. 3. an operator to construct a closure from an anonymous function (lambda is viewed both as an operator to construct a closure as well as the anonymous function itself) 4. a function variable aka a variable which holds a reference to a closure a language with first class functions offer a distinct way of 1. designing software and 2. expressing a program though they have the exactly same overall capability as that of a moduler programming language like C. i.e. anything that can be achieved using first class functions can be achieved using a moduler programming language, and vice versa, albeit the design and look and feel of the code will be different. why is this interesting? in web programming, a server often generates code which is sent to the client side and client executes the code. this is considered better than client invoking an API function on the server side over a remote procedule call mechanics, since it avoids the compatibility issue between the client and the server. so a language with built in support for code generation fits more naturally into this requirement. without this support, the server side program will use of the following: 1. code templates which are viewed as texts. these don't benefit from compilation / syntax check / other code analysis tooling. 2. server side program generates a call to a generic API function, where the generic function resides on server side. the code snippet sent to client essentially calls the generic server side function with specific parameters. this can lead to greater network traffic and loss of efficiency and reliability. 3. the server side may send the code for the generic function along with the private state such that the client invokes a specific instance of the generic function. this is what is made implicit and done automatically by a language which supports first class functions. deaf grandma program | def yell(words)
return lambda {puts words.upcase}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def lambda; end",
"def compile_lambda(scope, args, body)\n compile_defun(scope, @e.get_local, args,body)\n end",
"def lambda_demo(a_lambda)\n puts \"I'm the method!\"\n a_lambda.call\nend",
"def lambda_demo(a_lambda)\n puts \"I'm the method!\"\n a_lambda.call\nend",
"def lambda_demo(a_lambda)\n pu... | [
"0.6354189",
"0.6065641",
"0.5721369",
"0.5721369",
"0.5721369",
"0.5705837",
"0.5681615",
"0.5620382",
"0.55595595",
"0.5537422",
"0.54664105",
"0.546107",
"0.5458064",
"0.5449111",
"0.5443965",
"0.54267263",
"0.54267263",
"0.5374135",
"0.5336062",
"0.5336062",
"0.5336062",
... | 0.0 | -1 |
euler020 6/22/12 Find the sum of the digits in the number 100! ============================================================================ | def euler020
def fact(x)
ans = x.downto(1).reduce(:*)
end
fact(100).to_s.split('').map { |x| x.to_i}.reduce(:+)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def euler_sum \n\tnums = (1...999).select { |n| n % 3 === 0 || n % 5 === 0 }\n\n\tnum_sum = nums.inject(0) {|s, n| s += n }\nend",
"def euler_sum\n sum = (0..999).select {|n| n%3==0 || n%5==0}.inject(0) {|s,n| s+=n}\n sum\nend",
"def euler016\n (2 ** 1000).to_s.split('').map { |x| x.to_i }.reduce(:+)\nend",
... | [
"0.720517",
"0.71016836",
"0.70384014",
"0.7019401",
"0.70184284",
"0.7007637",
"0.7004722",
"0.692449",
"0.6918288",
"0.69061327",
"0.68916255",
"0.6877606",
"0.6876679",
"0.6847596",
"0.6837302",
"0.68242794",
"0.6805717",
"0.6804139",
"0.67985547",
"0.6796361",
"0.6770783"... | 0.7129993 | 1 |
inside the function the variable is temoporary, when you return it then it can be assigned to a variable for lateer | def secret_formula(started)
jelly_beans = started * 500
jars = jelly_beans / 1000
crates = jars / 100
return jelly_beans, jars, crates
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def variable; end",
"def variable; end",
"def get_it\n @myvar\n end",
"def return_a_value\n name = \"Austin\"\n return name\n name = \"Brian\"\nend",
"def create_var \n b = 12\n return b \n end",
"def l_variable (str)\nb = str\n\nend",
"def main_variable ; end",
"def result=(_); e... | [
"0.6768195",
"0.6768195",
"0.67202",
"0.6718758",
"0.67071587",
"0.66429394",
"0.6627469",
"0.65924567",
"0.6552105",
"0.6520936",
"0.6464326",
"0.64508367",
"0.6390428",
"0.62934333",
"0.6234716",
"0.6216517",
"0.61608136",
"0.61434084",
"0.6136857",
"0.6129941",
"0.61031073... | 0.0 | -1 |
TODO follow redirect to get live apple message | def not_registered
error_msg "Please validate your product's purchase date. Apple is unable to provide information about your service coverage."
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_app_links\n # https://developer.apple.com/library/ios/documentation/AppleApplications/Reference/SafariWebContent/PromotingAppswithAppBanners/PromotingAppswithAppBanners.html\n if element = @server.response.doc.at_xpath(\"//meta[@name='apple-itunes-app']\")\n result = element.attributes['conten... | [
"0.6168524",
"0.5863048",
"0.581914",
"0.580315",
"0.5654492",
"0.5644574",
"0.5558355",
"0.5549997",
"0.5535184",
"0.54709387",
"0.5455786",
"0.54317904",
"0.53893983",
"0.5368947",
"0.5346848",
"0.53368884",
"0.5334694",
"0.5332596",
"0.5328089",
"0.53263944",
"0.53177816",... | 0.0 | -1 |
endregion region Password reset | def send_password_reset
self.reset_token = Token.random
update_columns(reset_digest: Token.digest(reset_token), reset_sent_at: Time.zone.now)
UserMailer.password_reset(self).deliver_now
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def password_reset_request\n end",
"def reset_password(new_password, new_password_confirmation); end",
"def forgot_password\n\t\tend",
"def send_reset_password_instructions; end",
"def password_reset\n\t\tshepherd = Shepherd.first\n\t\tshepherd.reset_token = Shepherd.new_token\n ShepherdMailer.password... | [
"0.8061012",
"0.8041453",
"0.79405916",
"0.79004973",
"0.7897919",
"0.788152",
"0.78813016",
"0.78371173",
"0.7831085",
"0.78106433",
"0.7778985",
"0.7727934",
"0.7721441",
"0.76651764",
"0.76651764",
"0.7659376",
"0.76574594",
"0.76537377",
"0.7644679",
"0.7637372",
"0.76275... | 0.0 | -1 |
Right now the wording of this message is the same as for enrollment | def assessment_sms_weblink(patient)
if patient&.primary_telephone.blank?
add_fail_history_blank_field(patient, 'primary phone number')
return
end
if patient.blocked_sms
TwilioSender.handle_twilio_error_codes(patient, TwilioSender::TWILIO_ERROR_CODES[:blocked_number][:code])
return
end
# Cover potential race condition where multiple messages are sent for the same monitoree.
return unless patient.last_assessment_reminder_sent_eligible?
messages_array = []
sms_lang = patient.select_language(:sms)
web_lang = patient.select_language(:email)
patient.active_dependents.uniq.each do |dependent|
url = new_patient_assessment_jurisdiction_lang_initials_url(dependent.submission_token, dependent.jurisdiction.unique_identifier, web_lang&.to_s,
dependent&.initials_age)
contents = I18n.t('assessments.twilio.sms.weblink.intro', locale: sms_lang, initials_age: dependent&.initials_age('-'), url: url)
# Update last send attempt timestamp before Twilio call
patient.last_assessment_reminder_sent = DateTime.now
patient.save(touch: false)
threshold_hash = dependent.jurisdiction[:current_threshold_condition_hash]
message = { prompt: contents, patient_submission_token: dependent.submission_token,
threshold_hash: threshold_hash }
messages_array << message
end
patient.active_dependents_and_self.each { |pat| add_success_history(pat) } if TwilioSender.send_sms(patient, messages_array)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def message\n return MSG_NOT_ENROLLED unless enrolled?\n return MSG_FULL_ACCESS if registered?\n return MSG_LIMITED_ACCESS if twenty_percent_cnp_exception?\n MSG_FEES_UNPAID\n end",
"def meme_phrase; end",
"def whine msg\n logger.error(\"Synfeld laments: \" + m... | [
"0.6435627",
"0.6350415",
"0.62496716",
"0.6249376",
"0.62021154",
"0.6194348",
"0.6101234",
"0.60801",
"0.606815",
"0.6033377",
"0.5987189",
"0.5954343",
"0.5950888",
"0.5948497",
"0.59480274",
"0.5932388",
"0.5901886",
"0.5899486",
"0.58897847",
"0.5883906",
"0.587001",
"... | 0.0 | -1 |
This returns the API user being used for calls | def api_user
@user
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def user\n conf['api']['user']\n end",
"def current_user\r\n api_key = ApiKey.active.where(access_token: token).first\r\n if api_key\r\n return api_key.user\r\n else\r\n return nil\r\n end\r\n end",
"def user\n @user ||= @uri && client.user(@uri.split(':')[2])\n end",
"def ... | [
"0.79773635",
"0.76724285",
"0.76404595",
"0.76386076",
"0.7634918",
"0.76042706",
"0.7556157",
"0.7521312",
"0.74474907",
"0.72893983",
"0.72706825",
"0.7225416",
"0.7210287",
"0.7199154",
"0.7179509",
"0.7175929",
"0.71632904",
"0.7133719",
"0.7117078",
"0.7113061",
"0.7102... | 0.8331093 | 0 |
This returns the API key being used for calls | def api_key
@key
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def api_key\n key\n end",
"def me_api_key\n api_key = ApiKey.find(me.api_key_id) if auth?\n api_key.api_key || ''\n end",
"def api_key\n configuration.api_key\n end",
"def api_key\n config.api_key\n end",
"def api_key\n config.api_key\n end",
"def api_key\n @... | [
"0.8371249",
"0.83074266",
"0.81852305",
"0.8054933",
"0.8054933",
"0.8046503",
"0.8010114",
"0.7981128",
"0.7968959",
"0.7968959",
"0.79372025",
"0.7876118",
"0.7792502",
"0.77100605",
"0.77100605",
"0.76793605",
"0.7674456",
"0.7651613",
"0.7636844",
"0.757416",
"0.7506866"... | 0.83176166 | 1 |
This returns the API version being used for calls | def api_version
@version
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def api_version\n request('getAPIVersion')\n end",
"def version\n raise InvalidRequestException unless defined?(API_VERSION)\n API_VERSION\n end",
"def get_api_version()\n return API_VERSION\n end",
"def get_api_version\n _make_request(:types)['version'].to_s\n ... | [
"0.88588905",
"0.8724628",
"0.85719347",
"0.8535282",
"0.842111",
"0.83159876",
"0.8304739",
"0.82623535",
"0.8196698",
"0.81932366",
"0.81587267",
"0.8142436",
"0.81376165",
"0.8110708",
"0.8070393",
"0.79920065",
"0.79788274",
"0.7851303",
"0.7807265",
"0.7783084",
"0.77316... | 0.8421387 | 4 |
This returns whether or not we've been initialized yet | def initialized?
@initialized || false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialized?\n @initialized ||= false\n end",
"def initialized?\n @initialized ||= false\n end",
"def initialized?\n end",
"def initialized?\n !!@initialized\n end",
"def init?\n @init\n end",
"def initialized?\n !@data.nil?\n end",
"def init... | [
"0.8766324",
"0.8766324",
"0.86628884",
"0.8427186",
"0.8331638",
"0.82875085",
"0.8215806",
"0.81125915",
"0.80918264",
"0.80918264",
"0.7978551",
"0.7940297",
"0.77771693",
"0.7610409",
"0.75859493",
"0.75859493",
"0.75859493",
"0.75859493",
"0.7559332",
"0.7464577",
"0.732... | 0.8758801 | 2 |
This authenticates with Rackspace and returns the information necessary to make subsequent authenticated calls to the API | def authenticate
raise Rackspace::NotInitialized unless self.initialized?
headers = RestClient::Request.execute(:method => :get, :url => "#{AUTH_URL}/#{self.api_version}", :headers => {"X-Auth-User" => self.api_user, "X-Auth-Key" => self.api_key}, :raw_response => true).headers
{:auth_token => headers[:x_auth_token], :storage_url => headers[:x_storage_url], :server_management_url => headers[:x_server_management_url], :cdn_management_url => headers[:x_cdn_management_url]}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def authenticate\n # :x_amee_source = \"X-AMEE-Source\".to_sym\n request = Typhoeus::Request.new(\"#{protocol}#{@server}/auth/signIn\", \n :method => \"post\",\n :verbose => DEBUG,\n :headers => {\n :Accept => content_type(:xml),\n },\n :body => form_encode(:us... | [
"0.68515164",
"0.67352784",
"0.6707994",
"0.6640942",
"0.6632217",
"0.65311235",
"0.6514519",
"0.6512263",
"0.6510728",
"0.64858323",
"0.64855963",
"0.64813614",
"0.6442701",
"0.64391893",
"0.64357597",
"0.64333266",
"0.6425217",
"0.6417281",
"0.64149237",
"0.6414572",
"0.641... | 0.8480711 | 0 |
These are default headers we need to use on all requests | def default_headers
{:accept => "application/json", :content_type => "application/json"}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def default_headers\n {\n user_agent: \"Unloq ruby gem #{Unloq::VERSION}\"\n }\n end",
"def default_headers\n @default_headers ||= {}\n {\n 'user-agent' => 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.0.1) Gecko/2008070206 Firefox/3.0.1',\n 'accept' => 'text/... | [
"0.8268056",
"0.82457113",
"0.8192051",
"0.8154548",
"0.8131782",
"0.8094137",
"0.8090789",
"0.8024158",
"0.7980696",
"0.78547084",
"0.78031284",
"0.774329",
"0.77422446",
"0.7722451",
"0.7664412",
"0.7664412",
"0.7647234",
"0.7623513",
"0.76214886",
"0.76133907",
"0.75683606... | 0.80758214 | 7 |
This returns the available versions of the API | def versions
JSON.parse(RestClient.get("#{VERSION_URL}/.json", self.default_headers))["versions"].collect { |v| v["id"] }.uniq
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def available_versions\n raise \"available_versions API is only available for Artifactory backend.\"\n end",
"def versions\n info[:versions]\n end",
"def get_all_versions\n []\n end",
"def fetch_versions\n http_get(\"#{host}/#{Configuration.versions_file}\").body\n end",
... | [
"0.7911649",
"0.74483323",
"0.7420273",
"0.73977816",
"0.7392916",
"0.722803",
"0.72215706",
"0.7192871",
"0.7157209",
"0.71292275",
"0.7113218",
"0.70429564",
"0.7028521",
"0.7021907",
"0.7003831",
"0.6946998",
"0.6926113",
"0.6875869",
"0.68436795",
"0.6833199",
"0.6830812"... | 0.7814768 | 1 |
This caches the authentication response for subsequent usage | def auth_response
@auth_response ||= self.authenticate
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def authenticate!\n if !authenticated?\n response = request_token\n\n @token = response[\"token\"]\n @expires_at = DateTime.parse(response[\"expires_at\"])\n end\n\n [@token, @expires_at]\n end",
"def retry_with_auth(response)\n @already_tried_with_auth = true\n l... | [
"0.6387723",
"0.63305163",
"0.6312613",
"0.61748326",
"0.6147414",
"0.6122541",
"0.6114287",
"0.6111199",
"0.6104289",
"0.6092938",
"0.6068579",
"0.6054741",
"0.60148",
"0.600937",
"0.6008093",
"0.59659064",
"0.593324",
"0.5898481",
"0.5878535",
"0.5873972",
"0.5870065",
"0... | 0.7530714 | 0 |
This is the auth token provided by Rackspace after a successful authentication | def auth_token
self.auth_response[:auth_token]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def auth_token\n @@auth_token\n end",
"def auth_token\n @auth_token ||= request.headers.fetch('Authorization', '').split(' ').last\n end",
"def authentication_token\n generate_token(:authentication_token)\n end",
"def auth_token\n\t\trequest.headers['X-AUTH-TOKEN']\n\tend",
"def... | [
"0.7818504",
"0.7591694",
"0.75749207",
"0.7430305",
"0.73680997",
"0.73346734",
"0.7299858",
"0.72879374",
"0.72694427",
"0.7249586",
"0.72470814",
"0.7172336",
"0.7171656",
"0.7168374",
"0.71476907",
"0.71431357",
"0.714131",
"0.71393925",
"0.71087384",
"0.70409703",
"0.703... | 0.7663875 | 1 |
This returns the root URL for Cloud Files API queries (not yet implemented) | def storage_url
self.auth_response[:storage_url]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def url; \"file:#{@root}\"; end",
"def url\n host = @uploader.ucloud_cdn_host || @uploader.ucloud_bucket_host\n return nil unless host\n [host, @path].join(\"/\")\n end",
"def root_url\n '.'\n end",
"def directory_uri\n template = Addressable::Template.new(\n ... | [
"0.714462",
"0.686621",
"0.6836571",
"0.67245674",
"0.6688671",
"0.6663328",
"0.6582323",
"0.6576267",
"0.6560481",
"0.6519834",
"0.6501415",
"0.64614016",
"0.64230025",
"0.6402665",
"0.63983446",
"0.63536304",
"0.6327349",
"0.63083935",
"0.6307807",
"0.63065314",
"0.6289053"... | 0.0 | -1 |
This returns the root URL for Cloud Servers API queries | def server_management_url
self.auth_response[:server_management_url]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def root_url\n @response.env[:url].to_s if @response\n end",
"def root_url\n \"#{@env['rack.url_scheme']}://#{@env['HTTP_HOST']}\"\n end",
"def root_url\n '.'\n end",
"def base_url\n URI::HTTPS.build(host: @server, port: @port, path: @api)\n end",
"def api_root\n root_u... | [
"0.75165474",
"0.74742705",
"0.7467842",
"0.73292",
"0.72943676",
"0.725942",
"0.72557974",
"0.7066603",
"0.70543814",
"0.70543814",
"0.7001407",
"0.6977074",
"0.6972126",
"0.69707954",
"0.69157064",
"0.68690205",
"0.6844724",
"0.68437684",
"0.6837551",
"0.6837551",
"0.682113... | 0.0 | -1 |
This returns the root URL for CDN Cloud Files API queries (not yet implemented) | def cdn_management_url
self.auth_response[:cdn_management_url]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def url\n host = @uploader.ucloud_cdn_host || @uploader.ucloud_bucket_host\n return nil unless host\n [host, @path].join(\"/\")\n end",
"def url; \"file:#{@root}\"; end",
"def root_url\n '.'\n end",
"def url\n base = [FilestackConfig::CDN_URL]\n if @transform_t... | [
"0.7293536",
"0.6621153",
"0.6544243",
"0.6485726",
"0.64530295",
"0.64487547",
"0.6266853",
"0.62627476",
"0.62618876",
"0.6252516",
"0.6242374",
"0.62102807",
"0.6187452",
"0.61778116",
"0.61629",
"0.6151417",
"0.6140029",
"0.6137985",
"0.6112066",
"0.6063998",
"0.60424966"... | 0.5993882 | 23 |
This performs a basic GET request using the supplied URL and headers | def get(url, headers = {})
http :get, "#{url}.json", headers
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get(url, headers = {})\n do_request Net::HTTP::Get, url, headers\n end",
"def get(url, headers={})\n do_request(\"get\", url, nil, headers)\n end",
"def get(url, headers = {})\n request(:get, url, headers)\n end",
"def get(url, headers = {})\n request(:get, url, headers)\n end",
... | [
"0.85870266",
"0.85305065",
"0.83588445",
"0.83588445",
"0.8213956",
"0.7912093",
"0.79002655",
"0.7849229",
"0.7670843",
"0.76333576",
"0.76230216",
"0.761041",
"0.74752575",
"0.74572265",
"0.7432885",
"0.7385609",
"0.72676575",
"0.7248267",
"0.7227382",
"0.7164586",
"0.7144... | 0.7834818 | 8 |
This performs a basic POST request using the supplied URL, payload and headers | def post(url, payload = {}, headers = {})
http :post, "#{url}.json", payload.to_json, headers
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def post(url, payload, headers: {}, options: {})\n request_with_payload(:post, url, payload, headers, options)\n end",
"def post(url, payload, headers={})\n payload = MultiJson.encode(payload)\n headers = headers.merge({:content_type => 'application/json'})\n request(:post, url, payloa... | [
"0.84302634",
"0.80263704",
"0.7911639",
"0.77735686",
"0.7758614",
"0.7733568",
"0.7709064",
"0.73818666",
"0.73346424",
"0.7326004",
"0.7272792",
"0.72559726",
"0.7231427",
"0.7212969",
"0.7157233",
"0.71504617",
"0.70935875",
"0.70628935",
"0.7015264",
"0.70148796",
"0.698... | 0.8125234 | 1 |
This performs a basic PUT request using the supplied URL, payload and headers | def put(url, payload = {}, headers = {})
http :put, "#{url}.json", payload.to_json, headers
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def put(url, payload, headers: {}, options: {})\n request_with_payload(:put, url, payload, headers, options)\n end",
"def put(url, payload, headers={})\n RestClient.put url, payload, headers\n end",
"def put(url, payload, headers={})\n payload = MultiJson.encode(payload)\n ... | [
"0.86669135",
"0.8494346",
"0.84635204",
"0.8019125",
"0.7994147",
"0.7935481",
"0.7834837",
"0.7747173",
"0.7729944",
"0.7729944",
"0.7715607",
"0.7689188",
"0.76714534",
"0.7645712",
"0.76046675",
"0.759969",
"0.7553415",
"0.7545826",
"0.751816",
"0.7448072",
"0.74445117",
... | 0.86126524 | 1 |
This performs a basic DELETE request using the supplied URL and headers | def delete(url, headers = {})
http :delete, "#{url}.json", headers
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete(url, headers = {})\n request(:delete, url, headers)\n end",
"def delete(url, headers = {})\n request(:delete, url, headers)\n end",
"def delete(url, headers: {}, params: {}, options: {})\n url = encode_query(url, params)\n\n request = Net::HTTP::Delete.new(url, @default_headers... | [
"0.8734279",
"0.8734279",
"0.8568862",
"0.85250336",
"0.8518292",
"0.8287435",
"0.81405973",
"0.8140373",
"0.8117444",
"0.8078875",
"0.80540323",
"0.7873519",
"0.78500545",
"0.77670527",
"0.7726931",
"0.7718208",
"0.769285",
"0.76708657",
"0.76698923",
"0.7657206",
"0.7651639... | 0.845824 | 5 |
This will perform an HTTP call with the specified method, and arguments It will also pick up if the response is that the request was unauthorized, and will attempt the same request again after reauthenticating (in case the auth token has expired) | def http(method, *args)
args.last.merge!(self.default_headers).merge!("X-Auth-Token" => self.auth_token)
response = RestClient.send(method, *args)
@retried = false
response
rescue RestClient::Unauthorized
@auth_response = nil
if @retried
raise
else
@retried = true
retry
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def execute(method, path, **options)\n uri = URI(\"#{@base_url}/#{path}\")\n\n case method.to_sym\n when :get\n req = Net::HTTP::Get.new(uri)\n when :post\n req = Net::HTTP::Post.new(uri)\n when :put\n req = Net::HTTP::Put.new(uri)\n when :delete\n req = Net::HTTP::Delete.new(... | [
"0.7433135",
"0.71996975",
"0.7114339",
"0.69521403",
"0.6861476",
"0.6836841",
"0.6722458",
"0.6681006",
"0.6672767",
"0.66568345",
"0.66376173",
"0.6632255",
"0.6590535",
"0.6588767",
"0.6573776",
"0.65652335",
"0.6552048",
"0.6552048",
"0.6551272",
"0.6548551",
"0.6546658"... | 0.78931975 | 0 |
create command for add helm repository =============================================================== | def do_add_repo(repository,mirror_enabled,mirror_url,mirror_ca_cert)
name = repository['name']
url = repository['url']
if !mirror_enabled
cmd = "helm repo add #{name} #{url} "
else
if mirror_ca_cert == ""
cmd = "helm repo add #{name} #{mirror_url} "
else
cmd = "helm repo add --ca-file=/var/vcap/store/action/config/mirror_ca_cert.pem #{name} #{mirror_url} "
end
end
"#{cmd};helm repo update"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def install_command\n command = ['helm', 'upgrade', name, chart] +\n install_flag +\n reset_values_flag +\n optional_tls_flags +\n optional_version_flag +\n rbac_create_flag +\n namespace_flag +\n value_flag\n\n command.... | [
"0.6459812",
"0.6439818",
"0.6429886",
"0.62147754",
"0.6172976",
"0.60509694",
"0.6036178",
"0.6035579",
"0.5994835",
"0.5986173",
"0.5948862",
"0.5840109",
"0.58038956",
"0.57848525",
"0.5752091",
"0.5746584",
"0.5734534",
"0.5638456",
"0.5586727",
"0.5563567",
"0.5563039",... | 0.76771754 | 0 |
more tests more more mroe | def create
upload = Upload.find(params[:upload_id])
comment_params = Hash.new
comment_params[:upload_id] = params[:upload_id]
comment_params[:description] = params[:description]
comment_params[:user_id] = params[:user_id]
#comment params need to change to whatever we pass in the text box
comment = upload.comments.create(comment_params)
comment_params[:user_name] = User.find(params[:user_id]).email
if comment.save
# redirect_to main_path
respond_to do |format|
format.json { render json: comment_params}
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tests; end",
"def tests; end",
"def testing\n # ...\n end",
"def test_cases; end",
"def test \n end",
"def test\n\n end",
"def test_case; end",
"def my_tests\n end",
"def generate_alltest\n\n end",
"def test_method\n end",
"def test\n end",
"def test\n end",
... | [
"0.7541602",
"0.7541602",
"0.7440775",
"0.72041845",
"0.68698335",
"0.6840051",
"0.67955905",
"0.6787085",
"0.6777833",
"0.6738014",
"0.6735499",
"0.6735499",
"0.6735499",
"0.66692215",
"0.6647514",
"0.6634424",
"0.66192096",
"0.6598048",
"0.65607285",
"0.6555865",
"0.6555865... | 0.0 | -1 |
Register the global meter provider. | def meter_provider=(provider)
@mutex.synchronize do
if @meter_provider.instance_of? Internal::ProxyMeterProvider
logger.debug("Upgrading default proxy meter provider to #{provider.class}")
@meter_provider.delegate = provider
end
@meter_provider = provider
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def register_meter( name )\n @metrics.meter( name )\n end",
"def register_gauge(type, &block)\n register_metric( Drone::Metrics::Gauge.new(type, &block) )\n end",
"def initialize(...)\n @metrics = {}\n register(...)\n end",
"def register_metric(metric)\n @metrics <... | [
"0.70266426",
"0.6072285",
"0.59438455",
"0.57787174",
"0.5660892",
"0.56036025",
"0.55297095",
"0.5477177",
"0.539635",
"0.5387235",
"0.53433156",
"0.5310754",
"0.5310754",
"0.5224658",
"0.5131831",
"0.51292706",
"0.5122979",
"0.51195997",
"0.50732994",
"0.50732994",
"0.5073... | 0.6006363 | 2 |
Use callbacks to share common setup or constraints between actions. | def set_property_image
@property_image = PropertyImage.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576"... | 0.0 | -1 |
Only allow a trusted parameter "white list" through. | def property_image_params
params.require(:property_image).permit(:image_url, :property_id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allowed_params\n ALLOWED_PARAMS\n end",
"def expected_permitted_parameter_names; end",
"def param_whitelist\n [:role, :title]\n end",
"def default_param_whitelist\n [\"mode\"]\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def permitted_params\n []\n end",
... | [
"0.7121987",
"0.70541996",
"0.69483954",
"0.6902367",
"0.6733912",
"0.6717838",
"0.6687021",
"0.6676254",
"0.66612333",
"0.6555296",
"0.6527056",
"0.6456324",
"0.6450841",
"0.6450127",
"0.6447226",
"0.6434961",
"0.64121825",
"0.64121825",
"0.63913447",
"0.63804525",
"0.638045... | 0.0 | -1 |
note An instance of `Gitlab::GithubImport::Representation::Note`. project An instance of `Project`. client An instance of `Gitlab::GithubImport::Client`. | def initialize(note, project, client)
@note = note
@project = project
@client = client
@user_finder = GithubImport::UserFinder.new(project, client)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_project_note\n @project_note = ProjectNote.find(params[:id])\n end",
"def note(note)\n\t\t@note = note\n\tend",
"def create\n @project_note = ProjectNote.new(project_note_params(params[:project_note]))\n\n if @project_note.save\n render json: @project_note, status: :created, location... | [
"0.6556374",
"0.6367514",
"0.61506945",
"0.6062631",
"0.60564697",
"0.6053366",
"0.599303",
"0.59807014",
"0.58403254",
"0.58266973",
"0.58240813",
"0.5815559",
"0.5804585",
"0.5754971",
"0.56971043",
"0.5668589",
"0.5639272",
"0.56191605",
"0.56188077",
"0.5612311",
"0.56039... | 0.6835686 | 1 |
Returns the ID of the issue or merge request to create the note for. | def find_noteable_id
GithubImport::IssuableFinder.new(project, note).database_id
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def changelog_notes_id\n IssueCustomField.find_by_name('Changelog Note').id\n end",
"def find_merge_request_id\n GithubImport::IssuableFinder.new(project, note).database_id\n end",
"def identifier\n issue.identifier\n end",
"def create_note(issue)\n Note.create_status_change_note(i... | [
"0.6557007",
"0.649947",
"0.64493304",
"0.62286705",
"0.612455",
"0.59475327",
"0.5878396",
"0.5841053",
"0.5829433",
"0.58254474",
"0.5776873",
"0.577545",
"0.5731897",
"0.57104117",
"0.57104117",
"0.5702355",
"0.5678286",
"0.5662933",
"0.5662676",
"0.5642341",
"0.5630811",
... | 0.6480564 | 2 |
end of user input | def drink_list #makes the menu
Recipe.all.each.with_index(1) do |x, index|
puts "#{index} #{x.drink_name}"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def end_input\n\t\tinput = nil\n\t\tuntil input != nil\n\t\t\tinput = case gets.chomp.downcase\n\t\t\twhen \"yes\", \"y\" then \"yes\"\n\t\t\twhen \"no\", \"n\" then \"no\"\n\t\t\telse nil\n\t\t\tend\n\t\t\tputs \"That's not a valid option!\" if not input\n\t\tend\n\t\tinput\n\tend",
"def get_user_input\n\t\tput... | [
"0.7340667",
"0.68995893",
"0.6695416",
"0.66071856",
"0.6603539",
"0.65339696",
"0.64594275",
"0.64234143",
"0.64234143",
"0.64234143",
"0.63956654",
"0.63715553",
"0.6365442",
"0.63601655",
"0.63601655",
"0.63382107",
"0.63325155",
"0.6327132",
"0.63222057",
"0.63133043",
"... | 0.0 | -1 |
end setup to_s should return a string representation of the graph in the dot language. most of whats added to the graph will translate to something than is in this... | def test_graph_to_s
sut_graph = Graph.new
sut_graph.name="test_graph"
sut_graph.type=:digraph
sut_graph.node_style=:ellipse
#sut_graph.add_node "TEST1"
#sut_graph.add_node "TEST2"
sut_graph.add_edge("TEST1" , "TEST2" , "take_me_to_test_2")
returned_obj = sut_graph.to_s
assert( returned_obj.instance_of?(String) , "Check to_s returns String, returns: #{returned_obj.class}" )
assert(returned_obj.scan(/test_graph/).length==1 , "Check once occurence of graph name in dot to_s.")
assert(returned_obj.scan(/digraph test_graph/).length==1 , "Check graph type and name in dot to_s.")
assert(returned_obj.scan(/shape = ellipse/).length==1 , "Check graph node style in dot to_s.")
#assert(returned_obj.scan(/TEST1\;/).length==1 , "Check that Node definition is included: TEST1;")
#assert(returned_obj.scan(/TEST2\;/).length==1 , "Check that Node definition is included: TEST2}")
assert(returned_obj.scan(/label = \"take_me_to_test_2"/).length==1 , "Check that arc label is included")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_dot (params={}) to_dot_graph(params).to_s; end",
"def to_dot (params={}) to_dot_graph(params).to_s; end",
"def graph_to_s\n string = \"\"\n @nodes.each do |name, node|\n string +=\"#{name}:\\n\\t(#{node.name}, #{node.country}, #{node.continent} #{node.timezone}, #{node.coords}, ... | [
"0.7962001",
"0.7962001",
"0.76369226",
"0.72473687",
"0.7166967",
"0.7156966",
"0.6953944",
"0.6791427",
"0.67006135",
"0.66608757",
"0.66547245",
"0.657938",
"0.65760434",
"0.65679413",
"0.6555326",
"0.65237045",
"0.65188",
"0.65093064",
"0.6476672",
"0.6450198",
"0.6442195... | 0.68478245 | 7 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.