query stringlengths 7 6.41k | document stringlengths 12 28.8k | metadata dict | negatives listlengths 30 30 | negative_scores listlengths 30 30 | document_score stringlengths 5 10 | document_rank stringclasses 2
values |
|---|---|---|---|---|---|---|
PUT /commodities/1 PUT /commodities/1.json | def update
@commodity = Commodity.find(params[:id])
respond_to do |format|
if @commodity.update_attributes(commodity_params)
format.html { redirect_to commodities_url, notice: 'Commodity was successfully updated.' }
format.json { head :no_content }
else
format.html { render ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @commodity = Commodity.find(params[:id])\n\n respond_to do |format|\n if @commodity.update_attributes(params[:commodity])\n format.html { redirect_to @commodity, notice: 'Commodity was successfully updated.' }\n format.json { head :no_content }\n else\n format.html... | [
"0.698199",
"0.6865258",
"0.6549405",
"0.625449",
"0.61144966",
"0.6061187",
"0.6029585",
"0.59958655",
"0.5914688",
"0.5914688",
"0.5864249",
"0.57738084",
"0.5706487",
"0.569667",
"0.5666119",
"0.56512976",
"0.56425893",
"0.56246763",
"0.56246763",
"0.5579705",
"0.5577149",... | 0.6982537 | 0 |
DELETE /commodities/1 DELETE /commodities/1.json | def destroy
@commodity = Commodity.find(params[:id])
@commodity.destroy
respond_to do |format|
format.html { redirect_to commodities_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @commodity.destroy\n respond_to do |format|\n format.html { redirect_to commodities_url, flash: {success: '操作成功.' } }\n format.json { head :no_content }\n end\n end",
"def destroy\n @commodity = Commodity.find(params[:id])\n @commodity.num = 0\n\n respond_to do |format|... | [
"0.73369837",
"0.70824623",
"0.68722385",
"0.67435133",
"0.6578203",
"0.655855",
"0.6527886",
"0.6525086",
"0.651146",
"0.65054107",
"0.6503747",
"0.64894783",
"0.6469133",
"0.64428556",
"0.6442285",
"0.643782",
"0.64324564",
"0.6415179",
"0.6380721",
"0.6375529",
"0.637437",... | 0.7840331 | 1 |
The definition of the ranks for this board. By default it will be files 1 .. 8. You can change this by initializing the board with a different range. | def ranks
Outpost::Config.instance.ranks
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ranks\n @ranks ||= RANK_RANGE.map(&:to_i)\n end",
"def rank=(value)\n @rank = value\n end",
"def ranked_board\n # pre-process to remove sunken ships\n string = remove_sunken_ships board_to_string\n self.board = string_to_board(string)\n set_base_ran... | [
"0.7753274",
"0.64954853",
"0.6490504",
"0.6442089",
"0.64249766",
"0.64249766",
"0.6338014",
"0.6267029",
"0.62390393",
"0.6190477",
"0.6189208",
"0.61687887",
"0.61215717",
"0.6021965",
"0.60004365",
"0.5976181",
"0.5976181",
"0.59745973",
"0.59647113",
"0.5960863",
"0.5947... | 0.7009478 | 1 |
This helper will give you a way to cycle the colors | def cycled_colors
@cycled_colors ||= colors.cycle
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cycle colors=[], delay=0.5\n unless colors.all? {|c| COLORS.include? c}\n raise \"Invalid color\"\n end\n\n reset\n\n @thread = Thread.new do\n i = 0\n loop do\n set_color_raw colors[i]\n i = (i+1) % colors.length\n sleep delay\n end\n ... | [
"0.76274145",
"0.71802366",
"0.71802366",
"0.69707036",
"0.6750518",
"0.6687178",
"0.66343486",
"0.66284937",
"0.6518931",
"0.6429232",
"0.6398278",
"0.63675666",
"0.63319075",
"0.625633",
"0.62457186",
"0.6207914",
"0.6201747",
"0.61980814",
"0.61974007",
"0.61866844",
"0.61... | 0.77058166 | 0 |
Parse the JSON from all VMs and templates. Then return an array of objects (without duplicates) | def read_vms_info
vms_arr = json([]) do
execute_prlctl('list', '--all','--info', '--json')
end
templates_arr = json([]) do
execute_prlctl('list', '--all','--info', '--json', '--template')
end
vms_arr | templates_arr
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_vms\n args = %w[list --all --no-header --json -o name,uuid]\n vms_arr = json { execute_prlctl(*args) }\n templates_arr = json { execute_prlctl(*args, '--template') }\n\n vms = vms_arr | templates_arr\n Hash[vms.map { |i| [i.fetch('name'), i.fetch('uuid')] }]\n ... | [
"0.71686256",
"0.6681401",
"0.5961826",
"0.59298587",
"0.5920288",
"0.58270335",
"0.56836045",
"0.56644773",
"0.56527555",
"0.548605",
"0.5467821",
"0.5452085",
"0.54150885",
"0.53878874",
"0.5383206",
"0.5383206",
"0.53668404",
"0.5338923",
"0.53160316",
"0.52626276",
"0.520... | 0.6927358 | 1 |
GET /videos/list GET /videos/list.json | def list
@videos = Video.all
respond_to do |format|
format.html # list.html.erb
format.json { render json: @videos }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def videos options={}\n response = client.get(\"/#{id}/videos\", options)\n end",
"def index\n @videos = Video.all\n render json: @videos\n end",
"def video_list(login = nil, authenticated = false, page=1)\n result = []\n response = nil\n if authenticated\n response = auth_... | [
"0.8083367",
"0.7769143",
"0.7755607",
"0.7634245",
"0.763365",
"0.763365",
"0.763365",
"0.763365",
"0.76053154",
"0.7463178",
"0.7461059",
"0.7452215",
"0.7430447",
"0.73788255",
"0.7368817",
"0.7312249",
"0.7265401",
"0.7265401",
"0.7265401",
"0.7265401",
"0.7265401",
"0.... | 0.842482 | 0 |
source can take any of the following as arguments A single string argument Multiple string arguments An array or strings A delayed evaluator that evaluates to a string or array of strings All strings must be parsable as URIs. source returns an array of strings. | def source(*args)
arg = parse_source_args(args)
ret = set_or_return(:source,
arg,
{ callbacks: {
validate_source: method(:validate_source),
} })
if ret.is_a? String
Array(ret)
else
ret
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def source(*args)\n arg = parse_source_args(args)\n ret = set_or_return(:source,\n arg,\n { :callbacks => {\n :validate_source => method(:validate_source),\n } })\n if ret.is_a? St... | [
"0.791088",
"0.6675598",
"0.6345544",
"0.6165359",
"0.60313857",
"0.6004425",
"0.59468085",
"0.59468085",
"0.59468085",
"0.59468085",
"0.59468085",
"0.58789057",
"0.58679634",
"0.58420074",
"0.5757213",
"0.5739514",
"0.5690611",
"0.56784505",
"0.56784505",
"0.5676527",
"0.565... | 0.7801762 | 1 |
Disable or enable ETag and Last Modified conditional GET. Equivalent to use_etag(true_or_false) use_last_modified(true_or_false) | def use_conditional_get(true_or_false)
use_etag(true_or_false)
use_last_modified(true_or_false)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get(path, headers = {})\n cached_response = fetch_cached_response(path)\n if cached_response\n headers = headers.merge 'If-None-Match' => cached_response['Etag']\n end\n response = super(path, headers)\n case response\n when Net::HTTPNotModified then cached_response\n ... | [
"0.6482948",
"0.6287235",
"0.6280377",
"0.6072988",
"0.60519505",
"0.5913605",
"0.5906597",
"0.590059",
"0.58755744",
"0.58405143",
"0.5829607",
"0.58241147",
"0.5783479",
"0.57205737",
"0.567177",
"0.5611315",
"0.55969965",
"0.55632925",
"0.55285174",
"0.5520176",
"0.5505413... | 0.8406503 | 1 |
returns true if a handler is set for the HTTP method in param it is an alternative to get_handler which would return a true value if there is a default handler | def has_handler?(method)
send(method) && true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def respond_to_missing?(method_name)\n @original_handler.respond_to?(method_name)\n end",
"def has_handler_for?(handler_method)\n @jr_handlers ||= {}\n @jr_handlers.has_key?(handler_method)\n end",
"def get?\r\nHTTP_METHOD_LOOKUP[request_method] == :get\r\nend",
"def handleRequest?(path)... | [
"0.71880573",
"0.70673895",
"0.70315045",
"0.6960397",
"0.6888432",
"0.66511524",
"0.6429777",
"0.63968956",
"0.6372571",
"0.63350034",
"0.6328482",
"0.6309252",
"0.6307925",
"0.63055146",
"0.63052446",
"0.62920165",
"0.6265385",
"0.62626976",
"0.6252423",
"0.6249509",
"0.624... | 0.76993495 | 0 |
sets a handler for the HTTP method in param to val | def set_handler(method, val)
send("#{method}=", val)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def http_method(value = nil)\n if value\n @http_method = value\n else\n @http_method\n end\n end",
"def http_method(v)\n endpoint_info[:http_method] = v\n end",
"def http_method= new_verb\n @http_method = new_verb.to_s.upcase\n end",
"def http_metho... | [
"0.71939635",
"0.7159462",
"0.6982221",
"0.6982221",
"0.69335437",
"0.6730909",
"0.6562484",
"0.6323994",
"0.617905",
"0.617905",
"0.61646706",
"0.61485004",
"0.61454594",
"0.6113104",
"0.6094643",
"0.60380816",
"0.6008632",
"0.6005134",
"0.5914227",
"0.5892399",
"0.5888219",... | 0.7760868 | 0 |
Returns an array of pairs of array with [HTTPverbs, handler] an extra item is the :default handler NB: could also be a hash, but I'm fine with it | def handlers
HTTP_METHODS.map do |sym|
[sym, send(sym)]
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def verbs\n (@verb.downcase.presence || 'get').split('|')\n end",
"def http_methods(_path)\n []\n end",
"def handlers\n @handlers ||= Hash.new do |hash, key|\n if key.nil?\n raise NoHandler\n else\n raise InvalidHandler, key\n end\n end\n... | [
"0.65251577",
"0.63290566",
"0.609211",
"0.6043446",
"0.5937355",
"0.5895904",
"0.5859775",
"0.5852079",
"0.58322763",
"0.58017915",
"0.58015114",
"0.57037044",
"0.57037044",
"0.57037044",
"0.56874067",
"0.566724",
"0.5663021",
"0.56479955",
"0.56331813",
"0.55932385",
"0.559... | 0.7637699 | 0 |
returns an array like handlers but restricted to the not nil values | def handlers_set
handlers.reject{|sym, handler| handler.nil?}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def handlers\n @handlers ||= Hash.new do |hash, key|\n if key.nil?\n raise NoHandler\n else\n raise InvalidHandler, key\n end\n end\n end",
"def handlers\n @handlers ||= Set.new\n end",
"def __handlers\n @__handlers ||= Hash.new([])\n ... | [
"0.6487597",
"0.62378854",
"0.61714274",
"0.61482465",
"0.6014034",
"0.57429856",
"0.57349545",
"0.5681223",
"0.5636645",
"0.5546216",
"0.5546216",
"0.5546216",
"0.55271155",
"0.55175674",
"0.55102974",
"0.54561996",
"0.544601",
"0.5399749",
"0.5366708",
"0.5335934",
"0.53336... | 0.7042405 | 0 |
Returns true if there is no handler set for this dispatcher | def no_handler?
handlers_set.empty?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def handlers?\n registered_handlers.length > 0\n end",
"def has_handler?(method)\n send(method) && true\n end",
"def empty?\n @dispatchers.empty?\n end",
"def handled?\n handled\n end",
"def handled?\n\t\treturn ! @status.nil?\n\tend",
"def handler_enabled?\n ... | [
"0.77711904",
"0.7221516",
"0.7161389",
"0.69499964",
"0.6823033",
"0.67305195",
"0.6703453",
"0.64089286",
"0.6389181",
"0.6150591",
"0.6085799",
"0.60730803",
"0.60704345",
"0.606162",
"0.6032549",
"0.6016277",
"0.60115904",
"0.59596235",
"0.5940822",
"0.59036714",
"0.58757... | 0.881674 | 0 |
Checks that the model given as a string exists | def model_exists?
if model.present?
begin
model.constantize
rescue NameError
errors.add :model, "#{model} is not a valid model"
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def model_exists?(model_type, name)\n get_model(model_type, name) != nil\n end",
"def model_exists?(model)\n File.exists? File.join(RAILS_ROOT,'app/models', model + '.rb')\n end",
"def model_exists?(model)\n File.exists? File.join(RAILS_ROOT,'app/models', model + '.rb')\nend",
"def model_exists?... | [
"0.7527053",
"0.7440013",
"0.7321153",
"0.71498436",
"0.69572294",
"0.6877183",
"0.68527615",
"0.666068",
"0.664825",
"0.6614182",
"0.65156555",
"0.64835036",
"0.6479785",
"0.64507276",
"0.64369017",
"0.64369017",
"0.643171",
"0.6349107",
"0.6253727",
"0.6243179",
"0.6229256"... | 0.7787579 | 0 |
Instantiates the reporter to generate the HamlLint report | def reporter
@reporter ||= ::HamlLint::Reporter::HashReporter.new(
::HamlLint::Logger.new(StringIO.new)
)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def runner\n @runner ||= ::HamlLint::Runner.new\n end",
"def display_report(report)\n super\n\n File.write(ConfigurationLoader::AUTO_GENERATED_FILE, config_file_contents)\n log.log \"Created #{ConfigurationLoader::AUTO_GENERATED_FILE}.\"\n log.log \"Run `haml-lint --config #{Confi... | [
"0.677621",
"0.65861124",
"0.61029667",
"0.6087162",
"0.60562736",
"0.5987778",
"0.59489644",
"0.5836281",
"0.5832875",
"0.5822366",
"0.5787985",
"0.570662",
"0.56942123",
"0.56863564",
"0.5663181",
"0.5639901",
"0.5637486",
"0.5603447",
"0.5535068",
"0.55140877",
"0.5497244"... | 0.80870014 | 0 |
GET /bbs GET /bbs.json | def index
@bbs = Bb.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @bb = Bb.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @bb }\n end\n end",
"def show\n @weibo = Weibo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @w... | [
"0.7061532",
"0.6372534",
"0.63676804",
"0.62977475",
"0.6288213",
"0.62540007",
"0.6250688",
"0.61445594",
"0.61312085",
"0.6126052",
"0.61097634",
"0.6059838",
"0.6042345",
"0.6031007",
"0.60165703",
"0.60161185",
"0.5978962",
"0.59534454",
"0.5938299",
"0.5935922",
"0.5931... | 0.6912775 | 1 |
POST /bbs POST /bbs.json | def create
@bb = Bb.new(bb_params)
respond_to do |format|
if @bb.save
format.html { redirect_to @bb, notice: 'Bb was successfully created.' }
format.json { render :show, status: :created, location: @bb }
else
format.html { render :new }
format.json { render json: @bb... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @bb = Bb.new(params[:bb])\n\n respond_to do |format|\n if @bb.save\n format.html { redirect_to @bb, notice: 'Bb was successfully created.' }\n format.json { render json: @bb, status: :created, location: @bb }\n else\n format.html { render action: \"new\" }\n ... | [
"0.6819664",
"0.64434904",
"0.6243959",
"0.6234521",
"0.61542755",
"0.60390276",
"0.60334337",
"0.603039",
"0.6004649",
"0.59964174",
"0.59896815",
"0.59720916",
"0.593884",
"0.59021103",
"0.5866441",
"0.58390075",
"0.58284444",
"0.5801121",
"0.5784998",
"0.5768846",
"0.57652... | 0.6746908 | 1 |
DELETE /bbs/1 DELETE /bbs/1.json | def destroy
@bb.destroy
respond_to do |format|
format.html { redirect_to bbs_url, notice: 'Bb was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @bb = Bb.find(params[:id])\n @bb.destroy\n\n respond_to do |format|\n format.html { redirect_to bbs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @b = B.find(params[:id])\n @b.destroy\n\n respond_to do |format|\n format.html { redirect_to... | [
"0.72713745",
"0.700241",
"0.69206923",
"0.68334067",
"0.6804754",
"0.67955065",
"0.6783016",
"0.6760925",
"0.6735975",
"0.6682564",
"0.66667366",
"0.66650814",
"0.66561687",
"0.6645461",
"0.663072",
"0.6581821",
"0.658068",
"0.657236",
"0.656462",
"0.6540489",
"0.6531784",
... | 0.71378064 | 1 |
We use these mock accounts to ensure that the ones which are available in development are valid, to test omniauth actions and verify that a mock account is available for every supported omniauth provider. These must be identical to the ones in /config/environments/development.rb Remember to keep them in sync with devel... | def mock_auth_accounts
OmniAuth.config.mock_auth[:facebook] =
OmniAuth::AuthHash.new(
provider: 'facebook',
uid: 'facebook-test-uid-1',
info: {
name: 'facebook user',... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mock_auth\n OmniAuth.config.mock_auth[:facebook] = OmniAuth::AuthHash.new({\n provider: 'facebook',\n uid: '123545',\n person_id: '1',\n credentials: {\n token: 'token',\n expires_at: Time.now + 10000000\n },\n info: {\n first_name: 'first_name',\n l... | [
"0.69900966",
"0.6871177",
"0.65068924",
"0.6486989",
"0.64714503",
"0.63960737",
"0.6280759",
"0.62422264",
"0.62377244",
"0.6116393",
"0.6083275",
"0.599791",
"0.5968223",
"0.59553987",
"0.5878758",
"0.5878758",
"0.58665687",
"0.5865046",
"0.5829651",
"0.5829651",
"0.582272... | 0.8128238 | 0 |
Delete all entities which match all attributes attributes: Hash of attributes to match Returns: Integer count of entities deleted. | def delete_all(attributes = {})
raise NotImplementedError.new
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_all\n self.store.delete_keys(find_keys)\n end",
"def delete_all(conditions = \"\")\n collection.remove(XGen::SQL::Parser.parse_where(conditions, true) || {})\n end",
"def delete(*args)\n if args.blank?\n raise \"Using delete with no args is not allowed. Please... | [
"0.6635313",
"0.639678",
"0.63617414",
"0.6349998",
"0.61776924",
"0.6144484",
"0.6132015",
"0.60949475",
"0.60592246",
"0.6057224",
"0.6045857",
"0.60256195",
"0.60182184",
"0.59771925",
"0.5975894",
"0.59724146",
"0.5940667",
"0.5931897",
"0.5931067",
"0.5914326",
"0.584031... | 0.7103051 | 0 |
The default stitching is a board of square tiles Inherit & overwrite these as necessary | def stitching(x, y)
# Return only what's already been generated (that is, what's above and to the left).
return [:normal, [
([x - 1, y] if x > 0),
([x - 1, y - 1] if x > 0 and y > 0),
([x, y - 1] if y > 0),
([x + 1, y - 1] if y > 0 and x < @field_width - 1)
].compact]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def place_knights\r\n $board[1][0] = Knight.new('white')\r\n\t\t$board[6][0] = Knight.new('white')\r\n\t\t$board[1][7] = Knight.new('black')\r\n\t\t$board[6][7] = Knight.new('black')\r\n end",
"def reset(cols, rows)\n\t\t@holeSize = 3 + rand(2)\n\t\t@holeHeight = rows / 4 + rand * (rows / 2)\n\t\t@tubePositi... | [
"0.61197764",
"0.60431886",
"0.59968626",
"0.5990148",
"0.5925573",
"0.59176254",
"0.5896609",
"0.58956623",
"0.5866875",
"0.5858822",
"0.58477473",
"0.5846091",
"0.583172",
"0.5825306",
"0.57986695",
"0.5786398",
"0.57670075",
"0.57513285",
"0.57303077",
"0.5724194",
"0.5711... | 0.6045129 | 1 |
Public Methods Process => Validate, setup all appropriate request data, and register contexts => Return self | def process
raise RequestValidationError unless validate
@roles = get_roles
@user = get_or_create_user
@resource = get_resource
@assignment = get_assignment
@space = get_space
@space_user = get_or_create_space_user
register
self
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def process\n klass.new(request).process\n end",
"def perform\n\n r = validate\n return r unless r.success?\n\n process_hook\n\n end",
"def run(*params)\n setup!(*params) # where do we assign/find the model?\n\n [process(*params), @valid].reverse\n end",
"def pr... | [
"0.64535993",
"0.60113144",
"0.60081416",
"0.5862405",
"0.5718233",
"0.56996",
"0.56746596",
"0.5672537",
"0.563901",
"0.5611255",
"0.5554513",
"0.554773",
"0.55267185",
"0.55062586",
"0.54888093",
"0.54832774",
"0.5472991",
"0.54684776",
"0.5447625",
"0.5411495",
"0.5409127"... | 0.73026836 | 0 |
Helper function to expect a class to have a set of options defined. These options are not firstclass citizens of puppet, but instead a keyvalue map. So regular rspec matchers don't help. To stay DRY, introduce this helper. | def expect_option(klass, key, val)
# test each option
it do
should contain_class(klass).with_options(
lambda do |map|
if map[key] == val
true
else
fail "#{klass} option #{key.inspect} doesn't match (-- expected, ++ actual):\n"\
"-- #{val.inspect}\n"\
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def expect_option(klass, key, val)\n # test each option\n it do\n should contain_class(klass).with_options(\n lambda do |map|\n # check\n if map[key] == wrap_expected(val)\n true\n else\n fail \"#{klass} option #{key.inspect} doesn't match (-- expected, ++ actual):\... | [
"0.7172928",
"0.678551",
"0.6163496",
"0.6143392",
"0.58016455",
"0.57745785",
"0.5760239",
"0.5745142",
"0.57433367",
"0.5733813",
"0.5724448",
"0.5716634",
"0.57087576",
"0.5706889",
"0.5699857",
"0.5690678",
"0.5689048",
"0.5671607",
"0.5663806",
"0.5651863",
"0.5648074",
... | 0.71979326 | 0 |
get list of current available books | def available_books
puts "Available Books:"
@book_status.each { |k, v| puts "#{k}" if v == "available" }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def available_books\n @books.each do |book|\n if book.status == \"available\"\n puts \"#{book.title} by #{book.author} is available.\"\n end\n end\n end",
"def available_books\n @books.select { |book| book.status == 'available' }\n end",
"def available\n @books = Book.all\n end"... | [
"0.821038",
"0.8146145",
"0.8103563",
"0.8034198",
"0.78797823",
"0.77441853",
"0.77196896",
"0.7670728",
"0.7670728",
"0.7607577",
"0.75827783",
"0.75540465",
"0.75470656",
"0.75229883",
"0.75056064",
"0.7451121",
"0.7438426",
"0.7419048",
"0.7416641",
"0.7391632",
"0.726700... | 0.8305527 | 0 |
Derives the mac key and encryption key | def derive_keys(key)
derived_key_size = key.size / 2
mac_key = key[0...derived_key_size]
enc_key = key[derived_key_size..-1]
return mac_key, enc_key
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_crypto_key_hex\n return @crypto_key if ! @crypto_key\n @crypto_key.unpack(\"H*\")\n end",
"def crypto_key\n # Returns singleton object\n EmailEncryptionKey.instance.key\n end",
"def key(hash160)\n key = Bitcoin::Key.new\n key.priv = hash160\n key\n end",
"def key(hash160)\n ... | [
"0.67573506",
"0.6469433",
"0.6421602",
"0.6187748",
"0.6174795",
"0.6153859",
"0.61152786",
"0.6113035",
"0.6106023",
"0.6080731",
"0.6058705",
"0.6050827",
"0.60343266",
"0.6021635",
"0.6020837",
"0.60139185",
"0.60079",
"0.59283787",
"0.5915352",
"0.5915091",
"0.5907426",
... | 0.7485602 | 0 |
Default empty implementation of _roda_after, usually overridden by Roda.def_roda_before. | def _roda_after(res)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def def_roda_after\n meths = private_instance_methods.grep(/\\A_roda_after_\\d\\d/).sort\n unless meths.empty?\n plugin :error_handler unless private_method_defined?(:_roda_after)\n if meths.length == 1\n class_eval(\"alias _roda_after #{meths.first}\", __FILE__... | [
"0.81931144",
"0.6234094",
"0.6234094",
"0.5841248",
"0.58328044",
"0.57832104",
"0.5742591",
"0.569086",
"0.56727916",
"0.5619244",
"0.55398107",
"0.55398107",
"0.5523276",
"0.54220074",
"0.5413007",
"0.53838795",
"0.5372664",
"0.5365784",
"0.5365784",
"0.5365784",
"0.536578... | 0.7350155 | 1 |
Handle the given exception using handle_error, using a default status of 500. Run after hooks on the rack response, but if any error occurs when doing so, log the error using rack.errors and return the response. | def _handle_error(e)
res = @_response
res.send(:initialize)
res.status = 500
res = _roda_handle_route{handle_error(e)}
begin
_roda_after(res)
rescue => e2
if errors = env['rack.errors']
errors.puts "Error in after hook pro... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def handle_exception(exception, request, response)\n response.flush\n response.status = 500\n\n if config.development?\n response.content_type = \"text/html\"\n response.puts(Rack::ShowExceptions.new(nil).pretty(request.env, exception))\n else\n response.layout = \"layouts/... | [
"0.731188",
"0.7174244",
"0.7033307",
"0.6968687",
"0.6931454",
"0.6908432",
"0.68350697",
"0.67627835",
"0.6713306",
"0.65973717",
"0.65823203",
"0.65475065",
"0.65432066",
"0.65420574",
"0.65269786",
"0.65223503",
"0.650062",
"0.65005255",
"0.6499815",
"0.64948493",
"0.6478... | 0.73504764 | 0 |
The standard commands which never change. | def standard_commands
{
'C' => Commands::ClearImageBuffer,
'T' => Commands::Feed,
'XS' => Commands::Issue
}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def commands\n {}\n end",
"def commands; end",
"def commands\n @commands ||= []\n end",
"def get_commands\n return nil\n end",
"def commands\n @@commands.dup\n end",
"def commands\n COMMANDS\n end",
"def commands\n load_commands unless @commands\n @commands... | [
"0.7855798",
"0.77812415",
"0.76808256",
"0.76807827",
"0.7663106",
"0.7656751",
"0.75898874",
"0.7530471",
"0.75160503",
"0.7499065",
"0.7473173",
"0.74081194",
"0.74054396",
"0.7366237",
"0.7355058",
"0.731455",
"0.7310965",
"0.73096603",
"0.72974914",
"0.7296988",
"0.72390... | 0.7909898 | 0 |
Take a list of commands and execute them. Returns an array of objects. In the case of standard commands will just create a new command. With a derived command it will execute the method. A derived command may itself contain a list of commands so the whole thing is flattened to produce a single array. | def commands
@commands ||= [].tap do |c|
commands_list.each do |command|
if command.instance_of? String
c << standard_commands[command].new
else
ret_command = send(command)
c << (ret_command.instance_of?(Hash) ? ret_command.values : ret... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def invoke_all #:nodoc:\n self.class.all_commands.map { |_, command| invoke_command(command) }\n end",
"def commands\n return [] unless options[\"commands\"]\n options[\"commands\"].map do |options|\n options['parents'] = parents + [name]\n Command.new options\n end... | [
"0.71134484",
"0.7039111",
"0.70300555",
"0.70222014",
"0.6867172",
"0.68665916",
"0.67523247",
"0.67329425",
"0.6723371",
"0.67002696",
"0.66542965",
"0.6629754",
"0.6566343",
"0.65500635",
"0.64870524",
"0.6472526",
"0.6455409",
"0.6412508",
"0.641077",
"0.6380616",
"0.6377... | 0.7644019 | 0 |
Converts a Cygwin Unix path to a Windows path, e.g.: /cygdrive/d/path/to/file ==> D:/path/to/file | def cygwin_path(path)
if RUBY_PLATFORM.include?('cygwin') && path.index('/') == 0
IO.popen("cygpath -m #{path.include?(':') ? '-p' : ''} #{path.shellescape}").readline.chomp.gsub(/;/, '\\;')
else
path
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def makeWindowsPathIntoMinGWPath(path)\n modifiedPath = path.gsub(/\\\\/, '/')\n modifiedPath.gsub(/^(\\w+):[\\\\\\/]/) { \"/#{$1.downcase}/\" }\nend",
"def windows_path(path)\n path.gsub(/\\//, '\\\\')\n end",
"def to_windows_path(path)\n path.gsub('/', \"\\\\\")\n end",
"def makeWindo... | [
"0.7466854",
"0.74545604",
"0.7454556",
"0.7245687",
"0.70774406",
"0.68850356",
"0.68850356",
"0.6841165",
"0.6809859",
"0.67986107",
"0.67639595",
"0.6714192",
"0.66852015",
"0.6679233",
"0.667161",
"0.6664879",
"0.6618574",
"0.656552",
"0.6312081",
"0.62101406",
"0.6208756... | 0.8176252 | 0 |
POST /system/platform_accounts POST /system/platform_accounts.json | def create
@system_platform_account = System::PlatformAccount.new(system_platform_account_params)
if @system_platform_account.save
record_activities('创建接入账号', @system_platform_account.account_name)
flash[:success] = '创建接入账号成功'
redirect_to system_platform_accounts_path
else
flash[:err... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @platform_account = PlatformAccount.new(platform_account_params)\n\n respond_to do |format|\n if @platform_account.save\n format.html { redirect_to @platform_account, notice: 'Platform account was successfully created.' }\n format.json { render :show, status: :created, locatio... | [
"0.69657475",
"0.6878102",
"0.65119225",
"0.6469372",
"0.6435222",
"0.613894",
"0.6093869",
"0.60785115",
"0.6018403",
"0.6013775",
"0.594479",
"0.59259516",
"0.5910427",
"0.58811086",
"0.586852",
"0.5812276",
"0.5800599",
"0.5793748",
"0.5776442",
"0.57460445",
"0.57443756",... | 0.692325 | 1 |
PATCH/PUT /system/platform_accounts/1 PATCH/PUT /system/platform_accounts/1.json | def update
if @system_platform_account.update(system_platform_account_params)
record_activities('修改接入账号', @system_platform_account.account_name)
flash[:success] = '修改接入账号成功'
redirect_to system_platform_accounts_path
else
flash[:error] = "修改失败: #{@system_platform_account.errors.full_messa... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n respond_to do |format|\n if @platform_account.update(platform_account_params)\n format.html { redirect_to @platform_account, notice: 'Platform account was successfully updated.' }\n format.json { render :show, status: :ok, location: @platform_account }\n else\n format... | [
"0.6664587",
"0.63509876",
"0.62742865",
"0.6177907",
"0.61456203",
"0.61348855",
"0.6080994",
"0.60676354",
"0.5990541",
"0.5987726",
"0.5969116",
"0.59688026",
"0.5911257",
"0.5911257",
"0.5896474",
"0.5860513",
"0.58026594",
"0.5790808",
"0.57885647",
"0.57713467",
"0.5769... | 0.65516 | 1 |
Processes the given email, submits attachments to the Heathen server, delivers responses as configured | def process email, mail_to, is_rts=false
documents = []
unless email.has_attachments?
logger.info "From: #{email.from} Subject: (#{email.subject}) Files: no attachments"
return
end
logger.info "From: #{email.from} Subject: (#{email.subject}) Files: #{email.attachments.map(&:fil... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def email\n\t\temail_response = EmailHandler.new(email_content).deliver_email\n\t\t\trender text: email_response + \"\\n\"\n\tend",
"def process\n return 'OK' if @email.to.first[:token] == 'example'\n return process_image if @email.to.first[:token] == 'flyers'\n\n token = ReplyToken.find(@email.to.first... | [
"0.6445737",
"0.62992346",
"0.62779707",
"0.6247057",
"0.6162328",
"0.6014607",
"0.6004042",
"0.5993383",
"0.5950224",
"0.59502155",
"0.5886799",
"0.5832686",
"0.58004117",
"0.5765758",
"0.5738035",
"0.5697251",
"0.5692308",
"0.5687707",
"0.5686721",
"0.567369",
"0.56539917",... | 0.6434325 | 1 |
Forward the email to sender, with decoded documents replacing the originals | def deliver_onward email, documents, mail_to
logger.info "Sending response mail to #{mail_to}"
email.cc [] # No CCing, just send to the recipient
email.to mail_to
email.subject "#{'Fwd: ' unless email.subject.to_s.start_with? 'Fwd:'}#{email.subject}"
email.return_path email.from unless ema... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def deliver_rts email, documents, mail_to\n logger.info \"Sending response mail to #{mail_to}\"\n mail = Mail.new\n mail.from @cfg[:from]\n mail.to mail_to\n # CCs to the original email will get a copy of the converted files as well\n mail.cc (email.cc - email.to - (@cfg[:cc_blacklist... | [
"0.64977014",
"0.6424124",
"0.63283294",
"0.6274577",
"0.5993774",
"0.5918794",
"0.5916153",
"0.582899",
"0.58096135",
"0.5710799",
"0.5679788",
"0.5650706",
"0.5617321",
"0.55787796",
"0.55785877",
"0.5576686",
"0.55626917",
"0.55534476",
"0.5546139",
"0.5511874",
"0.5496006... | 0.71392787 | 0 |
Opens and reads a file, first given the filename, then tries from the project base directory | def read_file filename
f = filename
unless File.exist? f
f = Pathname.new(__FILE__).realpath.parent.parent.parent + f
end
File.read f
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def file(filename) File.read(File.absolute_path(filename, File.dirname($PROGRAM_NAME))) end",
"def load_file( filename )\n begin\n read_in = File.new( filename, 'r' )\n rescue\n abort \"\\\"#{ filename }\\\" not found\"\n end\nend",
"def open_file(filename)\n File.open(filename, 'r')\n end",
... | [
"0.70322126",
"0.67769605",
"0.663163",
"0.6585881",
"0.65428025",
"0.6354542",
"0.63190085",
"0.63149667",
"0.63071203",
"0.62838364",
"0.62745726",
"0.6266581",
"0.6263687",
"0.62383866",
"0.62383866",
"0.62296194",
"0.6216855",
"0.6201136",
"0.61948687",
"0.6175239",
"0.61... | 0.69019765 | 1 |
POST /germinations POST /germinations.json | def create
@germination = Germination.new(germination_params)
respond_to do |format|
if @germination.save
format.html { redirect_to @germination, notice: 'Germination was successfully created.' }
format.json { render :show, status: :created, location: @germin... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def germination_params\n params.require(:germination).permit(:seed_id, :week, :numGerminations,:codeCross, :codeCrossNumRepeat, :totalNumRepeat, :totalCode, :missingSeed)\n end",
"def set_germination\n @germination = Germination.find(params[:id])\n end",
"def update\n respond_to do |... | [
"0.62815017",
"0.62179554",
"0.6190228",
"0.6001416",
"0.5924232",
"0.5803998",
"0.5788219",
"0.5759266",
"0.57424706",
"0.57262695",
"0.5717415",
"0.57160664",
"0.5695696",
"0.56330705",
"0.5626055",
"0.562183",
"0.5593575",
"0.55877817",
"0.5563954",
"0.5561194",
"0.55527",... | 0.6999638 | 0 |
PATCH/PUT /germinations/1 PATCH/PUT /germinations/1.json | def update
respond_to do |format|
if @germination.update(germination_params)
format.html { redirect_to @germination, notice: 'Germination was successfully updated.' }
format.json { render :show, status: :ok, location: @germination }
else
fo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @golfer = Golfer.find(params[:id])\n\n respond_to do |format|\n if @golfer.update_attributes(params[:golfer])\n format.html { redirect_to @golfer, notice: 'Golfer was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: ... | [
"0.62286437",
"0.6133187",
"0.60811967",
"0.6075552",
"0.60667264",
"0.60458076",
"0.59186405",
"0.58900356",
"0.58647126",
"0.5864348",
"0.58479387",
"0.58449566",
"0.5818425",
"0.58170277",
"0.58123165",
"0.5799829",
"0.5795953",
"0.57946986",
"0.57925326",
"0.5792086",
"0.... | 0.65737003 | 0 |
Method to update the quantity of an item input: updated_and_removed (hash), the food, and also the integer/value update steps: Call for the key, pass in an argument for the value (to update) output: hash with quantities changed | def update_quantity(updated_and_removed, food, quantity)
updated_and_removed[food] = quantity
return updated_and_removed
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_item_quantity(hash_of_items, item, quantity)\n hash_of_items[item] = quantity\n hash_of_items\nend",
"def update_quantity (item, quantity)\n item_hash[item] = quantity\nend",
"def update_quantity(list, upd_item, new_quantity)\n# steps:\n # reassign key (item) a new value (quantity)\n list[upd_i... | [
"0.7888069",
"0.764511",
"0.7604691",
"0.76039946",
"0.7598769",
"0.7592169",
"0.7575722",
"0.7571074",
"0.75564104",
"0.75564104",
"0.7491865",
"0.7490988",
"0.7438961",
"0.74265236",
"0.73975",
"0.7379802",
"0.73691183",
"0.7361545",
"0.73510516",
"0.73359215",
"0.73170424"... | 0.79688597 | 1 |
Top to bottom per col approach | def top_to_bottom_approach
largest_prod_of_all_cols = 0
for each_row in (0..15)
for each_col in (0..19)
curr_prod_in_col = $grid_of_numbers[each_row][each_col] * $grid_of_numbers[each_row + 1][each_col] * $grid_of_numbers[each_row + 2][each_col] * $grid_of_numbers[each_row + 3][each_col]
if curr_pro... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rows\n top...(top + bordered_height)\n end",
"def topToBottom(grid, width, height)\n\n strings = Array.new\n string = String.new\n\n for x in 0..width-1 do\n\n string = \"\"\n\n for y in 0..height-1 do\n letter = grid[[x, y]]\n string << letter\n ... | [
"0.64538753",
"0.6239998",
"0.61013013",
"0.60231555",
"0.6017565",
"0.5979388",
"0.5934234",
"0.59333867",
"0.59333867",
"0.59333867",
"0.59027475",
"0.5900925",
"0.5897193",
"0.58860314",
"0.5856215",
"0.58514017",
"0.58369446",
"0.5831316",
"0.58283556",
"0.58254564",
"0.5... | 0.64596754 | 0 |
destroys spelling analysis records for dirty attributes | def expire_spellcheck_analysis!
spellcheck_attributes.each do |attribute|
if send("#{attribute}_changed?")
spellcheck_analyses.for(
attribute
).destroy_all
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_analysis\n model.wordcounts.destroy_all\n create_analysis\n delete_orphaned_keywords\n end",
"def destroy_analysis\n model.wordcounts.destroy_all\n delete_orphaned_keywords\n end",
"def clean_attributes\n @attribute_changes = {}\n end",
"def clean_dirty_attri... | [
"0.7054716",
"0.6836037",
"0.67611176",
"0.66816026",
"0.65128964",
"0.64335",
"0.6398209",
"0.6332102",
"0.6327789",
"0.63066363",
"0.6243849",
"0.6243849",
"0.6214917",
"0.6196193",
"0.6184995",
"0.60894126",
"0.6087792",
"0.60426253",
"0.6020794",
"0.6009847",
"0.5996206",... | 0.7698176 | 0 |
schedules a spellcheck analysis if there's any attribute missing without analysis | def schedule_spellcheck_analysis!
if missing_spellcheck_analysis?
self.class.delay.perform_spellcheck!(id)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def analyse!\n @words = formatted_mispelled_words\n @success = true\n rescue *rescued_exceptions_keys => e\n @success = false\n if rescued_exceptions_messages.include?(e.message)\n # aspell is not present. track analysis as failure\n else\n raise e\n end\n end",
"def expire_spellche... | [
"0.7094114",
"0.65429735",
"0.60914516",
"0.5973861",
"0.5959402",
"0.56555307",
"0.5457493",
"0.54477775",
"0.53906095",
"0.5385877",
"0.5344768",
"0.5335884",
"0.5333769",
"0.53216285",
"0.52984506",
"0.52297664",
"0.51652765",
"0.5151356",
"0.5128848",
"0.5100648",
"0.5089... | 0.8056898 | 0 |
Epay::Subscription.create(:card_no => '...', :) | def create(params)
params.merge!(
:order_no => (Time.now.to_f * 10000).to_i.to_s, # Produce a unique order_no - it's not used anywhere, but ePay needs this
:amount => 0
)
post = Api.default_post_for_params(params).merge({
:subscription => 1,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_subscription(credit_card, options = {})\n\n u = self.user\n options[:order_id] = number # currently just loading a date\n options[:email] = u.email\n options[:address] = {\n :first_name => u.first_name,\n :last_name => u.last_name,\n :address1 => u.street_address1,\n ... | [
"0.74440676",
"0.69249344",
"0.66142",
"0.6543828",
"0.6535729",
"0.6463699",
"0.6438519",
"0.63840294",
"0.63840294",
"0.63743496",
"0.6366984",
"0.6348669",
"0.63290554",
"0.6298875",
"0.6294393",
"0.6271813",
"0.6244119",
"0.621914",
"0.62121296",
"0.6211957",
"0.6202277",... | 0.70539814 | 1 |
Locate whitelisted attributes for the supplied association name | def whitelisted_attrs_for(assoc_name, attr_hash = whitelisted_attrs)
if assoc_name.to_s == attr_hash.keys.first.to_s
return attr_hash.values.first.reject { |v| v.is_a? Hash }
end
scoped_whitelisted_attrs = attr_hash.values.first
scoped_whitelisted_attrs.reject { |v|
!v.is_a? Has... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_attributes_starting_with(name)\n @attributes.select { |key| key.to_s.start_with?(name) }\n end",
"def with(name)\r\n @attributes.find { |attr| attr.name == name }\r\n end",
"def sanitize_has_many(association_name)\n association_name = association_name.to_s\n singula... | [
"0.62297773",
"0.58707494",
"0.5681205",
"0.56804436",
"0.5580042",
"0.55318826",
"0.5509185",
"0.543627",
"0.54211015",
"0.5367452",
"0.53495026",
"0.5342377",
"0.52918595",
"0.5263046",
"0.52556527",
"0.5253176",
"0.51756036",
"0.51753515",
"0.5157375",
"0.51460755",
"0.514... | 0.6263081 | 0 |
days_of_week Helpers Hash mapping day of week (Symbol) to valid(true)/invalid(false) | def days_of_week_hash
@days_of_week_hash ||= {
:sunday => (days_of_week & SUNDAY ) > 0,
:monday => (days_of_week & MONDAY ) > 0,
:tuesday => (days_of_week & TUESDAY ) > 0,
:wednesday => (days_of_week & WEDNESDAY ) > 0,
:thursday => (days_of_week & THURSDAY ) > 0,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def week_days\n {\n \"1\" => 'mon',\n \"2\" => 'tue',\n \"3\" => 'wed',\n \"4\" => 'thu',\n \"5\" => 'fri',\n \"6\" => 'sat',\n \"7\" => 'sun'\n }\n end",
"def days_of_week_are_valid\n errors.add(:days_of_week, \"The days of the week ... | [
"0.7101164",
"0.68387413",
"0.66913855",
"0.6580827",
"0.645476",
"0.6395663",
"0.62980866",
"0.61266935",
"0.61141163",
"0.6081505",
"0.60686713",
"0.6054797",
"0.60448176",
"0.6013568",
"0.6002565",
"0.598655",
"0.5983415",
"0.59625745",
"0.5904272",
"0.5893466",
"0.5884830... | 0.81110364 | 0 |
Array beginning with Sunday of valid(true)/inactive(false) values | def days_of_week_array
dow = days_of_week_hash
@days_of_week_array ||= [
dow[:sunday],
dow[:monday],
dow[:tuesday],
dow[:wednesday],
dow[:thursday],
dow[:friday],
dow[:saturday]
]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_days\n\t\tbool_array = []\n\n\t\tbool_array << self[:monday]\n\t\tbool_array << self[:tuesday]\n\t\tbool_array << self[:wednesday]\n\t\tbool_array << self[:thursday]\n\t\tbool_array << self[:friday]\n\t\tbool_array << self[:saturday]\n\t\tbool_array << self[:sunday]\n\n\t\treturn bool_array\n\tend",
"def... | [
"0.71965784",
"0.67568946",
"0.6581913",
"0.64520675",
"0.63136214",
"0.6308482",
"0.6202394",
"0.61984134",
"0.6176048",
"0.61348885",
"0.6126456",
"0.60864455",
"0.6034387",
"0.60218185",
"0.59990925",
"0.5979697",
"0.59554625",
"0.595433",
"0.58854246",
"0.5867371",
"0.584... | 0.69801205 | 1 |
Humanreadable string of applicable days of week | def days_of_week_string
dow = days_of_week_hash
@days_of_week_string ||=
(dow[:sunday] ? "Su" : "") +
(dow[:monday] ? "M" : "") +
(dow[:tuesday] ? "Tu" : "") +
(dow[:wednesday] ? "W" : "") ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def day_name; Date::DAYNAMES[wday] end",
"def week_days\n {\n \"1\" => 'mon',\n \"2\" => 'tue',\n \"3\" => 'wed',\n \"4\" => 'thu',\n \"5\" => 'fri',\n \"6\" => 'sat',\n \"7\" => 'sun'\n }\n end",
"def wday_shortname date\n %w'вс пн... | [
"0.7737139",
"0.7486552",
"0.7469496",
"0.73546207",
"0.72907776",
"0.7284998",
"0.7241393",
"0.72357625",
"0.71897435",
"0.7145447",
"0.7094004",
"0.70383483",
"0.7018797",
"0.6955864",
"0.69220936",
"0.69005585",
"0.6775498",
"0.67750865",
"0.67712194",
"0.6764459",
"0.6739... | 0.78225845 | 0 |
TODO DEPRECATED METHODS Returns a RelativeTime object representing this OperatingTime | def relativeTime
@relativeTime ||= RelativeTime.new(self, :opensAt, :length)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def current_time\r\n return @owner.timestamp.to_i - @start.to_i\r\n end",
"def time\n Time.now.localtime + self.time_offset\n end",
"def to_time\n self\n end",
"def relative_time(time)\n stamp = time.getutc.iso8601\n %(<time class=\"ltr\" dir=\"ltr\" title=\"#{st... | [
"0.65414953",
"0.64402467",
"0.6255717",
"0.6231243",
"0.61912125",
"0.6088688",
"0.6035321",
"0.6035321",
"0.6031371",
"0.5978721",
"0.5962981",
"0.59468776",
"0.59287286",
"0.59149784",
"0.5897135",
"0.5892174",
"0.5857807",
"0.584655",
"0.58331233",
"0.58246064",
"0.582424... | 0.7810221 | 0 |
FIXME Deprecated, use +override+ instead | def special
override
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def overrides; end",
"def source(override); end",
"def super_method; end",
"def tag; raise 'Override this method'; end",
"def custom; end",
"def custom; end",
"def inherited(base); end",
"def overrides=(_arg0); end",
"def virtual; end",
"def proxy\n super\n end",
"def private; end",
"... | [
"0.8639842",
"0.76268375",
"0.75826335",
"0.75562793",
"0.74351907",
"0.74351907",
"0.74229366",
"0.7329519",
"0.7291582",
"0.72717106",
"0.7223582",
"0.7076081",
"0.7076081",
"0.7038899",
"0.69644564",
"0.69644564",
"0.69512624",
"0.6944975",
"0.69274217",
"0.69274217",
"0.6... | 0.7944929 | 1 |
Input: isSpecial = true/false FIXME Deprecated, use +override=+ instead | def special=(isSpecial)
if isSpecial == true or isSpecial == "true" or isSpecial == 1
self.override = true
elsif isSpecial == false or isSpecial == "false" or isSpecial == 0
self.override = false
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def special\n override\n end",
"def special=(value)\n @special = value\n end",
"def specialty; end",
"def is_special?\n\n [ '*embedded*', '*untracked*' ].include?(self.name)\n end",
"def overrides; end",
"def enotsup?() super; end",
"def set_normal!\n @wildcard = ... | [
"0.71309096",
"0.6226058",
"0.61120033",
"0.59751964",
"0.5869382",
"0.5725025",
"0.5698278",
"0.56727046",
"0.56639534",
"0.5553868",
"0.5505519",
"0.5494788",
"0.54832375",
"0.54832375",
"0.5450311",
"0.5423534",
"0.5421569",
"0.5414391",
"0.5395716",
"0.53858036",
"0.53718... | 0.8336799 | 0 |
Delete VPC. ec2.delete_vpc("vpc890ce2e0") => true | def delete_vpc(vpc_id)
link = generate_request("DeleteVpc", 'VpcId' => vpc_id )
request_info(link, RightHttp2xxParser.new(:logger => @logger))
rescue Exception
on_exception
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n requires :id\n service.delete_vpc(id)\n true\n end",
"def delete_vpc(vpc_id)\n return if vpc_id.nil? || !configured?\n\n @client.delete_vpc(vpc_id: vpc_id)\n end",
"def destroy\n @aws_vpc_tag.destroy\n respond_to do |format|\n format.html { redi... | [
"0.8224563",
"0.790087",
"0.694757",
"0.6551244",
"0.63807094",
"0.6149625",
"0.6077866",
"0.5724397",
"0.5701135",
"0.5694534",
"0.5691916",
"0.56865984",
"0.56732345",
"0.56375486",
"0.56126297",
"0.5608507",
"0.5586136",
"0.55807585",
"0.5557539",
"0.55503654",
"0.55220866... | 0.7932706 | 1 |
Delete DHCP Options. ec2.delete_dhcp_options("doptcb0de3a2") => true | def delete_dhcp_options(dhcp_options_id)
link = generate_request("DeleteDhcpOptions", 'DhcpOptionsId' => dhcp_options_id )
request_info(link, RightHttp2xxParser.new(:logger => @logger))
rescue Exception
on_exception
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n requires :id\n service.delete_dhcp_options(id)\n true\n end",
"def destroy\n @aws_dhcp_option_attribute.destroy\n respond_to do |format|\n format.html { redirect_to aws_dhcp_option_attributes_url, notice: 'Aws dhcp option attribute was successfully destr... | [
"0.8420959",
"0.6863806",
"0.6480748",
"0.6448804",
"0.6369895",
"0.61514276",
"0.60612226",
"0.60586494",
"0.6022748",
"0.59883505",
"0.597475",
"0.59474516",
"0.59318",
"0.58906984",
"0.58425814",
"0.58199286",
"0.576356",
"0.57190824",
"0.5701034",
"0.56766",
"0.5669369",
... | 0.79963267 | 1 |
Delete customer gateway. ec2.delete_customer_gateway("cgwd5a643bc") => true | def delete_customer_gateway(customer_gateway_id)
link = generate_request("DeleteCustomerGateway", 'CustomerGatewayId' => customer_gateway_id )
request_info(link, RightHttp2xxParser.new(:logger => @logger))
rescue Exception
on_exception
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n requires :customer_gateway_id\n \n service.delete_customer_gateway(customer_gateway_id)\n true\n end",
"def destroy\n requires :id\n \n service.delete_nat_gateway(id)\n true\n end",
"def destroy\n @payment_ga... | [
"0.8375744",
"0.6895204",
"0.6833198",
"0.66712445",
"0.6517801",
"0.6488889",
"0.6185644",
"0.6076983",
"0.6076983",
"0.6051314",
"0.6018349",
"0.6008825",
"0.59804004",
"0.59573954",
"0.59382427",
"0.58884317",
"0.586029",
"0.5835617",
"0.58298254",
"0.57514703",
"0.5721072... | 0.83043444 | 1 |
Detach VPN gateway. ec2.detach_vpn_gateway('vgwdfa144b6','vpc890ce2e0') => true | def detach_vpn_gateway(vpn_gateway_id, vpc_id)
link = generate_request("DetachVpnGateway", 'VpnGatewayId' => vpn_gateway_id,
'VpcId' => vpc_id )
request_info(link, RightHttp2xxParser.new(:logger => @logger))
rescue Exception
on_exception
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_vpn_gateway(vpn_gateway_id)\n link = generate_request(\"DeleteVpnGateway\", 'VpnGatewayId' => vpn_gateway_id )\n request_info(link, RightHttp2xxParser.new(:logger => @logger))\n rescue Exception\n on_exception\n end",
"def detach(vpc_id)\n requires :id\n service.... | [
"0.65123874",
"0.6361243",
"0.62730455",
"0.59608024",
"0.5887733",
"0.5845077",
"0.5825646",
"0.5697991",
"0.55941606",
"0.5589475",
"0.55568457",
"0.5531404",
"0.5480342",
"0.5466503",
"0.54130226",
"0.5395616",
"0.53945833",
"0.5380723",
"0.536856",
"0.5331706",
"0.5273601... | 0.78283596 | 0 |
Delete vpn gateway. ec2.delete_vpn_gateway("vgwdfa144b6") => true | def delete_vpn_gateway(vpn_gateway_id)
link = generate_request("DeleteVpnGateway", 'VpnGatewayId' => vpn_gateway_id )
request_info(link, RightHttp2xxParser.new(:logger => @logger))
rescue Exception
on_exception
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n requires :id\n \n service.delete_nat_gateway(id)\n true\n end",
"def destroy\n @payment_gateway.destroy\n respond_to do |format|\n flash[:success] = 'Payment gateway was successfully deleted.'\n format.html { redirect_to payment_gateways_ur... | [
"0.7183906",
"0.7150462",
"0.7052538",
"0.6931372",
"0.6924067",
"0.68908215",
"0.68870014",
"0.66670597",
"0.6476776",
"0.64290774",
"0.6409588",
"0.6380826",
"0.6116025",
"0.6015251",
"0.59981155",
"0.59282196",
"0.57916135",
"0.57296383",
"0.5694964",
"0.56835365",
"0.5665... | 0.8243737 | 0 |
Delete VPN connection. ec2.delete_vpn_connection("vpna9a643c0") => true | def delete_vpn_connection(vpn_connection_id)
link = generate_request("DeleteVpnConnection", 'VpnConnectionId' => vpn_connection_id )
request_info(link, RightHttp2xxParser.new(:logger => @logger))
rescue Exception
on_exception
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n requires :vpn_connection_id\n\n service.delete_vpn_connection(vpn_connection_id)\n true\n end",
"def destroy\n @vpn = Vpn.find(params[:id])\n checkaccountobject(\"vpns\",@vpn)\n @vpn.send_delete\n\n respond_to do |format|\n format.html { redirect_t... | [
"0.8566948",
"0.6577365",
"0.6408355",
"0.6338869",
"0.6139732",
"0.6011228",
"0.6007342",
"0.59931576",
"0.5975029",
"0.5954041",
"0.5954041",
"0.593591",
"0.5904912",
"0.5869909",
"0.5847338",
"0.58333385",
"0.58041346",
"0.579174",
"0.5732727",
"0.57266825",
"0.5715345",
... | 0.7710807 | 1 |
Build score keeper if it is enabled via settings | def batali_build_score_keeper
if(batali_least_impact?)
Chef::Log.warn "Batali 'least impact resolution' is currently enabled!"
if(node[:batali] && node[:batali][:last_resolution])
Batali::ScoreKeeper.new(
:manifest => Batali::Manifest.new(
:cookbooks => node[:batali][:last_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_score_tree\n tree_nodes = []\n root_node = nil\n\n @nodes.each do |n|\n if n['key'] == 1\n root_node = build_node_from_model(n)\n root_node['parent_id'] = 0\n else\n tree_nodes.push(build_node_from_model(n))\n end\n end\n\n node_list = { 1 => root_node }... | [
"0.55239743",
"0.5172838",
"0.50185764",
"0.49578756",
"0.48621836",
"0.48131984",
"0.47761005",
"0.47544083",
"0.47504866",
"0.47458765",
"0.46919346",
"0.4677389",
"0.46730867",
"0.4667838",
"0.46658063",
"0.46630818",
"0.4653106",
"0.46260557",
"0.46077943",
"0.46077755",
... | 0.5560613 | 0 |
Read in the table JSON | def readTable(path)
return JSON.parse(File.read(path).rstrip)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_table (filename)\n\t\t\tnew_table = File.open(filename)\n\t\t\t@file_table = JSON.load(new_table)\n\t\t\tnew_table.close\n\t\tend",
"def table\n self.class.read_and_parse_file(@table_path)\n end",
"def parse_json(json_)\n ::NTable.parse_json(json_)\n end",
"def get_data\n rais... | [
"0.7256125",
"0.69474566",
"0.6754364",
"0.66707605",
"0.64308697",
"0.6232659",
"0.60649",
"0.60297436",
"0.602133",
"0.5964239",
"0.5830802",
"0.5751797",
"0.56991273",
"0.56991273",
"0.5664855",
"0.5638613",
"0.56268764",
"0.56209123",
"0.5603976",
"0.55999094",
"0.5592211... | 0.80408955 | 0 |
Set the "slimmer headers" to configure the page | def set_slimmer_headers(hash)
raise InvalidHeader if (hash.keys - SLIMMER_HEADER_MAPPING.keys).any?
SLIMMER_HEADER_MAPPING.each do |hash_key, header_suffix|
value = hash[hash_key]
headers["#{HEADER_PREFIX}-#{header_suffix}"] = value.to_s if value
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_headers! session = nil\n response.headers['sid'] = session.id\n response.headers['utoken'] = session.utoken\n end",
"def add_headers; end",
"def show_headers=(value)\n @show_headers = value\n end",
"def on_header_init()\n end",
"def kopal_layout_before_page_heade... | [
"0.64804345",
"0.61778986",
"0.6094569",
"0.60413307",
"0.6010624",
"0.6004721",
"0.59677815",
"0.5965604",
"0.59422946",
"0.59367436",
"0.5924764",
"0.59143287",
"0.59120494",
"0.5895154",
"0.5886509",
"0.5886509",
"0.5886509",
"0.5886509",
"0.5886509",
"0.5886509",
"0.58865... | 0.63729626 | 1 |
Create or update L2 Bridge Endpoint Profile API will create or update L2 bridge profile with ID profileid. L2 Bridge profile is only allowed under an enforcementpoint with path /infra/sites/default/enforcementpoints/default. | def update_l2_bridge_profile_with_http_info(site_id, enforcement_point_id, profile_id, l2_bridge_endpoint_profile, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: PolicyNetworkingConnectivitySegmentsEdgeBridgeProfilesApi.update_l2_bridge_profile ...'
end
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_l2_bridge_profile_0_with_http_info(site_id, enforcement_point_id, profile_id, l2_bridge_endpoint_profile, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: PolicyNetworkingConnectivitySegmentsEdgeBridgeProfilesApi.update_l2_bridge_profile_0 ...'\n ... | [
"0.74238",
"0.72147363",
"0.7183777",
"0.7162514",
"0.7139919",
"0.68746734",
"0.6780593",
"0.67534924",
"0.6525527",
"0.65236706",
"0.6434839",
"0.6292552",
"0.626511",
"0.6154161",
"0.60921836",
"0.6080533",
"0.6035727",
"0.60206205",
"0.59959066",
"0.59720224",
"0.5951914"... | 0.7440173 | 0 |
Create or update L2 Bridge Endpoint Profile API will create or update L2 bridge profile with ID profileid. L2 Bridge profile is only allowed under an enforcementpoint with path /infra/sites/default/enforcementpoints/default. | def update_l2_bridge_profile_0_with_http_info(site_id, enforcement_point_id, profile_id, l2_bridge_endpoint_profile, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: PolicyNetworkingConnectivitySegmentsEdgeBridgeProfilesApi.update_l2_bridge_profile_0 ...'
end
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_l2_bridge_profile_with_http_info(site_id, enforcement_point_id, profile_id, l2_bridge_endpoint_profile, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: PolicyNetworkingConnectivitySegmentsEdgeBridgeProfilesApi.update_l2_bridge_profile ...'\n ... | [
"0.7441519",
"0.7215665",
"0.71844035",
"0.71624964",
"0.7139739",
"0.6875108",
"0.6781137",
"0.67538905",
"0.65258217",
"0.65243983",
"0.64351976",
"0.629415",
"0.6266634",
"0.615254",
"0.60908175",
"0.60808843",
"0.6036305",
"0.60189813",
"0.5993805",
"0.5972299",
"0.595081... | 0.7424836 | 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 volum... | {
"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 |
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 { re... | {
"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 |
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 |
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 |
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 refer... | 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)
el... | {
"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 |
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 |
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 |
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
)
adjustmen... | {
"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,
I1... | {
"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 |
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 |
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 }
... | {
"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 |
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 |
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 |
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 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... | {
"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 |
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 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 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 ... | {
"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... | {
"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 |
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 |
end test Test that the graph class will not let you to_s on an incomplete graph | def test_graph_to_s_incomplete
sut_graph = Graph.new
sut_graph.name="test_graph"
#sut_graph.type=:digraph
sut_graph.node_style=:ellipse
sut_graph.add_edge("TEST1" , "TEST2" , "take_me_to_test_2")
assert_raises RuntimeError do
returned_obj = sut_graph.to_s
end # end asser... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_to_s_empty_graph\n graph = Graph.new\n\n assert(graph.to_s == '')\n end",
"def test_to_s\n graph = DirectedGraph.new\n vertex_a = Vertex.new('a')\n vertex_b = Vertex.new('b')\n vertex_c = Vertex.new('c')\n graph.add_vertex(vertex_a).add_vertex(vertex_b).add_vertex(vertex_c)\n gr... | [
"0.8240558",
"0.7790349",
"0.77343917",
"0.767811",
"0.7484956",
"0.68562925",
"0.6537316",
"0.65276414",
"0.65032285",
"0.6472538",
"0.6434005",
"0.63676643",
"0.6310323",
"0.6239692",
"0.6239692",
"0.6225078",
"0.61920583",
"0.61881006",
"0.61529404",
"0.611738",
"0.607198"... | 0.8398824 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.