query stringlengths 7 9.55k | document stringlengths 10 363k | metadata dict | negatives listlengths 0 101 | negative_scores listlengths 0 101 | document_score stringlengths 3 10 | document_rank stringclasses 102 values |
|---|---|---|---|---|---|---|
Convenience method to update the delay value for the current type. Returns false if the health monitor is not enabled or is not an http monitor, the new value if it succeeds, and raises an exception otherwise. | def body_regex=(value)
return false unless @enabled && ['HTTP','HTTPS'].include?(self.type)
update(:type => self.type, :body_regex => value)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delay=(value)\n return false unless @enabled\n update(:type => self.type, :delay => value)\n end",
"def delay=(value)\n\t\t\t@delay = value\n\t\tend",
"def delay=(value)\n\t\t\t@delay = value\n\t\tend",
"def delay(value)\n model.delay = value\n end",
"def delay(value)\n ... | [
"0.68817335",
"0.6076384",
"0.6076384",
"0.5865073",
"0.5865073",
"0.57650197",
"0.5617089",
"0.56079096",
"0.56066304",
"0.55951947",
"0.55925936",
"0.5566893",
"0.5532277",
"0.5370051",
"0.53396606",
"0.53258497",
"0.53172684",
"0.52903444",
"0.5277283",
"0.52732867",
"0.52... | 0.0 | -1 |
Removes the current health monitor. Returns true if successful, exception otherwise. >> monitor.destroy! => true | def destroy!
response = @connection.lbreq("DELETE",@lbmgmthost,"#{@lbmgmtpath}/loadbalancers/#{CloudLB.escape(@load_balancer.id.to_s)}/healthmonitor",@lbmgmtport,@lbmgmtscheme)
CloudLB::Exception.raise_exception(response) unless response.code.to_s.match(/^20.$/)
@enabled = false
true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def stop_monitor\n self.monitor.kill if self.monitor\n self.monitor = nil\n end",
"def delete(monitor_instance_id)\n if @monitors.key?(monitor_instance_id)\n @monitors.delete(monitor_instance_id)\n end\n end",
"def delete_monitor monitor_name\n response = RestClient.delete(\"htt... | [
"0.6627919",
"0.5984936",
"0.59543437",
"0.5859098",
"0.57966596",
"0.562554",
"0.5597796",
"0.55347276",
"0.5470935",
"0.5425685",
"0.5413738",
"0.5387723",
"0.5339462",
"0.5324221",
"0.52160877",
"0.51552993",
"0.50998926",
"0.5078183",
"0.5039362",
"0.5033613",
"0.49981368... | 0.6022731 | 1 |
This is the games controller | def games
@remember_token = User.hash_token(cookies[:remember_token])
@user = User.find_by(remember_token: @remember_token)
# defaultParams.merge(params) Will keep defaults and new ones will overwrite dup keys
if (!params[:order])
params[:order] = ""
end
games = getInventoryFromSelector(Ownership, :games)
if (params.has_key?(:console_id))
@ownership = games.where(:console_general => {:eng_name => params[:console_id]})
else # Make some config or user set results per page
@ownership = games.all
end
@image = Image.all
@gameConsoles = Ownership.where(user_id: @user).joins(:games => :console_general).order("eng_name").uniq.pluck(:eng_name)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @games = current_creator.games\n redirect_to root_path\n end",
"def index\n\t\t@games = Game.all\n\tend",
"def index\n @games = Game.all\n end",
"def index\n @games = Game.all\n end",
"def index\n @games = Game.all\n end",
"def index\n @games = Game.all\n end",
"def i... | [
"0.7696546",
"0.76638573",
"0.7568997",
"0.7567566",
"0.7567566",
"0.7567566",
"0.7567566",
"0.7567566",
"0.7567566",
"0.7567566",
"0.7567566",
"0.7567566",
"0.7567566",
"0.7567566",
"0.7567566",
"0.7567566",
"0.7567566",
"0.7567566",
"0.7567566",
"0.7567566",
"0.7567566",
... | 0.0 | -1 |
Allows +Model.for_search_params+ to do equalitybased searching for the given +attr_names+. Date attributes (ending in "_on") will take Rubyparseable date strings as well as the common US case "mm/dd/yyyy". searchable :first_name, :last_name, :born_on | def searchable(*attr_names)
attr_names.each do |attr_name|
scope "search_#{attr_name}", -> attr_value do
where(attr_name => (attr_name =~ /_on$/ ? parse_date_string(attr_value) : attr_value))
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def criterion_list searchable_attr = {}, formats ={}, criteria = {}\n\n searchable_attr.each{|attr|\n criterion_key = attr_2_criterion_sym(attr)\n #operator_key = attr_2_operator(attr)\n if params[criterion_key] then\n if not params[criterion_key].blank? then\n if criterion_key.to... | [
"0.6207823",
"0.591569",
"0.58887076",
"0.584572",
"0.5769055",
"0.5568031",
"0.55450124",
"0.5537399",
"0.5518184",
"0.548063",
"0.54466534",
"0.54076564",
"0.53269756",
"0.53159285",
"0.5294487",
"0.527706",
"0.5255387",
"0.5232297",
"0.5230948",
"0.5229895",
"0.52182484",
... | 0.8257089 | 0 |
Time complexity: O(n) => Because it loops 1 time in 'reverse' method depending on the input size, and it loops 1 time in 'reverse_sentence' method. Since a constant drops, it becomes O(n) Space complexity: O(1) => Because it does not create any extra array. | def reverse!(string, i, j) # " I can do this! "
while i < j
string[i], string[j] = string[j], string[i]
# # same as above
# temp = string[i]
# string[i] = string[j]
# string[j] = temp
i += 1
j -= 1
end
return string # " !siht od nac I "
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reverse_sentence(sentence)\n array = sentence.split(' ')\n reverse_array = []\n idx = array.size\n\n loop do\n idx -= 1\n break if idx < 0\n reverse_array << array[idx]\n end\n\n reverse_array.join(' ')\nend",
"def reverse_words(sentence)\n arr_of_words = split_sentence(sentence)\n arr_of_re... | [
"0.7852244",
"0.77709776",
"0.77423114",
"0.77300787",
"0.7554715",
"0.75056994",
"0.74355966",
"0.7396846",
"0.7384749",
"0.7379366",
"0.7362837",
"0.7339589",
"0.73385704",
"0.7324409",
"0.7316939",
"0.7311594",
"0.73070496",
"0.7303315",
"0.7302605",
"0.7302605",
"0.729887... | 0.0 | -1 |
Create ID from current timestamp this, obviously, can be called exactly and only once in an object's lifetime. | def new_timestamp_and_uuid()
u = UUID.timestamp_create()
[u.hexdigest, u.timestamp]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def id\n @id ||= Time.now.utc.to_i\n end",
"def make_id\n Time.now.to_f.to_s.ljust(16, '0') + rand(10).to_s\n end",
"def generate_temporary_id\n (Time.now.to_f*1000).to_i.to_s\n end",
"def generate_id(_)\n accurate_timestamp = (Time.now.to_f * 1000).round\n time_part = (accu... | [
"0.74145633",
"0.7164073",
"0.7049503",
"0.7027662",
"0.69806236",
"0.68769115",
"0.6836673",
"0.6817502",
"0.66826814",
"0.6678174",
"0.6647231",
"0.66210765",
"0.6604489",
"0.65806615",
"0.656927",
"0.655393",
"0.6540355",
"0.65176755",
"0.65074134",
"0.6487702",
"0.6487702... | 0.0 | -1 |
Create namespaced ID from the instance method given to acts_as_snowflake (some method which guaranteed intrinsic uniqueness a URL, say, or a permalink) | def namespaced_uuid()
UUID.sha1_create(self.class.uuid_namespace, self.send(self.class.uuid_generating_method)).hexdigest
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_id\n \"#{self.class.name.downcase}#{id}\"\n end",
"def tag_id\n \"#{sanitized_object_name}_#{sanitized_method_name}\"\n end",
"def to_id\n\t\treturn self.\n\t\t\tgsub(\"::\", \"\").\n\t\t\tgsub(/([A-Z]+)([A-Z][a-z])/,'\\1_\\2').\n\t\t\tgsub(/([a-z\\d])([A-Z])/,'\\1_\\2').\n\t\t\tdo... | [
"0.62714684",
"0.6266793",
"0.61359364",
"0.60451907",
"0.6012351",
"0.5975649",
"0.59534305",
"0.5949041",
"0.59419",
"0.5904787",
"0.5904787",
"0.5900741",
"0.5756918",
"0.5754005",
"0.56980914",
"0.5688284",
"0.56838524",
"0.5627143",
"0.562359",
"0.5618909",
"0.5609349",
... | 0.6300916 | 0 |
Retrieve a file from the filesystem, based on the calculated store_dir and the filename stored in the database. | def retrieve(filename, instance = nil, attribute = nil, options = {}) #:nodoc:
self.new(:retrieve, filename, instance, attribute, options)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_file_named name\n @store.find_file_named name\n end",
"def stored_file_path\n File.join(path, stored_name)\n end",
"def retrieve!(identifier)\n File.new(uploader, self, uploader.store_path(identifier))\n end",
"def retrieve!(identifier)\n self.class.configure_qcloud_sdk(up... | [
"0.6791648",
"0.6456668",
"0.63623524",
"0.6324057",
"0.6178648",
"0.61600244",
"0.61600244",
"0.6151353",
"0.61383575",
"0.60007495",
"0.59835124",
"0.59783983",
"0.5911264",
"0.5891454",
"0.58463174",
"0.58177775",
"0.5812456",
"0.578017",
"0.5746379",
"0.5737273",
"0.57355... | 0.0 | -1 |
Retreieve a file that was stored as a temp file | def retrieve_temp(path, instance = nil, attribute = nil, options = {}) #:nodoc:
self.new(:retrieve_temp, path, instance, attribute, options)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tmpfile\n \n unless @tmpfile\n \n return download\n \n end\n \n return @tmpfile\n \n end",
"def download_to_temp_file\n source_key = self.effective_key\n ext = self.format&.extensions&.first || \"tmp\"\n tempfile = Tempfi... | [
"0.7691312",
"0.7332111",
"0.6890964",
"0.6890964",
"0.6821964",
"0.6816823",
"0.6810895",
"0.6745262",
"0.66822535",
"0.659709",
"0.6517863",
"0.64941216",
"0.64708686",
"0.64658666",
"0.64645886",
"0.64344466",
"0.64258504",
"0.6425363",
"0.6417232",
"0.6406318",
"0.637572"... | 0.0 | -1 |
Returns the directory where tmp files are stored for this UploadedFile, relative to :root_dir | def relative_tmp_dir
parse_dir_options(:tmp_dir)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tmp_dir\n File.expand_path(self.relative_tmp_dir, @options[:root_dir])\n end",
"def tmp_dir\n @tmp_dir ||= root / 'tmp'\n end",
"def get_tmp_dir\n return \"#{Dir.tmpdir}/FilesRebuilder\"\n end",
"def tmp_dir\n return Dir.tmpdir if path_of('tmp_dir').nil?\n return path_of('tmp_di... | [
"0.8917042",
"0.80941606",
"0.8021649",
"0.79896575",
"0.79452497",
"0.77799755",
"0.769591",
"0.7695052",
"0.7612141",
"0.7512705",
"0.74828345",
"0.733629",
"0.7198152",
"0.71881074",
"0.7181632",
"0.7140849",
"0.71403235",
"0.7123725",
"0.7115414",
"0.70686316",
"0.7038196... | 0.7826861 | 5 |
Returns the directory where tmp files are stored for this UploadedFile | def tmp_dir
File.expand_path(self.relative_tmp_dir, @options[:root_dir])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_tmp_dir\n return \"#{Dir.tmpdir}/FilesRebuilder\"\n end",
"def tmp_dir\n return Dir.tmpdir if path_of('tmp_dir').nil?\n return path_of('tmp_dir')\n end",
"def temp_dir\n name = 'tmp_' + rand.to_s.gsub(/\\D/, '')\n File.join(@temp_root, name)\n end",
"def tmp_dir\n @tmp_dir ||... | [
"0.819052",
"0.8118195",
"0.7872873",
"0.7868546",
"0.78356504",
"0.7819804",
"0.76912093",
"0.76743865",
"0.75486195",
"0.74656415",
"0.7349417",
"0.73411703",
"0.7313828",
"0.7286001",
"0.72314376",
"0.7217275",
"0.7216671",
"0.7206421",
"0.7182542",
"0.71772563",
"0.711594... | 0.84387743 | 0 |
Returns the directory where files are stored for this UploadedFile, relative to :root_dir | def relative_store_dir
parse_dir_options(:store_dir)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def files_dir\n return File.absolute_path(File.join(@root_dir, 'lib', 'files'))\n end",
"def store_dir\n if Rails.env == \"production\"\n ENV['CONFIG_FILE_UPLOAD_PATH']\n else\n \"uploads\"\n end\n end",
"def store_dir\n raise \"Can't upload files for an unknown u... | [
"0.8034254",
"0.75140756",
"0.74367803",
"0.7360707",
"0.73503864",
"0.7302906",
"0.72121084",
"0.71303934",
"0.71080935",
"0.71080935",
"0.71080935",
"0.71080935",
"0.71080935",
"0.71036386",
"0.70779467",
"0.70674735",
"0.70621413",
"0.70465064",
"0.69920796",
"0.69803447",
... | 0.0 | -1 |
Returns the directory where files are stored for this UploadedFile | def store_dir
File.expand_path(self.relative_store_dir, @options[:root_dir])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def files_dir\n return File.absolute_path(File.join(@root_dir, 'lib', 'files'))\n end",
"def store_dir\n if Rails.env == \"production\"\n ENV['CONFIG_FILE_UPLOAD_PATH']\n else\n \"uploads\"\n end\n end",
"def store_dir\n raise \"Can't upload files for an unknown u... | [
"0.7729136",
"0.76253194",
"0.75435305",
"0.74663854",
"0.7353605",
"0.7321854",
"0.730594",
"0.730594",
"0.730594",
"0.730594",
"0.730594",
"0.7293797",
"0.72683626",
"0.7263094",
"0.72493297",
"0.724176",
"0.7221386",
"0.7217307",
"0.71907794",
"0.7182425",
"0.717423",
"0... | 0.0 | -1 |
Returns the path of the file relative to :root_dir | def relative_path
self.path.sub(File.expand_path(options[:root_dir]) + '/', '')
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def root_file_path; end",
"def file_root(path = '')\n File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..', path))\n end",
"def root_path(path) File.join(root, path) end",
"def relroot\n Pathname.new(File.expand_path(path)).\n relative_path_from(Pathname.new... | [
"0.7819564",
"0.7704712",
"0.76036805",
"0.7540507",
"0.7524881",
"0.75204736",
"0.75198686",
"0.74684554",
"0.74460965",
"0.7441767",
"0.74259174",
"0.7421771",
"0.7387253",
"0.7341055",
"0.73232394",
"0.72543246",
"0.72543246",
"0.7245849",
"0.7191325",
"0.7189784",
"0.7179... | 0.78295726 | 0 |
returns the full path of the file. | def path; super; end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def path\n @file.path\n end",
"def fullpath\n File.expand_path( @file )\n end",
"def get_file_path\n @path\n end",
"def path\n @file\n end",
"def file_path\n File.join(dir,filename)\n end",
"def file_path\n dir\n end",
"def path\n @file.path\... | [
"0.8444844",
"0.8357334",
"0.8300974",
"0.82767045",
"0.82736427",
"0.8195983",
"0.81881636",
"0.81694776",
"0.8158934",
"0.8122875",
"0.8099653",
"0.79950494",
"0.7919896",
"0.7878709",
"0.7827936",
"0.77674913",
"0.77567095",
"0.77423656",
"0.7736344",
"0.77033156",
"0.7681... | 0.0 | -1 |
returns the directory where the file is currently stored. | def dir
File.dirname(self.path)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def current_dir\n File.dirname(file_path)\n end",
"def directory\n File.dirname @path\n end",
"def directory\n File.dirname(@path) + '/'\n end",
"def dir\n @working_directory\n end",
"def containing_directory\n path.dirname\n end",
"def dir\n File.dirn... | [
"0.817147",
"0.8151737",
"0.7895601",
"0.7824955",
"0.7761911",
"0.7753266",
"0.7742757",
"0.7715699",
"0.7707661",
"0.7680336",
"0.75549287",
"0.7502023",
"0.74801034",
"0.7371983",
"0.7367305",
"0.73578525",
"0.7349935",
"0.73481506",
"0.733297",
"0.7316246",
"0.7309208",
... | 0.774434 | 6 |
return true if the file has just been uploaded. | def new_file?
@new_file
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def uploaded?(uploaded_file)\n uploaded_file.storage_key == storage_key.to_s\n end",
"def uploaded?( filename, buffer )\n return false if @upload_dir.nil?\n\n savedfile = \"#{@upload_dir}/#{filename}\"\n return false unless File.exist?( savedfile )\n\n old = File.read( savedfi... | [
"0.75458515",
"0.74913377",
"0.73320407",
"0.72018564",
"0.69525474",
"0.69102746",
"0.688982",
"0.68801033",
"0.68694013",
"0.6859565",
"0.6820747",
"0.6801161",
"0.6773614",
"0.67502207",
"0.6749296",
"0.67491275",
"0.6742957",
"0.6724087",
"0.67143565",
"0.6683608",
"0.658... | 0.668375 | 19 |
returns the url of the file, by merging the relative path with the web_root option. | def public_path
# TODO: this might present an attack vector if the file is outside the web_root
options[:web_root].to_s + '/' + self.relative_path.gsub("\\", "/")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def url(options = {})\n if file.respond_to?(:url)\n tmp_url = file.method(:url).arity.zero? ? file.url : file.url(options)\n return tmp_url if tmp_url.present?\n end\n\n if file.respond_to?(:path)\n path = encode_path(file.path.sub(File.expand_path(root), ''))\n\n ... | [
"0.7806334",
"0.7460358",
"0.7424791",
"0.7263887",
"0.7171022",
"0.7136243",
"0.7017039",
"0.7009962",
"0.7009962",
"0.7009962",
"0.69828564",
"0.69804144",
"0.6970337",
"0.6915831",
"0.6847198",
"0.68245906",
"0.68220896",
"0.6810768",
"0.6796626",
"0.6789026",
"0.67888916"... | 0.6772832 | 21 |
this is the value returned when avatar_temp is called, where avatar is an upload_column | def temp_value #:nodoc:
if tempfile?
if original_filename
%(#{@temp_name}/#{filename};#{original_filename})
else
%(#{@temp_name}/#{filename})
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def avatar\n @data['avatar']\n end",
"def avatar\n @data['avatar']\n end",
"def avatar_file\n @attributes[:avatar_file]\n end",
"def avatar\n if object.dp.present?\n k = object.dp.url.gsub('upload','upload/g_face,c_thumb,w_150,h_150')\n else\n k = object.avatar\n end\n end... | [
"0.7060572",
"0.7060572",
"0.69240475",
"0.6830996",
"0.6807751",
"0.6807751",
"0.6607059",
"0.65829194",
"0.65310305",
"0.65066284",
"0.6438627",
"0.64014286",
"0.6387693",
"0.6387693",
"0.6367911",
"0.6359177",
"0.6346424",
"0.6255814",
"0.6240763",
"0.6220346",
"0.6193119"... | 0.0 | -1 |
TODO: this is a public method, should be specced | def move_to_directory(dir)
p = File.join(dir, self.filename)
if copy_file(p)
@path = p
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def private; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def probers; end",
"def schubert; end",
"def implementation; end",
"def implementation; end",
"def custom; end",
"def custom; end",
"def identify; end",
"def refutal()\n end",
"def weber; en... | [
"0.7712056",
"0.673119",
"0.673119",
"0.673119",
"0.673119",
"0.64687943",
"0.63749635",
"0.6203464",
"0.6203464",
"0.6079689",
"0.6079689",
"0.60192215",
"0.6017107",
"0.59162885",
"0.5862696",
"0.5795702",
"0.5789549",
"0.57723945",
"0.57695085",
"0.57695085",
"0.5726146",
... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def postular_params
params.require(:postular).permit(:user_id, :idea_id, :oferta)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",... | 0.0 | -1 |
CORRECT. This works, but the only thing is that if one of the numbers is correct but the other incorrect, it makes you start over, instead of saving the correct number and only asking for the incorrect number again. Better userexperience if it saves the correct number. Provided answer: | def valid_number?(number_string)
number_string.to_i.to_s == number_string && number_string.to_i != 0
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def number2(second_guess)\n\tsecond_guess = gets.chomp\n\n\tif second_guess == secret_number\n\t\tputs \"Yes, #{second_guess} is correct. You win Secret Number!\"\n\telse\n\t\tputs \"#{second_guess} is not correct either. You have one more guess.\"\n\t\tlast_guess = number3(last_guess)\n\tend\n\nend",
"def corre... | [
"0.6851531",
"0.678858",
"0.67764306",
"0.6749121",
"0.662466",
"0.6441788",
"0.644089",
"0.64037716",
"0.63041025",
"0.63026345",
"0.62936467",
"0.62707734",
"0.6222373",
"0.62178457",
"0.61663383",
"0.6161383",
"0.6161072",
"0.6153368",
"0.61277115",
"0.6122439",
"0.6118498... | 0.0 | -1 |
pega o tempo disposto: Min:seg.ms e torna em ms | def time_in_ms(time)
time_string = time.split(':')
milliseconds = time_string.last.split('.').last
totalmilliseconds = time_string.last.split('.').first.to_i * 1000 + milliseconds.to_i
minutes = time_string.first.to_i * 60000
return totalmilliseconds + minutes
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tempo(beats_per_second)\n\t\tbeats_per_minute = beats_per_second * 60 \n\tend",
"def minutos(seg)\n return seg.to_f / 60\nend",
"def ms_to_min(ms)\n tempo = (ms.to_f / 1000) / 60\n return tempo\nend",
"def tRestante(concurso)\n return ((terminaC(concurso) - DateTime.now) / 60)\n end",
"def tRest... | [
"0.69392085",
"0.6896207",
"0.6660327",
"0.6538816",
"0.6538816",
"0.6461947",
"0.63786054",
"0.6353768",
"0.63272274",
"0.6305986",
"0.6270926",
"0.62687045",
"0.62443006",
"0.61832345",
"0.6163245",
"0.6155202",
"0.6105759",
"0.6087531",
"0.60696393",
"0.6065554",
"0.606554... | 0.56591666 | 59 |
turns a amount of ms into minutes converte uma quantidade de ms em minutos | def ms_to_min(ms)
tempo = (ms.to_f / 1000) / 60
return tempo
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def seconds_to_minutes(seconds)\n seconds / 60\nend",
"def minutes() 60 * seconds end",
"def seconds_in_minutes(num_min)\n\tnum_min * 60\nend",
"def to_minutes; Rational === @val ? @val/60 : @val/60.0 end",
"def time_in_ms(time)\n time_string = time.split(':')\n\n milliseconds = time_string.last.split('... | [
"0.79079336",
"0.74864364",
"0.74320793",
"0.7255307",
"0.7239944",
"0.7224875",
"0.72056425",
"0.7181202",
"0.7058388",
"0.6949478",
"0.693768",
"0.6899149",
"0.6868244",
"0.6825859",
"0.6792967",
"0.6787714",
"0.6787714",
"0.6710452",
"0.66967344",
"0.6662978",
"0.6651344",... | 0.7840582 | 1 |
subrecords of ours include :address | def addresses
query(:address)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def addresses; end",
"def address_results \n @address_results\n end",
"def addresses(aptArr)\n aptArr.each do |apt|\n #puts apt[:address]\n end\n end",
"def addresses\n collect { |a| a.address }\n end",
"def extract_addresses(address_list)\n addresse... | [
"0.6420966",
"0.6109762",
"0.6055216",
"0.5983212",
"0.59642756",
"0.59132963",
"0.59048325",
"0.58421206",
"0.57869",
"0.57858795",
"0.57798004",
"0.57555455",
"0.5729808",
"0.5708194",
"0.56929094",
"0.5688735",
"0.5642913",
"0.5623785",
"0.5608693",
"0.5600032",
"0.5594321... | 0.61726993 | 1 |
User inputs their string for coding or decoding Encryption initializes a counter for the index number, advances accross the string, and uses the .next function to increment the current letter, and adds it to a created empty string. The program checks for instances of "aa" then replaces them with the appropriate character, "z" decryption initializes a counter for the index number, and similarly advances accross the string Using the given alphabet string, the decryption function finds the given letters position on the alphabet, decrements the new index counter, finds the new letter at the new position, and pushes it to a new decrypted string The nested call should work since the argument is merely calling for the program to execute another function in order to provide the data required to finish the desired 'forwards backwards' function. | def intro()
puts "Greetings Agent. Encryption or decryption today? (e/d)"
confirm = gets.chomp
if confirm == "e"
puts "enter string for encryption"
input = gets.chomp
puts "#{input} encrypted: #{encryption(input)}"
elsif confirm == "d"
puts "enter string for decryption"
input = gets.chomp
puts "#{input} decrypted: #{decryption(input)}"
else
puts "confirmed for decryption decryption protocol, 'swordfish'"
puts "de-encrypt complete: #{decryption(encryption("swordfish"))}"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def encrypt(string_to_encrypt) # Create a function accepting string variable as parameter\n\tcontrol = 0\t# Set control variable to 0 \n\twhile control < string_to_encrypt.length # check if the control variable is less than length of the passed string. If yes run the code in the while loop\n\t\tif string_to_encryp... | [
"0.74536467",
"0.7354128",
"0.73444414",
"0.73321474",
"0.7313686",
"0.72016436",
"0.7200966",
"0.7185047",
"0.7172702",
"0.7162797",
"0.7138321",
"0.7051633",
"0.7038546",
"0.7037635",
"0.7032029",
"0.6973299",
"0.69443303",
"0.6922115",
"0.69184697",
"0.6909574",
"0.6895062... | 0.0 | -1 |
Create a new task. If supplied, +interval+ and +proc+ correspond to their respective methods. | def initialize(interval=nil, proc=nil)
self.interval = interval
self.proc = proc
self.thread = nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_task(interval, &block)\n tasks << Task.new(interval, block)\n end",
"def create_task name, url, cron, enabled = nil, timeout = nil, mail_when_success = false, mail_when_failure = false, timezone = nil\n connection.create_task(id, name, url, cron, enabled, timeout, mail_when_success, mail_whe... | [
"0.7326846",
"0.6050408",
"0.58623046",
"0.5852967",
"0.57322335",
"0.5720159",
"0.5690832",
"0.5681433",
"0.5648331",
"0.5570479",
"0.55599856",
"0.555268",
"0.5550335",
"0.55340755",
"0.5506508",
"0.5444165",
"0.54219663",
"0.54173684",
"0.5415679",
"0.53840053",
"0.5374359... | 0.67977387 | 1 |
Run the block or Proc associated with a task. | def run
self.proc.call
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run(&block)\n task('run').tap do |t|\n t.enhance &block if block\n end\n end",
"def task_run(&block) \n task(&block).start\n end",
"def task(*args, &block)\n Util.task(*args, &block)\n end",
"def task(&block) \n task = TaskRunnable.new\n task.proc = Proc.ne... | [
"0.7680454",
"0.76485217",
"0.7135619",
"0.70722413",
"0.7040703",
"0.6762098",
"0.6761985",
"0.65786314",
"0.65717775",
"0.6527718",
"0.6523105",
"0.6516295",
"0.6513155",
"0.6485164",
"0.6485164",
"0.6485164",
"0.6485164",
"0.64822865",
"0.64822865",
"0.64738846",
"0.644660... | 0.6829398 | 5 |
Schedule the task. This actually starts a thread that waits until the specified time interval has passed, then adds the task to a run queue that the main +Scheduler+ object waits on. | def schedule(scheduler)
case self.interval
when :startup, :shutdown
# ignore it
else
self.thread = Thread.new do
loop do
sleep self.interval
scheduler.run_queue << self
end
end
self.thread.abort_on_exception = true
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def periodically_trigger_task(task_name = nil, interval = 1, &block)\n periodically(interval) do\n trigger_task(task_name, &block)\n end\n end",
"def periodically_trigger_task(task_name = nil, interval = 1, &block)\n periodically(interval) do\n trigger_task(task_name, &block)\n end\n end"... | [
"0.6735218",
"0.6735218",
"0.6190001",
"0.60922134",
"0.60785",
"0.6013649",
"0.6009647",
"0.5894305",
"0.58761656",
"0.5788226",
"0.5784376",
"0.568933",
"0.5682004",
"0.56805176",
"0.5656025",
"0.5606173",
"0.56012076",
"0.556172",
"0.5534466",
"0.5522611",
"0.5458805",
"... | 0.6921817 | 0 |
Create a new schedule. The object's +schedule+ method, if any, will be called to create the schedule. Note that the schedule's +run+ method must be called to get actually start the schedule. | def initialize
self.tasks = Array.new
self.run_queue = Queue.new
self.schedule
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_schedule(body, opts = {})\n data, _status_code, _headers = create_schedule_with_http_info(body, opts)\n return data\n end",
"def schedule\n # implemented by subclass\n end",
"def schedule\n @schedule || Schedule.new\n end",
"def initialize\n @tag_name = self.cla... | [
"0.67916685",
"0.6557806",
"0.6494572",
"0.6469423",
"0.642208",
"0.6297236",
"0.6263814",
"0.6263814",
"0.6263814",
"0.62406576",
"0.62113905",
"0.6180685",
"0.61663043",
"0.61582005",
"0.6135242",
"0.61184967",
"0.60495806",
"0.60320395",
"0.60247713",
"0.60214955",
"0.6018... | 0.6274072 | 6 |
Add a task to the schedule. If +interval+ is a number (Fixnum or Float), it represents the number of seconds to wait between successive runs of the task. If +interval+ is a Time or Date object, the task will be run once at the specified time | def add_task(interval, &block)
tasks << Task.new(interval, block)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def periodically_trigger_task(task_name = nil, interval = 1, &block)\n periodically(interval) do\n trigger_task(task_name, &block)\n end\n end",
"def periodically_trigger_task(task_name = nil, interval = 1, &block)\n periodically(interval) do\n trigger_task(task_name, &block)\n end\n end"... | [
"0.6807595",
"0.6807595",
"0.64148045",
"0.63466895",
"0.6201277",
"0.616886",
"0.6147301",
"0.60302144",
"0.60302144",
"0.596489",
"0.59231305",
"0.5899942",
"0.5818921",
"0.5806204",
"0.5791733",
"0.57586944",
"0.562693",
"0.56242144",
"0.5621583",
"0.5581693",
"0.55715626"... | 0.7794959 | 0 |
Return all tasks that should be run at startup. | def startup_tasks
self.tasks.select { |t| t.interval == :startup }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def collect_tasks\n @top_level_tasks = []\n ARGV.each do |arg|\n if arg =~ /^(\\w+)=(.*)$/\n ENV[$1] = $2\n else\n @top_level_tasks << arg unless arg =~ /^-/\n end\n end\n @top_level_tasks.push(\"default\") if @top_level_tasks.size == 0\n end",
"def a... | [
"0.74070156",
"0.7296949",
"0.72532713",
"0.7242283",
"0.7216893",
"0.7216893",
"0.7200142",
"0.71659696",
"0.71349317",
"0.70957625",
"0.70800424",
"0.70732987",
"0.70547897",
"0.6996462",
"0.6990743",
"0.6955508",
"0.6951715",
"0.6935978",
"0.6923637",
"0.6914516",
"0.69139... | 0.83647007 | 0 |
Return all tasks that should be run at shutdown. | def shutdown_tasks
self.tasks.select { |t| t.interval == :shutdown }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def scheduled_tasks\n self.tasks.select { \n |t| t.interval != :startup && t.interval != :shutdown\n }\n end",
"def startup_tasks\n self.tasks.select { |t| t.interval == :startup }\n end",
"def all_tasks\n @all_tasks ||= []\n end",
"def all_tasks_to_run\n self.all_tas... | [
"0.74999547",
"0.6925326",
"0.67300475",
"0.6700755",
"0.6670325",
"0.6650546",
"0.6626348",
"0.65551203",
"0.6524475",
"0.64689064",
"0.64141977",
"0.6407539",
"0.6407539",
"0.63943416",
"0.6394324",
"0.6362615",
"0.6319951",
"0.63094974",
"0.62779015",
"0.62779015",
"0.6277... | 0.8636883 | 0 |
Return all tasks that should be scheduled. | def scheduled_tasks
self.tasks.select {
|t| t.interval != :startup && t.interval != :shutdown
}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def all\n return @tasks\n end",
"def all_tasks\n @all_tasks ||= []\n end",
"def actionable_tasks\n\t\tnext_tasks.select{ |t| !t.deferred? }\n\tend",
"def get_available_tasks\n tasks_to_return = []\n @tasks_names.each{ |t_name|\n tasks_to_return.push(@tasks[t_name])\n } \n return ... | [
"0.755841",
"0.7515138",
"0.7395462",
"0.7377336",
"0.7280098",
"0.7211653",
"0.7194062",
"0.7185912",
"0.7148841",
"0.7148841",
"0.7096222",
"0.70657027",
"0.7065685",
"0.706109",
"0.7060252",
"0.70578",
"0.70578",
"0.70578",
"0.70457184",
"0.6986516",
"0.6980086",
"0.6947... | 0.84459335 | 0 |
Various helpful aliases that encourage readable schedules. | def second; 1.second; end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def aliases; end",
"def aliases; end",
"def aliases; end",
"def aliases\n end",
"def aliases\n short ? [name, short] : [name]\n end",
"def aliases\n\n end",
"def alias_names; end",
"def aliases\n myAliases = \"\"\n if ['Mount ',' Mountain',' Peak'].any? {|word| self.name.inclu... | [
"0.682253",
"0.682253",
"0.682253",
"0.6611162",
"0.64962786",
"0.649542",
"0.63009393",
"0.6281305",
"0.6066121",
"0.60516256",
"0.60121065",
"0.60121065",
"0.58852744",
"0.58202267",
"0.58199185",
"0.58092713",
"0.57157034",
"0.5689937",
"0.5660003",
"0.56409025",
"0.563577... | 0.0 | -1 |
Set up schedules. This method should be implemented by a subclass of Scheduler. | def schedule
# implemented by subclass
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_schedule!\n @schedule ||= load_default_schedule\n\n fail 'You should setup a schedule or place it in config/schedule.yml' unless schedule\n\n schedule.each do |name, config|\n # If rails_env is set in the config, enforce ENV['RAILS_ENV'] as\n # required for the jobs to be sche... | [
"0.7221451",
"0.65280867",
"0.641248",
"0.6391269",
"0.63749164",
"0.63611025",
"0.6322785",
"0.6266604",
"0.62494344",
"0.62494344",
"0.62494344",
"0.6182044",
"0.61681676",
"0.6110153",
"0.61048746",
"0.60518914",
"0.6046614",
"0.6042762",
"0.6042762",
"0.6037323",
"0.60331... | 0.6573526 | 1 |
Start a schedule. If +period+ is supplied, the schedule will only run for that many seconds. Otherwise, it will run forever, or until there are no tasks to run. | def start(period=nil)
# Run any startup tasks.
self.startup_tasks.each { |t| t.run }
# If caller only wants to run for a while, start a thread that will
# sleep that long, then kill off all the threads. +nil+ is posted to
# the queue as a signal that the scheduler should stop running.
if period
Thread.new do
Thread.abort_on_exception = true
sleep period
self.scheduled_tasks.each {
|t| t.thread.exit if t.thread && t.thread.alive? }
self.run_queue << nil
end
end
# Schedule all the tasks.
self.scheduled_tasks.each { |t| t.schedule(self) }
# Run any tasks whose threads have placed the task onto the run
# queue, until +nil+ is received.
while (task = self.run_queue.pop) do
task.run
end
# Run any shutdown tasks.
self.shutdown_tasks.each { |t| t.run }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def periodic period, options={}, &block\n worker([], options.merge({:with_period => period}), &block)\n end",
"def schedule_every (freq, params={}, &block)\n\n params = prepare_params(params)\n params[:every] = freq\n\n first_at = params[:first_at]\n first_in = params[:first_in]\n\n ... | [
"0.6499388",
"0.6206337",
"0.5930672",
"0.57904136",
"0.5744161",
"0.5512998",
"0.54905796",
"0.5474985",
"0.5474985",
"0.53982836",
"0.53610456",
"0.5318919",
"0.529568",
"0.52906144",
"0.5283434",
"0.52251387",
"0.5196062",
"0.519141",
"0.5170202",
"0.5167955",
"0.5111225",... | 0.8104139 | 0 |
GET /notifications GET /notifications.json | def index
@notifications = Notification.with_deleted.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def notifications\n query_api_object Notification, \"/rest/notifications\", nil, \"GET\", \"notifications\"\n end",
"def get_notifications\n begin\n response = notifications_api.get\n [parse_json(response), nil]\n rescue RestClient::Unauthorized\n [{}, Unauthorized]\n end\n end",... | [
"0.8339561",
"0.8280543",
"0.80831534",
"0.76445353",
"0.7561788",
"0.7450535",
"0.7411313",
"0.7227688",
"0.7227688",
"0.72002643",
"0.7156145",
"0.71267486",
"0.71203446",
"0.71198344",
"0.7106039",
"0.7098343",
"0.70976835",
"0.70976835",
"0.70976835",
"0.70976835",
"0.709... | 0.6322093 | 65 |
GET /notifications/1 GET /notifications/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def notifications\n query_api_object Notification, \"/rest/notifications\", nil, \"GET\", \"notifications\"\n end",
"def get_notifications\n begin\n response = notifications_api.get\n [parse_json(response), nil]\n rescue RestClient::Unauthorized\n [{}, Unauthorized]\n end\n end",... | [
"0.76366484",
"0.7468357",
"0.74621856",
"0.7194608",
"0.70602906",
"0.6947561",
"0.68801",
"0.6859424",
"0.6850998",
"0.6815374",
"0.6815356",
"0.6802459",
"0.6802459",
"0.6802459",
"0.6802459",
"0.6802459",
"0.6802459",
"0.67795664",
"0.6767779",
"0.6733075",
"0.6710404",
... | 0.0 | -1 |
POST /notifications POST /notifications.json | def create
session.delete(:return_to)
session[:return_to] ||= request.referer
device_ids = []
if notification_params[:notification_type] === 'division_wise'
@division = Division.find(notification_params[:type_data])
@division.students.each do |student|
@notification = Notification.new(title: notification_params[:title],
message: notification_params[:message],
from: notification_params[:from], student_id: student.id)
@user = User.where(username: student.father_mobile).last
unless device_ids.include?(@user.device_id)
device_ids << @user.device_id
end
@notification.save
if notification_params[:by_mail] == '1'
unless @notification.student.student_email.blank?
NotificationMailer.notify_student(@notification.student, @notification).deliver
end
end
if notification_params[:by_sms] == '1'
send_sms_to_parent(@notification.student, @notification)
end
end
if notification_params[:by_app] == '1'
puts device_ids
require 'fcm'
fcm = FCM.new(ENV['FCM_SERVER_KEY'])
# fcm = init_fcm
# @student = Student.find(notification_params[:student_id])
# @user = User.where(username: @student.father_mobile).last
# device_id = @user.device_id
# registration_ids= [device_id] # an array of one or more client registration tokens
options = {
priority: "high",
collapse_key: "updated_score",
notification: {
title: @notification.title,
body: @notification.message
}
}
response = fcm.send(device_ids, options)
puts response
end
respond_to do |format|
format.html { redirect_to session.delete(:return_to), notice: "Notification was sent successfully to All from division #{@division.name}." }
format.json { render :show, status: :created, location: @notification }
end
elsif notification_params[:notification_type] === 'standard_wise'
counter = 0
device_ids = []
@standard = Standard.find(notification_params[:type_data])
@standard.divisions.each do |division|
division.students.each do |student|
@notification = Notification.new(title: notification_params[:title],
message: notification_params[:message],
from: notification_params[:from], student_id: student.id)
@user = User.where(username: student.father_mobile).last
unless device_ids.include?(@user.device_id)
device_ids << @user.device_id
end
@notification.save
if notification_params[:by_mail] == '1'
unless @notification.student.student_email.blank?
NotificationMailer.notify_student(@notification.student, @notification).deliver
end
end
if notification_params[:by_sms] == '1'
send_sms_to_parent(@notification.student, @notification)
end
end
end
if notification_params[:by_app] == '1'
puts device_ids
require 'fcm'
fcm = FCM.new(ENV['FCM_SERVER_KEY'])
# fcm = init_fcm
# @student = Student.find(notification_params[:student_id])
# @user = User.where(username: @student.father_mobile).last
# device_id = @user.device_id
# registration_ids= [device_id] # an array of one or more client registration tokens
options = {
priority: "high",
collapse_key: "updated_score",
notification: {
title: @notification.title,
body: @notification.message
}
}
response = fcm.send(device_ids, options)
puts response
end
respond_to do |format|
format.html { redirect_to session.delete(:return_to), notice: "Notification was sent successfully to All from standard #{@standard.name}." }
format.json { render :show, status: :created, location: @notification }
end
elsif notification_params[:notification_type] === 'to_all'
device_ids = []
Student.all.each do |student|
@notification = Notification.new(title: notification_params[:title],
message: notification_params[:message],
from: notification_params[:from], student_id: student.id)
@user = User.where(username: student.father_mobile).last
unless device_ids.include?(@user.device_id)
device_ids << @user.device_id
end
@notification.save
if notification_params[:by_mail] == '1'
unless @notification.student.student_email.blank?
NotificationMailer.notify_student(@notification.student, @notification).deliver
end
end
if notification_params[:by_sms] == '1'
send_sms_to_parent(@notification.student, @notification)
end
end
if notification_params[:by_app] == '1'
puts device_ids
require 'fcm'
fcm = FCM.new(ENV['FCM_SERVER_KEY'])
# fcm = init_fcm
# @student = Student.find(notification_params[:student_id])
# @user = User.where(username: @student.father_mobile).last
# device_id = @user.device_id
# registration_ids= [device_id] # an array of one or more client registration tokens
options = {
priority: "high",
collapse_key: "updated_score",
notification: {
title: @notification.title,
body: @notification.message
}
}
response = fcm.send(device_ids, options)
puts response
end
respond_to do |format|
format.html { redirect_to session.delete(:return_to), notice: "Notification was sent successfully to All." }
format.json { render :show, status: :created, location: @notification }
end
elsif notification_params[:notification_type] === 'student_wise'
@notification = Notification.new(notification_params)
@notification.save
if notification_params[:by_mail] == '1'
unless @notification.student.student_email.blank?
NotificationMailer.notify_student(@notification.student, @notification).deliver
end
end
if notification_params[:by_sms] == '1'
send_sms_to_parent(@notification.student, @notification)
end
if notification_params[:by_app] == '1'
require 'fcm'
fcm = FCM.new(ENV['FCM_SERVER_KEY'])
# fcm = init_fcm
@student = Student.find(notification_params[:student_id])
@user = User.where(username: @student.father_mobile).last
device_id = @user.device_id
registration_ids= [device_id] # an array of one or more client registration tokens
options = {
priority: "high",
collapse_key: "updated_score",
notification: {
title: @notification.title,
body: @notification.message,
icon: "http://myschoolcon.com/images/schoolcon_logo.jpeg"
}
}
response = fcm.send(registration_ids, options)
puts response
end
respond_to do |format|
format.html { redirect_to session.delete(:return_to), notice: "Notification was sent successfully." }
format.json { render :show, status: :created, location: @notification }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def post_notification(attributes)\n begin\n response = notifications_api.post(encode_json(attributes))\n [parse_json(response), nil]\n rescue RestClient::UnprocessableEntity => e\n [parse_json(e.response), InvalidNotification]\n rescue RestClient::Unauthorized\n [{}, Unauthorized]\n ... | [
"0.7593524",
"0.73412955",
"0.7305329",
"0.6963764",
"0.6929839",
"0.6868717",
"0.6850269",
"0.6850269",
"0.6805122",
"0.6787712",
"0.6780248",
"0.67769974",
"0.6639654",
"0.6622584",
"0.65698683",
"0.65131927",
"0.65050566",
"0.64740777",
"0.64697534",
"0.6467012",
"0.645325... | 0.0 | -1 |
PATCH/PUT /notifications/1 PATCH/PUT /notifications/1.json | def update
respond_to do |format|
if @notification.update(notification_params)
format.html { redirect_to @notification, notice: 'Notification was successfully updated.' }
format.json { render :show, status: :ok, location: @notification }
else
format.html { render :edit }
format.json { render json: @notification.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def updateNotification\n read = convertToBoolean(read)\n delivered = convertToBoolean(delivered)\n\n parameters={id_user: params[:id_user].to_i, subject: params[:subject].to_s, content: params[:content].to_s, read: params[:read], delivered: params[:delivered] }\n options = {\n :body =>... | [
"0.70702535",
"0.70515186",
"0.6883182",
"0.6862723",
"0.6791934",
"0.6791934",
"0.67503804",
"0.67503804",
"0.67503804",
"0.6740188",
"0.6713271",
"0.6710817",
"0.6663978",
"0.65771335",
"0.65405804",
"0.6520096",
"0.6475701",
"0.6432363",
"0.6419112",
"0.63468456",
"0.63115... | 0.6625986 | 18 |
DELETE /notifications/1 DELETE /notifications/1.json | def destroy
@notification.destroy
respond_to do |format|
format.html { redirect_to notifications_url, notice: 'Notification was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def call(id)\n client.delete(\"/api/rest/v1/notifications/#{id}.json\")\n true\n end",
"def destroy\n @notification = Notification.find(params[:id])\n @notification.destroy\n\n respond_to do |format|\n format.html { redirect_to notifications_url }\n format.json { head :no_co... | [
"0.76316833",
"0.7612126",
"0.7582967",
"0.7582967",
"0.7582967",
"0.7582967",
"0.75271237",
"0.7509277",
"0.7415778",
"0.7409959",
"0.7405695",
"0.7383919",
"0.7381154",
"0.73799336",
"0.7351029",
"0.73404694",
"0.7332287",
"0.73111224",
"0.7302633",
"0.7300147",
"0.72997034... | 0.72660834 | 26 |
Use callbacks to share common setup or constraints between actions. | def set_notification
@notification = Notification.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576"... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def notification_params
params.require(:notification).permit(:title, :message, :from, :student_id, :notification_type, :type_data, :by_sms, :by_mail, :by_app)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.69811666",
"0.6782836",
"0.6747644",
"0.6742015",
"0.6735273",
"0.6593917",
"0.65037674",
"0.6498627",
"0.6482372",
"0.64795715",
"0.64566946",
"0.6439213",
"0.6380714",
"0.6378147",
"0.63657266",
"0.63206697",
"0.6300169",
"0.62992156",
"0.6295538",
"0.62943023",
"0.62915... | 0.0 | -1 |
character graphic index Start | def start
DataManager.create_game_objects
$game_party.setup_starting_members
$game_map.setup(Config::Starting_Map_ID)
$game_player.moveto(Config::X_Pos, Config::Y_Pos)
$game_player.followers.visible = false
$game_player.refresh
$game_player.make_encounter_count
@character_name = $game_player.character_name
@character_index = $game_player.character_index
$game_player.set_graphic('', 0)
$game_system.menu_disabled = true
Graphics.frame_count = 0
super
create_foreground
create_background
create_command_window
play_title_music
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def range_start\n @character_range[0]\n end",
"def zero_start\n @chr_start - 1\n end",
"def start_character\n attributes.fetch(:startCharacter)\n end",
"def class_character_index(d)\n cur_graph = class_graphics\n return nil if cur_graph.nil?\n index = cu... | [
"0.69694406",
"0.68426895",
"0.68343174",
"0.6538088",
"0.6373407",
"0.6368403",
"0.63429683",
"0.63263583",
"0.6319428",
"0.6306296",
"0.6260088",
"0.61901706",
"0.6186515",
"0.6176402",
"0.61725277",
"0.61725277",
"0.61725277",
"0.61725277",
"0.61654586",
"0.6128893",
"0.61... | 0.0 | -1 |
Determine if Debug Call by F9 key | def update_call_debug
# do nothing
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_call_debug\r\n # If debug mode is ON and F9 key was pressed\r\n if $DEBUG and Input.press?(Input::F9)\r\n # Set debug calling flag\r\n $game_temp.debug_calling = true\r\n end\r\n end",
"def key_pressed?\n @declared_fields['keyPressed'].value(java_self)\n end",
"def key_pr... | [
"0.715639",
"0.595154",
"0.55854803",
"0.5574925",
"0.5574216",
"0.5574095",
"0.55705386",
"0.5516987",
"0.5516987",
"0.5495007",
"0.547738",
"0.5474451",
"0.5454143",
"0.5453563",
"0.54231745",
"0.5416089",
"0.54038405",
"0.5390203",
"0.5356487",
"0.5340475",
"0.5337784",
... | 0.0 | -1 |
Move Sprite to Screen Center | def center_sprite(sprite)
sprite.ox = sprite.bitmap.width / 2
sprite.oy = sprite.bitmap.height / 2
sprite.x = Graphics.width / 2
sprite.y = Graphics.height / 2
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def center(sprite)\n sprite.ox = sprite.width / 2\n sprite.oy = sprite.height / 2\n end",
"def center_sprite(sprite)\r\n \tsprite.ox = sprite.bitmap.width / 2\r\n \tsprite.oy = sprite.bitmap.height / 2\r\n \tsprite.x = Graphics.width / 2\r\n \tsprite.y = Graphics.height / 2\r\n end",
"def center_sp... | [
"0.76465803",
"0.7566719",
"0.7472258",
"0.7459323",
"0.735465",
"0.7037949",
"0.68760663",
"0.68760663",
"0.68496203",
"0.68047416",
"0.663678",
"0.65815073",
"0.65475744",
"0.64811736",
"0.6470186",
"0.645956",
"0.63862336",
"0.631137",
"0.62863344",
"0.62577796",
"0.621596... | 0.7697529 | 1 |
Play Title Screen Music | def play_title_music
$data_system.title_bgm.play
RPG::BGS.stop
RPG::ME.stop
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def play\n\t\t\"playing #{title}\"\n\tend",
"def play_title_music\r\n\r\n$data_system.title_bgm.play\r\n\r\nRPG::BGS.stop\r\n\r\nRPG::ME.stop\r\n\r\nend",
"def our_songs\r\n\t@title = \"Our Songs\"\r\n end",
"def play_song(song_title)\n\t\tmsg = \"\"\n\t\t@songs.each do |song|\n\t\t\tif (song_title == song.... | [
"0.7865728",
"0.7579568",
"0.7333883",
"0.7111176",
"0.70193666",
"0.675885",
"0.6692385",
"0.6677047",
"0.66751117",
"0.6640734",
"0.6599654",
"0.6581105",
"0.65691805",
"0.6532044",
"0.6520902",
"0.64782697",
"0.64590585",
"0.64590585",
"0.64590585",
"0.64590585",
"0.645653... | 0.83133274 | 1 |
this method came with us from LockedLdpObject, and it'll keep this name until it gets refactored rubocop:disable Naming/AccessorMethodName | def set_thumbnail(attachment)
self.logo_id = attachment.id
save!
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def access_locked?; end",
"def private; end",
"def if_access_locked; end",
"def locked; end",
"def lock_expired?; end",
"def lock_timeout; end",
"def read_blocked\n end",
"def lock_timeout_retry_delay; end",
"def lock; end",
"def lock; end",
"def lock; end",
"def udp_timeout\n super\n ... | [
"0.5918262",
"0.56497496",
"0.5636865",
"0.5472901",
"0.5436317",
"0.52554923",
"0.5246845",
"0.51128983",
"0.50601196",
"0.50601196",
"0.50601196",
"0.5056158",
"0.50503653",
"0.5046929",
"0.50455475",
"0.50179315",
"0.49837768",
"0.49739203",
"0.49383724",
"0.49364188",
"0.... | 0.0 | -1 |
utility methods for checking for certain visibility transitions | def transitioned_to_private?
return true if changes['visibility'].present? &&
(changes['visibility'][0] != JupiterCore::VISIBILITY_PRIVATE) &&
(changes['visibility'][1] == JupiterCore::VISIBILITY_PRIVATE)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_visible?\n visibility && ( visibility > 0 )\n end",
"def visibility_changed?\n !(@old_visible_value == visible)\n end",
"def visible?\n end",
"def visible?\n @style.display != 'none'\n end",
"def visible?\n el.displayed?\n end",
"def can_walk_to?(transition); end",
"def visi... | [
"0.70364994",
"0.65650594",
"0.6287702",
"0.6253134",
"0.6212421",
"0.61628485",
"0.6145518",
"0.6119876",
"0.610125",
"0.60669124",
"0.60590637",
"0.59794986",
"0.5853262",
"0.5853262",
"0.5853262",
"0.5853262",
"0.5853262",
"0.5831426",
"0.5831426",
"0.58149695",
"0.5812127... | 0.59373504 | 12 |
Create a function that takes an array as an argument and returns true or false depending on whether the average of all elements in the array is a whole number or not. | def is_avg_whole?(arr)
arr.reduce(&:+) % arr.length == 0
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_avg_whole?(arr)\n\tsum = arr.sum\n\tavg_i = sum / arr.count \n\tavg_f = sum / arr.count.to_f\n\tavg_i == avg_f\nend",
"def is_avg_whole?(arr)\n sum_of_arr = arr.inject(0) {|sum,x| sum + x }\n\treturn (sum_of_arr / arr.length.to_f)%1==0 ? true : false\nend",
"def average_array(array)\n array.each d... | [
"0.83071",
"0.82768464",
"0.7145569",
"0.6849234",
"0.67085767",
"0.6641965",
"0.65922004",
"0.65213394",
"0.6506971",
"0.64956963",
"0.64939934",
"0.64450246",
"0.63976735",
"0.6393489",
"0.63912326",
"0.6367124",
"0.6365417",
"0.6363632",
"0.63605213",
"0.63585126",
"0.6343... | 0.80225235 | 2 |
Create a function that searches for the index of a given item in an array. If the item is present, it should return the index, otherwise, it should return 1. | def search(arr, item)
arr.index(item) || -1
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def search_array (array, integer)\n array.each_with_index do |item, index|\n if item == integer\n return index\n end\n end\nend",
"def search(arr, x)\n (0..arr.count).each do |i|\n return i if arr[i] == x\n end\n -1\nend",
"def find(arr, item)\n i = 0\n item_index = nil\n while item_index... | [
"0.80245537",
"0.7731764",
"0.76851076",
"0.76829517",
"0.76363814",
"0.76272833",
"0.76201665",
"0.76108813",
"0.754299",
"0.75330526",
"0.75125885",
"0.74808735",
"0.74796146",
"0.7457277",
"0.7453161",
"0.73716724",
"0.735374",
"0.7337712",
"0.73192644",
"0.73133796",
"0.7... | 0.8381486 | 0 |
Create access token, it provides basic access authentication for HTTP protocol, returns token contain username and password, they are separated by a colon. | def create_access_token(id:, type: nil)
params = {
id: id,
type: type
}
client.make_request('/create-access-token', 'post', params: params)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_access_token\n token_string = \"#{@username}:#{@password}\"\n return Base64.strict_encode64(token_string)\n end",
"def get_access_token\n uri = URI.parse(@token_url)\n http = Net::HTTP.new(uri.host, uri.port)\n req = Net::HTTP::Post.new(uri.request_uri)\n auth = Base64.encod... | [
"0.75740784",
"0.74791986",
"0.7260952",
"0.7062508",
"0.70146096",
"0.70033944",
"0.69514394",
"0.69514394",
"0.69514394",
"0.69514394",
"0.69514394",
"0.69514394",
"0.69514394",
"0.69514394",
"0.69514394",
"0.69514394",
"0.69514394",
"0.69514394",
"0.69514394",
"0.69514394",
... | 0.0 | -1 |
Returns the list of all available access tokens. | def list_access_tokens
client.make_request('/list-access-tokens', 'post', params: {})
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @access_tokens = page(access_token_list)\n end",
"def valid_tokens\n clear_expired_tokens\n access_tokens.pluck(:token)\n end",
"def get_tokens\n\t\tresource = \"/oauth/access_token\"\n\t\t\n\t\tbegin\n\t\t\tresponse = @connection.post resource do |request|\n\t\t\t\trequest.params['clien... | [
"0.7392675",
"0.6893904",
"0.6773382",
"0.669384",
"0.6585153",
"0.65119535",
"0.6448822",
"0.6425449",
"0.63602126",
"0.6318597",
"0.6135279",
"0.6128645",
"0.6058802",
"0.60582036",
"0.6054884",
"0.60374075",
"0.60346556",
"0.5980881",
"0.5964618",
"0.5947014",
"0.59435785"... | 0.838271 | 0 |
Delete existed access token. | def delete_access_token(id:)
client.make_request('/delete-access-token', 'post', params: {id: id})
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy_current_access_token\n AccessToken.find(current_access_token_id).destroy\n end",
"def delete_access_token(access_token_id)\n @redis.del(auth_domain_key(access_token_id))\n end",
"def destroy\n @access_token = AccessToken.find(params[:id])\n @access_token.destroy\n\n respond... | [
"0.80021304",
"0.7944134",
"0.77474403",
"0.7735231",
"0.71775585",
"0.7082591",
"0.703241",
"0.7012576",
"0.6998853",
"0.69616264",
"0.6957224",
"0.6914664",
"0.6908975",
"0.68696594",
"0.6838973",
"0.68295693",
"0.68295693",
"0.680112",
"0.6782523",
"0.6763248",
"0.6686812"... | 0.7877221 | 2 |
Check access token is valid. | def check_access_token(id: , secret:)
params = {
id: id,
secret: secret
}
client.make_request('/check-access-token', 'post', params: params)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_access_token\r\n\t\t\t\ttoken = request.headers[\"X-Access-Token\"] || nil\r\n\t\t\t\t\r\n\t\t\t\tif token\r\n\t\t\t\t\tfind_token = ApiKey.find_by_access_token(token)\r\n\r\n\t\t\t\t\tif find_token.nil?\r\n\t\t\t\t\t\tinvalid_access_token\r\n\t\t\t\t\tend\r\n\t\t\t\telse\r\n\t\t\t\t\tinvalid_access_toke... | [
"0.8140243",
"0.81180745",
"0.8112279",
"0.806671",
"0.7994866",
"0.79767174",
"0.79271895",
"0.7919153",
"0.78944325",
"0.7700348",
"0.76701516",
"0.76685643",
"0.7586358",
"0.7541547",
"0.74958205",
"0.7488552",
"0.7412302",
"0.7315815",
"0.72392935",
"0.71928656",
"0.71889... | 0.64973617 | 85 |
list products in the store TODO: add constraints to the find based on category, etc. | def list
@products = Product.find(:all, :page => {:start => 1, :size => 15})
@product_cols = 3
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def products_list\n\t\t@view.products_list\n\t\tproducts = @store.products\n\t\tproducts.each do |product|\n\t\t\tputs \"Name: #{product.name} ---> Price: #{product.price}\"\n\t\tend\n\t\t@view.second_view(@current_user, @current_user.actions)\n\tend",
"def products\n products_list\n .where(@filterable.f... | [
"0.78513247",
"0.7784803",
"0.7737194",
"0.75699866",
"0.7493385",
"0.74132067",
"0.732146",
"0.7308817",
"0.7297656",
"0.72874194",
"0.72600836",
"0.72364306",
"0.72322136",
"0.7230215",
"0.7220764",
"0.7219494",
"0.7213784",
"0.71856505",
"0.71729434",
"0.7164039",
"0.71220... | 0.7102552 | 21 |
hack to handle bug in URI.parse, which doesn't allow subdomains to contain underscores | def parse_uri(url = nil)
URI.parse(url)
rescue URI::InvalidURIError
host = url.match(".+\:\/\/([^\/]+)")[1]
uri = URI.parse(url.sub(host, 'dummy-host'))
uri.instance_variable_set('@host', host)
uri
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_domain_part\n assert_kind_of(N::URI, N::URI.new(\"http://somethingelse.com/foobar/bla/\").domain_part)\n assert_equal(\"http://somethingelse.com/foobar/bla/\", N::URI.new(\"http://somethingelse.com/foobar/bla/\").domain_part.to_s)\n assert_equal(\"http://somethingelse.com/foobar/bla/\", N::URI.ne... | [
"0.677612",
"0.6630629",
"0.6630629",
"0.6560784",
"0.65142155",
"0.64491236",
"0.64110756",
"0.6400645",
"0.6400645",
"0.6395796",
"0.6384113",
"0.63685095",
"0.63620925",
"0.6345576",
"0.62430656",
"0.62284994",
"0.6194634",
"0.61811304",
"0.61771625",
"0.61540616",
"0.6107... | 0.6045141 | 29 |
GET /contests/1 GET /contests/1.json | def show
@contest = Contest.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render :json => @contest }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @contest = Contest.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @contest }\n end\n end",
"def show\n @contest = Contest.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format... | [
"0.8039824",
"0.80027866",
"0.7894636",
"0.78603256",
"0.74444187",
"0.73176265",
"0.73176265",
"0.73176265",
"0.73176265",
"0.7205758",
"0.7156151",
"0.7156151",
"0.71495616",
"0.7118187",
"0.7028238",
"0.6884724",
"0.6837134",
"0.6814197",
"0.6814197",
"0.6757925",
"0.67245... | 0.79434526 | 3 |
GET /contests/new GET /contests/new.json | def new
@contest = Contest.new
respond_to do |format|
format.html {
if current_user.instance_of? Contractor
render
elsif current_user.instance_of? Designer
self.unauthorized
end
}
format.json { render :json => @contest }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @contest = Contest.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @contest }\n end\n end",
"def new\n @contest = Contest.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @contest }\n ... | [
"0.84161323",
"0.84161323",
"0.8337011",
"0.8180796",
"0.81516045",
"0.7913461",
"0.7685467",
"0.7532079",
"0.7532079",
"0.7532079",
"0.75287265",
"0.75068116",
"0.75068116",
"0.73809254",
"0.73809254",
"0.73809254",
"0.7335651",
"0.7218757",
"0.7218757",
"0.7218757",
"0.7210... | 0.0 | -1 |
POST /contests POST /contests.json | def create
@contest = Contest.new(params[:contest])
@contest.contractor_id = current_user.id
respond_to do |format|
if @contest.save
format.html { redirect_to @contest, :notice => 'Contest was successfully created.' }
format.json { render :json => @contest, :status => :created, :location => @contest }
else
format.html { render :action => "new" }
format.json { render :json => @contest.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @contest = Contest.new(params[:contest])\n\n respond_to do |format|\n if @contest.save\n format.html { redirect_to @contest, notice: 'Contest was successfully created.' }\n format.json { render json: @contest, status: :created, location: @contest }\n else\n format.... | [
"0.74872786",
"0.74872786",
"0.74872786",
"0.7152174",
"0.7103855",
"0.70241404",
"0.70208913",
"0.69897294",
"0.695391",
"0.68805426",
"0.68404317",
"0.68307537",
"0.68174773",
"0.6759615",
"0.6731611",
"0.67187345",
"0.6692199",
"0.6692199",
"0.66318876",
"0.66176033",
"0.6... | 0.67118084 | 16 |
PUT /contests/1 PUT /contests/1.json | def update
@contest = Contest.find(params[:id])
respond_to do |format|
if @contest.update_attributes(params[:contest])
format.html { redirect_to @contest, :notice => 'Contest was successfully updated.' }
format.json { head :no_content }
else
format.html { render :action => "edit" }
format.json { render :json => @contest.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @contest = Contest.find_by(path: params[:id])\n\n respond_to do |format|\n if @contest.update_attributes(params[:contest])\n format.html { redirect_to contest_path(@contest.path)+'/upload' }\n #format.json { head :no_content }\n else\n format.html { render action: ... | [
"0.7452851",
"0.7452833",
"0.74279934",
"0.74279934",
"0.7191935",
"0.71750563",
"0.7164745",
"0.7117877",
"0.705355",
"0.70395637",
"0.7026145",
"0.69851846",
"0.6976812",
"0.69482785",
"0.6924179",
"0.69112897",
"0.67661893",
"0.67661893",
"0.6714746",
"0.6714746",
"0.67147... | 0.7441542 | 2 |
DELETE /contests/1 DELETE /contests/1.json | def destroy
@contest = Contest.find(params[:id])
@contest.destroy
respond_to do |format|
format.html { redirect_to contests_url, :notice => 'Contest was successfully deleted.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @contest = Contest.find(params[:id])\n @contest.destroy\n\n respond_to do |format|\n format.html { redirect_to contests_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @contest.destroy\n respond_to do |format|\n format.html { redirect_to contests_url ... | [
"0.80987906",
"0.80896854",
"0.8085642",
"0.8085642",
"0.8085642",
"0.8085642",
"0.7983932",
"0.7868613",
"0.7868047",
"0.78431594",
"0.7790738",
"0.77683955",
"0.77683955",
"0.77683955",
"0.77602553",
"0.76734424",
"0.76611394",
"0.75796723",
"0.7568219",
"0.74781656",
"0.74... | 0.79219407 | 7 |
Starts the benchmark. Returns an Array of request times in seconds. | def run
done = false
times = []
threads = ThreadGroup.new
count_m = Mutex.new
@threads.times do
Thread.start do
threads.add Thread.current
until @num_requests <= 0 do
count_m.synchronize do
if @num_requests % @tenths == 0 then
print @num_requests
elsif @num_requests % @hundredths == 0 then
print '.'
end
@num_requests -= 1
end
$stdout.flush
times << time_request
end
end
Thread.pass
end
threads.enclose
threads.list.each { |t| t.join }
puts
return times
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def response_times\n times = []\n start_time = Time.now\n final_time = Time.now + @max_time\n counter = 1\n while Time.now < final_time do\n times << @request_builder.call(@url, counter)\n sleep(@sleep_time)\n counter += 1\n end\n times\n end",
"def time_request\n\t\tstarttim... | [
"0.6848309",
"0.66205114",
"0.6387109",
"0.6387109",
"0.63492465",
"0.6341557",
"0.6176479",
"0.61509836",
"0.60824037",
"0.59680545",
"0.591732",
"0.5859425",
"0.5840765",
"0.58400464",
"0.5839045",
"0.5831944",
"0.5804365",
"0.58034307",
"0.577173",
"0.5766091",
"0.5757748"... | 0.60694987 | 9 |
Returns the amount of time taken to execute the given block. | def time
start_time = Time.now.to_f
yield
end_time = Time.now.to_f
return end_time - start_time
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def profile (block_description, &block)\n start_time = Time.new\n block.call\n duration = Time.new - start_time\n puts \"#{block_description}: #{duration} seconds\"\nend",
"def profile block_description, &block\n start_time = Time.new\n block.call\n duration = Time.new - start_time\n puts \"#{block_descr... | [
"0.7433315",
"0.7376588",
"0.73042643",
"0.7244509",
"0.71874106",
"0.718099",
"0.7154886",
"0.6948005",
"0.6876386",
"0.67497885",
"0.6725823",
"0.6526324",
"0.65033",
"0.6447613",
"0.64385056",
"0.64196855",
"0.62957144",
"0.6288237",
"0.6252005",
"0.6245605",
"0.6185272",
... | 0.6375307 | 16 |
Returns the time taken to perform a request. | def time_request
time do
do_request
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def runtime_latency\n (finished_at || Time.current) - performed_at if performed_at\n end",
"def requests_per_second\n requests / horizon_time\n end",
"def get_response_time(uri)\n t0 = Time.now\n res = Net::HTTP.get_response(uri)\n\n Time.now - t0\nend",
"def time_request\n\t\tstar... | [
"0.7391947",
"0.72868717",
"0.7237059",
"0.7222084",
"0.71357614",
"0.704371",
"0.6997002",
"0.6966069",
"0.6847586",
"0.6841729",
"0.6826769",
"0.6766358",
"0.67625606",
"0.6728186",
"0.6728186",
"0.6728186",
"0.6716749",
"0.66869056",
"0.66575545",
"0.66535807",
"0.6603224"... | 0.7660052 | 0 |
def select_category_from_projects "SELECT category FROM projects;" end Make sure each ruby method returns a string containing a valid SQL statement. | def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_name
"SELECT projects.title,(SELECT SUM(pledges.amount))
FROM projects
INNER JOIN pledges ON projects.id = pledges.project_id
GROUP BY projects.title;"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def select_category_from_projects\n\"SELECT category FROM projects;\"\nend",
"def selects_the_category_names_and_pledge_amounts_of_all_pledges_in_the_music_category\n\"SELECT projects.category, pledges.amount\nFROM pledges\nINNER JOIN projects\nON projects.id = pledges.project_id\nWHERE projects.category = 'musi... | [
"0.91981363",
"0.70684034",
"0.69916224",
"0.6651801",
"0.66231173",
"0.6513625",
"0.64876",
"0.6324443",
"0.6061143",
"0.59409004",
"0.5938305",
"0.5936245",
"0.5900887",
"0.5882952",
"0.5870606",
"0.58542585",
"0.5853712",
"0.5840277",
"0.5819194",
"0.5785329",
"0.57822204"... | 0.54076433 | 60 |
Turn off stdout for all specs | def quiet_stdout
around(:example) do |example|
capture_stdout true
example.run
capture_stdout false
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def disable_stdout\n @old_stdout = STDOUT.dup\n # via Tomas Matousek, http://www.ruby-forum.com/topic/205887\n STDOUT.reopen(::RUBY_PLATFORM =~ /djgpp|(cyg|ms|bcc)win|mingw/ ? 'NUL' : '/dev/null')\n end",
"def disable_stdout\n @old_stdout = STDOUT.dup\n STDOUT.reopen(PLATFORM =~ /mswin/ ... | [
"0.7479832",
"0.7455504",
"0.73046803",
"0.7264223",
"0.7196278",
"0.71467674",
"0.7102035",
"0.7097419",
"0.70925206",
"0.7090385",
"0.7014187",
"0.7011816",
"0.6969808",
"0.6958182",
"0.6949559",
"0.69119877",
"0.6897611",
"0.68912137",
"0.6880098",
"0.6784229",
"0.6730688"... | 0.67396927 | 20 |
Clear the catalogue (= make it empty). | def zap_catalogue!()
catalogue.clear
save_catalogue
zap_rentals!
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clear() end",
"def clear() end",
"def clear; end",
"def clear; end",
"def clear; end",
"def clear; end",
"def clear; end",
"def clear; end",
"def clear; end",
"def clear\n end",
"def clear\n end",
"def clear\n end",
"def clear\n\t\tend",
"def clear\n end",
"def clear\n ... | [
"0.7291971",
"0.7291971",
"0.7102319",
"0.7102319",
"0.7102319",
"0.7102319",
"0.7102319",
"0.7102319",
"0.7102319",
"0.70909053",
"0.70909053",
"0.707453",
"0.69890213",
"0.695495",
"0.695495",
"0.695495",
"0.69023705",
"0.68929696",
"0.68929696",
"0.68929696",
"0.68755454",... | 0.6632013 | 32 |
Search a Video object having the given title | def search_video(aTitle)
result = catalogue.find { |video| video.title.strip == aTitle.strip }
if result.nil?
msg = "Video with title '#{aTitle}' isn't in the catalogue."
$stderr.puts msg
end
return result
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def search\n\n title = params[:title]\n\n @videos = Video.where('title ILIKE ?', \"%#{title}%\")\n # sql query where string of title is found in the vid title\n \n if @videos.nil?\n render json: \"No results found\"\n else\n render \"api/videos/search... | [
"0.8041182",
"0.6938407",
"0.688318",
"0.68469834",
"0.67216545",
"0.66604215",
"0.6647731",
"0.6602205",
"0.65458626",
"0.6432728",
"0.63991",
"0.63984686",
"0.63691866",
"0.6345562",
"0.6301288",
"0.62897646",
"0.6278824",
"0.62653005",
"0.62631667",
"0.6205694",
"0.6204542... | 0.7790585 | 1 |
Add a new video to the catalogue | def add_video(aTitle)
# Simplification: no check for title collision
catalogue << Video.new(aTitle, :available)
save_catalogue
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_video(video)\n @videos << video\n return true\n end",
"def add_video(tag)\n\n @driver.find_element(:link, 'Add Video').click\n\n wait = Selenium::WebDriver::Wait.new(:timeout => 30) # seconds\n wait.until { @driver.find_element(:link_text, \"Save Video\") }\n\n # Type in ... | [
"0.72062457",
"0.700506",
"0.6960435",
"0.692486",
"0.6888988",
"0.6880837",
"0.6855038",
"0.6742286",
"0.672718",
"0.6692539",
"0.6686246",
"0.66738904",
"0.66335833",
"0.662919",
"0.6610617",
"0.6593061",
"0.656236",
"0.65562165",
"0.65392566",
"0.65276724",
"0.652362",
"... | 0.81517845 | 0 |
nuevo archivo agregamos decimales, para leer y hacer espacio | def proyections(ventas_base, augment, start_array, end_array)
a = ventas_base.map.with_index do |sales, index|
if index >= start_array && index <= end_array
(sales*augment)
else
sales
end
end
return a
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fichier_de_donnees_pour(nb_items)\n \"../testdata/stock_options_#{nb_items/1024}K.txt\"\nend",
"def trailer_arquivo_posicao_394_a_400(sequencial)\n\t\t\t\t\t\t\"#{sequencial}\".adjust_size_to(6, '0', :right)\n\t\t\t\t\tend",
"def monta_header_arquivo\n header_arquivo = '' ... | [
"0.58282757",
"0.5818248",
"0.5766256",
"0.5655342",
"0.5636226",
"0.56290364",
"0.56137425",
"0.5577193",
"0.5572983",
"0.5538802",
"0.5532013",
"0.55307984",
"0.55025285",
"0.5459186",
"0.5455853",
"0.54396135",
"0.5432284",
"0.54289836",
"0.5415739",
"0.5407692",
"0.538827... | 0.0 | -1 |
Make an alg name simple enough so we can use it as a file name without problems. | def new_image_filename(alg_name, variation_index = '')
name = alg_name.to_s.dup
LETTER_REPLACEMENTS.each { |k, v| name.gsub!(k, v) }
name = "alg_#{name}#{variation_index}.#{FORMAT}"
unless name.ascii_only?
raise ArgumentError, "Even with some replacements, we couldn't transform #{alg_name} " \
'to an ASCII-only string.'
end
if name_to_alg[name]
raise ArgumentError,
"Two algs map to file name #{name}: #{alg_name} and #{name_to_alg[name]}"
end
name_to_alg[name] = alg_name
name
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_file_name(name)\r\n if name.match(/(.*)\\.([^\\.]*)/)\r\n fname, fext = $1, $2\r\n else\r\n fname, fext = name, \"dat\"\r\n end\r\n fname = fname.slugerize\r\n fext = fext.slugerize\r\n hash = Time.now.usec % 814949\r\n return \"#{hash.to_s(16)}_#{fname}.... | [
"0.64403033",
"0.6133815",
"0.6062381",
"0.60166794",
"0.6015186",
"0.5975764",
"0.59757346",
"0.5946585",
"0.59103715",
"0.5874238",
"0.5863449",
"0.58564645",
"0.58420175",
"0.5806091",
"0.5801089",
"0.577255",
"0.57408434",
"0.57219",
"0.57114017",
"0.57091564",
"0.5704789... | 0.7438881 | 0 |
Note that this will be called in parallel, so it needs to be threadsafe. | def process_note_input(note_input)
state = @options.color_scheme.solved_cube_state(@options.cube_size)
@solved_mask&.apply_to(state)
note_input.modified_alg.inverse.apply_to(state)
@visualizer.fetch_and_store(state, absolute_output_path(note_input.image_filename))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def lock; end",
"def lock; end",
"def lock; end",
"def thread()\n #This is a stub, used for indexing\n end",
"def private; end",
"def executor; end",
"def executor; end",
"def executor; end",
"def run() end",
"def run; end",
"def run; end",
"def run; end",
"def run; end",
... | [
"0.66191655",
"0.66191655",
"0.66191655",
"0.6590784",
"0.6361765",
"0.63361984",
"0.63361984",
"0.63361984",
"0.6144356",
"0.6138351",
"0.6138351",
"0.6138351",
"0.6138351",
"0.6138351",
"0.6138351",
"0.6138351",
"0.6138351",
"0.6138351",
"0.6134933",
"0.6134933",
"0.6134933... | 0.0 | -1 |
Use callbacks to share common setup or constraints between actions. | def set_status
@status = Status.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576"... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def status_params
params.require(:status).permit(:title, :status_group_id, :sorter)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.69811666",
"0.6782836",
"0.6747644",
"0.6742015",
"0.6735273",
"0.6593917",
"0.65037674",
"0.6498627",
"0.6482372",
"0.64795715",
"0.64566946",
"0.6439213",
"0.6380714",
"0.6378147",
"0.63657266",
"0.63206697",
"0.6300169",
"0.62992156",
"0.6295538",
"0.62943023",
"0.62915... | 0.0 | -1 |
Return an image tag for the club avatar thumbnail. | def clubthumbnail_tag(club)
image_tag(club.clubavatar.thumbnail_url, :border => 0)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def profile_image_thumbnail\n image_path = profile_user_image.present? ? profile_user_image.image.url(:thumbnail) :\n DEFAULT_USER_PROFILE_IMAGE_NAME\n\n h.image_tag image_path, class: 'img-thumbnail', alt: full_name\n end",
"def profile_image_miniature\n ... | [
"0.7750083",
"0.72984594",
"0.72029465",
"0.71783537",
"0.7132888",
"0.7103467",
"0.7012389",
"0.70120025",
"0.6947808",
"0.6881491",
"0.68230605",
"0.6801746",
"0.67763066",
"0.67535955",
"0.67494065",
"0.6738214",
"0.67337334",
"0.67268974",
"0.67265147",
"0.6723629",
"0.67... | 0.8426535 | 0 |
return [string output, string error_message, integer exitcode, boolean exception ] | def execute(cmd)
error_message=""
exception = false
# execute
begin
#output = ` #{cmd} `
output = %x( #{cmd})
#output = system(call "#{cmd}")
retcode = $?.exitstatus
rescue Exception => e
error_message= e.message.red
exception = true
end
#retcode = $?.exitstatus
return { "output" => output, "error" => error_message,
"retcode" => retcode, "exception" => exception }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def error(rc)\n return rc[0].strip if rc[2].success?\n\n puts \"ERROR: #{rc[1]}\"\n\n exit(-1)\nend",
"def error(msg, code)\n STDERR.puts msg\n exit code\nend",
"def error(msg, code)\n STDERR.puts msg\n exit code\nend",
"def exitstatus; end",
"def error(msg)\n puts \"#{msg}\\n\\n\"\n exit -1... | [
"0.6937589",
"0.6878476",
"0.6878476",
"0.6824858",
"0.6706357",
"0.664009",
"0.66048604",
"0.6603489",
"0.65850323",
"0.6454553",
"0.63912106",
"0.63901067",
"0.6378749",
"0.6345811",
"0.6320164",
"0.6320164",
"0.6320164",
"0.6320164",
"0.6320164",
"0.6311839",
"0.6311628",
... | 0.60361856 | 33 |
include ::Forms::DateOfBirthField include Validations::USDate.on(:date_of_birth) | def initialize(*attributes)
@addresses = [Address.new(kind: 'home'), Address.new(kind: 'mailing')]
@same_with_primary = "true"
super
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate_birthdate\n errors.add(:birthdate, \"Birthdate can't be in the future\") if birthdate && birthdate > Date.today\n end",
"def birth_date_and_date_of_joining\n if !user.user_information.birth_date.blank? && !date_of_joining.blank?\n valid = user.user_information.birth_date && date_of_... | [
"0.69490683",
"0.6717087",
"0.6696131",
"0.6577748",
"0.6492285",
"0.64385664",
"0.6424931",
"0.63769794",
"0.6319543",
"0.6271041",
"0.62241215",
"0.6149071",
"0.6148309",
"0.60825634",
"0.6075924",
"0.6045734",
"0.60068053",
"0.5987927",
"0.59471613",
"0.5940142",
"0.593314... | 0.0 | -1 |
The +Bot+ initially keeps no promises | def initialize(id)
super
@promises = {}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def waiting; end",
"def waiting; end",
"def run()\r\n @bot.run :async\r\n @bot.online\r\n wake_up(@bot)\r\n\r\n @bot.bucket :helpBucket, limit: 1, time_span: 30, delay: 1\r\n @bot.bucket :hamBucket, limit: 5, time_span: 1, delay: 1\r\n\r\n # Create all markov commands, invoked by dictionary n... | [
"0.6199822",
"0.6199822",
"0.61876655",
"0.5983125",
"0.5983125",
"0.5983125",
"0.5959639",
"0.59473974",
"0.59110236",
"0.58900875",
"0.5882327",
"0.58805674",
"0.5850394",
"0.5850394",
"0.5850394",
"0.58356315",
"0.5743751",
"0.5743751",
"0.5743751",
"0.5721636",
"0.5721636... | 0.0 | -1 |
Has this +Bot+ promised to give a +kind+ of +microchip+? | def promised_to?(kind)
@promises.key? kind
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_softwire?(); @type == GRT_SOFTWIRE; end",
"def physical_device?\n arches.any? do |arch|\n arch[/arm/, 0]\n end\n end",
"def is_hardwire?(); @type == GRT_HARDWIRE; end",
"def device?\n type == :device\n end",
"def card_detection\n end",
"def one_bit?\n identify.include... | [
"0.6721788",
"0.639083",
"0.63561624",
"0.6243865",
"0.6088038",
"0.6053154",
"0.6010889",
"0.5944566",
"0.5944557",
"0.59338075",
"0.5797902",
"0.57492965",
"0.57349926",
"0.57042587",
"0.5686725",
"0.5686725",
"0.568638",
"0.5672969",
"0.56384075",
"0.56308585",
"0.56295323... | 0.0 | -1 |
Get the +id+ of the +Entity+ that was promised a +kind+ of +microchip+ +kind+ can either be +:low+ or +:high+ | def givee(kind)
@promises[kind]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def kind_identifier\n kind ? kind.identifier : nil\n end",
"def kind\n data['kind']\n end",
"def kind\n attributes.fetch(:kind)\n end",
"def kind\n attributes.fetch(:kind)\n end",
"def kind\n attributes.fetch(:kind)\n end",
"def kind\n ... | [
"0.68468493",
"0.5960586",
"0.5879935",
"0.5879935",
"0.5879935",
"0.5879935",
"0.5879935",
"0.5879935",
"0.5843972",
"0.5843972",
"0.58017254",
"0.5797987",
"0.5797987",
"0.57493675",
"0.5694975",
"0.5694857",
"0.56832236",
"0.55979294",
"0.55979294",
"0.55979294",
"0.559792... | 0.0 | -1 |
"Hello, " + name + ". How are you doing?" end puts greeting("Bob") | def multiply(number1, number2)
number1 * number2
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def greeter(name)\n puts \"Hello #{name}! How are you today?\"\nend",
"def greet\n puts \"Hello! My name is #{name}!\"\n end",
"def greet(name)\n print \"Hello, #{name} how are you doing today?\"\nend",
"def greeting\n puts \"Hi, my name is #{@name}.\"\n end",
"def greeting(name)\n print \"h... | [
"0.8643108",
"0.8629694",
"0.85908693",
"0.8585934",
"0.85859305",
"0.8548421",
"0.85146636",
"0.8502299",
"0.8491893",
"0.84510684",
"0.841168",
"0.8410347",
"0.8402453",
"0.8391969",
"0.83801395",
"0.83801395",
"0.8360681",
"0.83586866",
"0.8356783",
"0.8335855",
"0.8332421... | 0.0 | -1 |
Check for valid request token and return user | def authorize_request
@current_user = AuthorizeApiRequest.new(request.headers).call[:user]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate_authentication_token\n \n @user = User.find_by_services_authentification_token(params[:auth_token])\n bad_request if @user.nil?\n end",
"def authenticate_user_from_token!\n user_token = params[:auth_token].presence\n user = user_token && User.find_by_authentication_token(user_t... | [
"0.77663815",
"0.7615777",
"0.74398065",
"0.7404742",
"0.7396012",
"0.73896915",
"0.73461586",
"0.73138165",
"0.7312087",
"0.72945833",
"0.7259202",
"0.7254861",
"0.7249174",
"0.7248579",
"0.7245904",
"0.71891725",
"0.7188027",
"0.71810305",
"0.7180644",
"0.7159302",
"0.71593... | 0.0 | -1 |
Usage verdiff [file_path_1,file_path_2,...] [template_directory] | def resolve_path(path)
unless Pathname.new(path).absolute?
File.join(Dir.pwd, path)
else
path
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def diff_cmd(file, version)\n fail \"The #{self.class} driver does not support the diff_cmd method!\"\n end",
"def diff___( from_file, to_file )\r\n raise StandardError, \"Under investigation\" \r\n got = @ndev.rpc.file_compare( :from_file => from_file, :to_file => to_file )\r\n end",
"... | [
"0.6310686",
"0.6279778",
"0.6132113",
"0.5863539",
"0.58592904",
"0.5843786",
"0.58210397",
"0.5820684",
"0.5801605",
"0.57951117",
"0.57951117",
"0.57612795",
"0.5740408",
"0.57354623",
"0.5695076",
"0.56876934",
"0.56864756",
"0.5640578",
"0.5587838",
"0.55745655",
"0.5570... | 0.0 | -1 |
This method generates an array of all moves that can be made after the current move. | def children
node_arr = []
(0..2).each do |row|
(0..2).each do |col|
if @board.empty?([row, col])
updated_board = @board.dup
updated_board[[row, col]] = @next_mover_mark
updated_positions = @prev_move_pos.dup
updated_positions += [row, col]
node_arr << TicTacToeNode.new(updated_board, @next_mover_mark == :o && :x || :o, updated_positions)
end
end
end
node_arr
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def next_possible_moves\n positions_array = []\n x = @position[0]\n y = @position[1]\n next_position = [x+1,y+2]\n positions_array << next_position if position_check(next_position)\n next_position = [x+1,y-2]\n positions_array << next_position if position_check(next_position)\n next_positio... | [
"0.74542904",
"0.7448149",
"0.74069035",
"0.7375318",
"0.72373027",
"0.7234965",
"0.7215259",
"0.72118765",
"0.72038615",
"0.71801317",
"0.71401936",
"0.71162206",
"0.70881444",
"0.7080469",
"0.70726323",
"0.70608085",
"0.7033311",
"0.70258737",
"0.6983692",
"0.69750845",
"0.... | 0.0 | -1 |
storage :fog Override the directory where uploaded files will be stored. This is a sensible default for uploaders that are meant to be mounted: | def store_dir
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def store_dir\n 'file_uploads'\n end",
"def store_dir\n \"uploads\"\n end",
"def store_dir\n 'uploads'\n end",
"def store_dir\n # \"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}\"\n # This works for the file storage as well as Amazon S3 and Rackspace Cloud Files.\n # D... | [
"0.7506943",
"0.7366758",
"0.7333099",
"0.733298",
"0.73037624",
"0.7299172",
"0.7278739",
"0.7278739",
"0.7278739",
"0.72693604",
"0.724532",
"0.72300035",
"0.7225865",
"0.7202066",
"0.71868175",
"0.71794933",
"0.71650726",
"0.7150311",
"0.7150311",
"0.7150311",
"0.7150311",... | 0.0 | -1 |
Add a white list of extensions which are allowed to be uploaded. For images you might use something like this: | def extension_whitelist
%w(jpg jpeg gif png)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def extension_whitelist\n %w(jpg jpeg gif png)\n end",
"def extension_whitelist\n %w[jpg jpeg gif png]\n end",
"def extension_whitelist\n %w[jpg jpeg gif png]\n end",
"def extension_whitelist\n %w[jpg jpeg gif png]\n end",
"def extension_whitelist\n %w[jpg jpeg png]\n end",
"def... | [
"0.81572783",
"0.8148596",
"0.8148596",
"0.8148596",
"0.81230783",
"0.8091924",
"0.8091924",
"0.8091924",
"0.8089499",
"0.79969525",
"0.79353714",
"0.79353714",
"0.7915584",
"0.78393465",
"0.7814662",
"0.7742898",
"0.7719162",
"0.76941663",
"0.7684599",
"0.7684599",
"0.768152... | 0.81239665 | 15 |
TODO: move from this | def as_json(attributes = {})
attrs = super(attributes)['attributes']
attrs.slice('id', 'body').merge(
username: user.full_name,
user_avatar_url: user.avatar_url,
created_at: I18n.l(created_at.in_time_zone, format: :answer)
)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def private; end",
"def probers; end",
"def schubert; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def refutal()\n end",
"def custom; end",
"def custom; end",
"def suivre; end",
"def formation; end",
"def implementation; end",
"def implementation; ... | [
"0.7651791",
"0.6560004",
"0.64762014",
"0.645525",
"0.645525",
"0.645525",
"0.645525",
"0.61956817",
"0.61529076",
"0.61529076",
"0.60593945",
"0.6052822",
"0.6033603",
"0.6033603",
"0.60198",
"0.60198",
"0.5924076",
"0.5831859",
"0.5831859",
"0.5816814",
"0.5810565",
"0.5... | 0.0 | -1 |
=begin def kesha_maker(array) kesha_array = [] array.each do |character| character[2] = "$" kesha_array.push(character) end kesha_array end =end | def kesha_maker(array)
array.collect do |character|
character[2] = "$"
character
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def kesha_maker(array)\n kesha = []\n array.each do |i|\n i[2] = \"$\"\n kesha << i\n end\n kesha\nend",
"def kesha_maker(array)\n kesha_array = []\n array.each do |name|\n name[2] = \"$\"\n kesha_array << name\n end\n kesha_array\nend",
"def kesha_maker(array)\n array.each do |string|\n... | [
"0.8856897",
"0.8813024",
"0.8774708",
"0.8711452",
"0.8630604",
"0.8622542",
"0.86042774",
"0.86004066",
"0.85989594",
"0.85986775",
"0.8469509",
"0.84468347",
"0.84031886",
"0.8386328",
"0.8373424",
"0.837338",
"0.8342644",
"0.8339378",
"0.8339378",
"0.8288024",
"0.82761735... | 0.8825824 | 1 |
check understanding of create method | def create
@story = Story.new(story_params)
if @story.save
flash[:success] = "Thanks for sharing"
redirect_to story_path(@story)
else
flash[:error] = "Oops, sorry, something went wrong"
render :new
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n \n end",
"def create; end",
"def create; end",
"def create; end",
"def create; end",
"def create\n \t\n end",
"def create\r\n end",
"def create\n end",
"def create\n \n end",
"def create!\n end",
"def create\r\n\r\n\r\n end",
"def create\n end",
... | [
"0.8637082",
"0.8635565",
"0.8635565",
"0.8635565",
"0.8635565",
"0.84175116",
"0.83964473",
"0.83905",
"0.8365424",
"0.8310063",
"0.8290388",
"0.8290368",
"0.8263731",
"0.8263731",
"0.8263731",
"0.8179925",
"0.8179925",
"0.81189525",
"0.81189525",
"0.8107339",
"0.80370194",
... | 0.0 | -1 |
method is only applicable within this file, public is accessible outside of this file | def story_params
params.require(:story).permit(:title, :body, :url, :author)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def private; end",
"def public; end",
"def public; end",
"def private_method\n end",
"def public_method; end",
"def internal; end",
"def protected_method\n end",
"def methods; end",
"def methods; end",
"def methods; end",
"def methods; end",
"def implementation; end",
"def impleme... | [
"0.84349996",
"0.7961294",
"0.7961294",
"0.79070276",
"0.7380707",
"0.7325665",
"0.7105948",
"0.7092406",
"0.7092406",
"0.7092406",
"0.7092406",
"0.69915587",
"0.69915587",
"0.6879588",
"0.68456775",
"0.68456775",
"0.6805289",
"0.6789396",
"0.6708778",
"0.66673034",
"0.661695... | 0.0 | -1 |
Creates a Device Group based on parameters | def create
start = Time.now
debug "Creating device group: \"#{resource[:full_path]}\""
connection = self.class.get_connection(resource[:account])
recursive_group_create(connection,
resource[:full_path],
resource[:description],
resource[:properties],
resource[:disable_alerting])
debug "Finished in #{(Time.now-start)*1000.0} ms"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_group\n group new_resource.group do\n gid new_resource.gid\n system true\n end\n end",
"def createGroup\n call :createGroup\n end",
"def create_group(attributes)\n BrickFTP::API::Group.create(attributes)\n end",
"def create_group(attri... | [
"0.7312992",
"0.71745986",
"0.7171816",
"0.71717054",
"0.68589145",
"0.6715112",
"0.67105293",
"0.6695985",
"0.66653776",
"0.6654163",
"0.6646319",
"0.6634482",
"0.6634482",
"0.65802175",
"0.65463996",
"0.65081716",
"0.6499611",
"0.6476722",
"0.6431991",
"0.6427271",
"0.63996... | 0.7506082 | 0 |
Deletes a Device Group | def destroy
start = Time.now
debug("Deleting device group: \"#{resource[:full_path]}\"")
connection = self.class.get_connection(resource[:account])
device_group = get_device_group(connection, resource[:full_path], 'id')
if device_group
delete_device_group = rest(connection,
Puppet::Provider::Logicmonitor::DEVICE_GROUP_ENDPOINT % device_group['id'],
Puppet::Provider::Logicmonitor::HTTP_DELETE)
valid_api_response?(delete_device_group) ? nil : alert(delete_device_group)
end
debug "Finished in #{(Time.now-start)*1000.0} ms"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_group(group)\n\t\t\tend",
"def delete_group(group)\n\t\t\tend",
"def delete_group\r\n if request.post?\r\n @group=Group.find_by_id(params[:id], :conditions=>['account_id = ?',session[:account_id]])\r\n if @group.nil?\r\n flash[:error] = \"Invalid action.\"\r\n else\r\n ... | [
"0.7975324",
"0.7975324",
"0.7948557",
"0.7874789",
"0.7735191",
"0.7672911",
"0.76039845",
"0.75678635",
"0.74709594",
"0.7425904",
"0.74128747",
"0.7407958",
"0.7405626",
"0.73350495",
"0.7309228",
"0.72707385",
"0.7232702",
"0.72187245",
"0.7177549",
"0.7137803",
"0.713192... | 0.81273687 | 0 |
Verifies the existence of a device group | def exists?
start = Time.now
debug "Checking if device group \"#{resource[:full_path]}\" exists"
connection = self.class.get_connection(resource[:account])
if resource[:full_path].eql?('/')
true
else
device_group = get_device_group(connection, resource[:full_path])
debug device_group unless nil_or_empty?(device_group)
debug "Finished in #{(Time.now-start)*1000.0} ms"
nil_or_empty?(device_group) ? false : true
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def group_exists?(group)\n Sys::Admin.get_group(group)\n true\n rescue\n false\n end",
"def has_group?(name)\n run(\"id -g #{name}\").success?\n end",
"def group_present(name)\n group_exists = false\n execute(\"dscacheutil -q group -a name #{name}\") do |result|\n gr... | [
"0.7134076",
"0.696905",
"0.6896247",
"0.681749",
"0.681749",
"0.6798795",
"0.67918974",
"0.67907494",
"0.6728133",
"0.67066514",
"0.663603",
"0.6600482",
"0.6590846",
"0.65790695",
"0.6486889",
"0.647442",
"0.6392958",
"0.6383161",
"0.63727427",
"0.63209254",
"0.6314875",
... | 0.70602906 | 1 |
Retrieve Device Group Description | def description
start = Time.now
debug "Checking description for device group: \"#{resource[:full_path]}\""
connection = self.class.get_connection(resource[:account])
device_group = get_device_group(connection, resource[:full_path],'description')
debug "Finished in #{(Time.now-start)*1000.0} ms"
device_group['description']
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def description\n [@group.description,@description].join(' ')\n end",
"def option_group_description\n data[:option_group_description]\n end",
"def get_device_group_list\n query_api('device-groups')\n end",
"def full_description(example_group)\n example_group.metadata.fetc... | [
"0.69122857",
"0.6838297",
"0.67690456",
"0.66809475",
"0.66659886",
"0.6632578",
"0.6622104",
"0.6527918",
"0.650246",
"0.64859444",
"0.62351847",
"0.62066865",
"0.61031884",
"0.608062",
"0.6066598",
"0.60373074",
"0.6005407",
"0.599934",
"0.5982732",
"0.5982492",
"0.5970798... | 0.8422715 | 0 |
Update Device Group Description | def description=(value)
start = Time.now
debug "Updating description on device group: \"#{resource[:full_path]}\""
connection = self.class.get_connection(resource[:account])
update_device_group(connection,
resource[:full_path],
value,
resource[:properties],
resource[:disable_alerting])
debug "Finished in #{(Time.now-start)*1000.0} ms"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_device_group(connection, fullpath, description, properties, disable_alerting)\n device_group = get_device_group(connection, fullpath, 'id,parentId')\n device_group_hash = build_group_json(fullpath,\n description,\n pro... | [
"0.6973977",
"0.68643016",
"0.6430639",
"0.63025874",
"0.61800104",
"0.61226726",
"0.6101705",
"0.60991216",
"0.6080032",
"0.60615283",
"0.60192186",
"0.5890359",
"0.5890106",
"0.5878162",
"0.58680093",
"0.58624405",
"0.5862161",
"0.58130544",
"0.5806277",
"0.57867354",
"0.57... | 0.79215366 | 0 |
Get disable_alerting status of Device Group | def disable_alerting
start = Time.now
debug "Checking disable_alerting setting for device group: \"#{resource[:full_path]}\""
connection = self.class.get_connection(resource[:account])
device_group = get_device_group(connection, resource[:full_path],'disableAlerting')
debug "Finished in #{(Time.now-start)*1000.0} ms"
device_group['disableAlerting'].to_s
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def disable_alerting=(value)\n start = Time.now\n debug \"Updating disable_alerting setting for device group: \\\"#{resource[:full_path]}\\\"\"\n connection = self.class.get_connection(resource[:account])\n update_device_group(connection,\n resource[:full_path],\n ... | [
"0.7371675",
"0.6242139",
"0.6040878",
"0.5979644",
"0.59092927",
"0.5820182",
"0.57699585",
"0.567009",
"0.5554105",
"0.5519001",
"0.5463659",
"0.54286194",
"0.53949326",
"0.53891623",
"0.53680676",
"0.53614587",
"0.5360941",
"0.53425825",
"0.52844673",
"0.52688235",
"0.5263... | 0.8547635 | 0 |
Update disable_alerting status of Device Group | def disable_alerting=(value)
start = Time.now
debug "Updating disable_alerting setting for device group: \"#{resource[:full_path]}\""
connection = self.class.get_connection(resource[:account])
update_device_group(connection,
resource[:full_path],
resource[:description],
resource[:properties],
value)
debug "Finished in #{(Time.now-start)*1000.0} ms"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def disable_alerting\n start = Time.now\n debug \"Checking disable_alerting setting for device group: \\\"#{resource[:full_path]}\\\"\"\n connection = self.class.get_connection(resource[:account])\n device_group = get_device_group(connection, resource[:full_path],'disableAlerting')\n debug \"Finishe... | [
"0.80387694",
"0.6416387",
"0.6183336",
"0.61413246",
"0.58565116",
"0.57329226",
"0.57147056",
"0.56291914",
"0.55382824",
"0.5524323",
"0.5500079",
"0.5492993",
"0.54369867",
"0.5432056",
"0.5413198",
"0.5348121",
"0.5259602",
"0.52381265",
"0.5232796",
"0.52298886",
"0.520... | 0.83525395 | 0 |
Retrieve Properties for device group (including password properties) | def properties
start = Time.now
debug "Checking properties for device group: \"#{resource[:full_path]}\""
connection = self.class.get_connection(resource[:account])
properties = Hash.new
device_group = get_device_group(connection, resource[:full_path], 'id')
if device_group
device_group_properties = rest(connection,
Puppet::Provider::Logicmonitor::DEVICE_GROUP_PROPERTIES_ENDPOINT % device_group['id'],
Puppet::Provider::Logicmonitor::HTTP_GET,
build_query_params('type:custom,name!:system.categories,name!:puppet.update.on',
'name,value'))
if valid_api_response?(device_group_properties, true)
device_group_properties['data']['items'].each do |property|
name = property['name']
value = property['value']
if value.include?('********') && resource[:properties].has_key?(name)
debug 'Found password property. Verifying'
verify_device_group_property = rest(connection,
Puppet::Provider::Logicmonitor::DEVICE_GROUP_PROPERTIES_ENDPOINT % device_group['id'],
Puppet::Provider::Logicmonitor::HTTP_GET,
build_query_params("type:custom,name:#{name},value:#{value}", nil, 1))
if valid_api_response?(verify_device_group_property)
debug 'Property unchanged'
value = resource[:properties][name]
else
debug 'Property changed'
end
end
properties[name] = value
end
else
alert device_group_properties
end
else
alert device_group
end
debug "Finished in #{(Time.now-start)*1000.0} ms"
properties
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_properties()\n resp = conn.get('/users/'+name+'/props/')\n \n case resp.code.to_i\n when 200\n return JSON.parse(resp.body)\n when 404\n raise RestAuthUserNotFound.new( resp )\n else\n raise RestAuthUnknownStatus.new( rest )\n end\n end",
"def properties=(value)\n ... | [
"0.60712594",
"0.5910523",
"0.5889344",
"0.5867824",
"0.5826572",
"0.58261967",
"0.5758224",
"0.568512",
"0.55921817",
"0.55417323",
"0.55283237",
"0.5505112",
"0.5427554",
"0.5423174",
"0.54067004",
"0.5398085",
"0.5368259",
"0.5366639",
"0.53529936",
"0.53297323",
"0.527509... | 0.79790485 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.