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 |
|---|---|---|---|---|---|---|
(boolean) scrap_user_logged_in? : Renders "tiddler status msg" or "tiddler msg" if not logged in | def scrap_user_logged_in?(error_in_empty_tiddler = false)
if !logged_in?
message = '<h3>'+'Please login first'[:error_login_first] + '</h3>'
respond_to do |format|
format.html { flash[:error] = message and render :action => 'create', :status => :unauthorized and return false }
format.js {
if error_in_empty_tiddler
render :partial => "layouts/message", :status => :unauthorized, :locals => {:message => message}, :layout => false
else
render :partial => "layouts/status_message", :status => :unauthorized, :locals => {:message => message}, :layout => false
end
return false
}
format.xml { return false }
end
else
return true
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_logged_in\n service_response = success\n render_api_response(service_response)\n end",
"def check_status\n if @current_user.blank?\n render :text => {\"continue\" => false}.to_json\n return\n end\n \n render :text => @current_user.real_time_notifications.to_json\n end",
... | [
"0.60554606",
"0.60521966",
"0.6011723",
"0.5927316",
"0.59044623",
"0.5818589",
"0.5803148",
"0.57557356",
"0.5747598",
"0.57026184",
"0.5696085",
"0.56866974",
"0.5606351",
"0.5597603",
"0.5585642",
"0.55816674",
"0.5581013",
"0.5577791",
"0.55694044",
"0.556765",
"0.555456... | 0.7296878 | 0 |
setter and getter methods meow method | def meow
puts "meow!"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getters; end",
"def name\n return @name\nend\ndef age\n return @age\nend\n#setters, allows you to change or set something\ndef name=(name)\n @name = name\nend",
"def method_missing(meth, *args, &blk)\n match = meth.to_s.match(/^([a-zA-Z\\_]+)(=|$)$/)\n if match\n attribute, setter... | [
"0.7285025",
"0.70624655",
"0.6889987",
"0.67542064",
"0.67542064",
"0.6577742",
"0.6561623",
"0.6499023",
"0.6475793",
"0.64498645",
"0.64399177",
"0.6423702",
"0.641594",
"0.641594",
"0.641594",
"0.641594",
"0.641594",
"0.641594",
"0.641594",
"0.63862824",
"0.63265926",
"... | 0.0 | -1 |
Returns true if user belongs to the specified role. | def role?(role)
if self.role == role.to_s
return true
else
return false
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has_role?(role)\n current_user && current_user.has_role?(role)\n end",
"def has_role?(role)\n current_user && current_user.has_role?(role)\n end",
"def has_role_for_user(name, role)\n roles = get_roles_for_user(name)\n roles.include?(role)\n end",
"def has_role? user_role\n role... | [
"0.82410175",
"0.82410175",
"0.8199655",
"0.81890464",
"0.81474125",
"0.80992967",
"0.80757785",
"0.806661",
"0.8058675",
"0.8016378",
"0.7938648",
"0.791125",
"0.7890983",
"0.78774905",
"0.78774905",
"0.78774905",
"0.78774905",
"0.78743523",
"0.7873208",
"0.7857661",
"0.7856... | 0.80308217 | 9 |
Run a command using 'artisan' ==== Parameters +command+ :: command to run | def artisan(command, options = {})
raise LaravelNotFoundError unless laravel_exists_in_directory?(@path)
php = `which php`.strip
raise RequiredLibraryMissingError, "php" unless php
command = "#{php} #{@path}/artisan #{command}"
output = `#{command}`
puts output unless options[:quiet]
($?.exitstatus == 0)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run_command(command)\n `#{command}`\nend",
"def execute(command)\n system(command)\n end",
"def execute_command(command)\n system(command)\n end",
"def run(command)\n @commands_to_run << command\n end",
"def rake(command, options = {})\n execute_command :rake, comman... | [
"0.70448864",
"0.69320637",
"0.68787193",
"0.67727023",
"0.67011297",
"0.6612411",
"0.65893614",
"0.6586468",
"0.6586468",
"0.6576517",
"0.65408194",
"0.6538971",
"0.6479874",
"0.64602405",
"0.645924",
"0.64582384",
"0.64582384",
"0.64547336",
"0.64460385",
"0.64445966",
"0.6... | 0.76547575 | 0 |
Return the path to the local cache directory for a given Source ==== Return +string+ :: Filepath to the local cache directory | def cache_directory
File.join(CacheFolder, make_md5(@source))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def local_path\n src = if %i(direct repo).include?(new_resource.source)\n package_metadata[:url]\n else\n new_resource.source.to_s\n end\n ::File.join(Chef::Config[:file_cache_path], ::File.basename(src))\n end",
"def cache_... | [
"0.7425864",
"0.6830605",
"0.6805839",
"0.6785696",
"0.6771832",
"0.67435277",
"0.6725107",
"0.6725107",
"0.67212343",
"0.67212343",
"0.67077017",
"0.6700639",
"0.6649551",
"0.6648104",
"0.66367656",
"0.6622296",
"0.6547174",
"0.6541506",
"0.6541182",
"0.65391",
"0.6508492",
... | 0.7448737 | 0 |
Check whether the app directory is the current directory. This is useful to know if we are creating the new application in the current directory. ==== Return +boolean+ :: True, if the app directory is the current directory. | def create_in_current_directory?
is_current_directory?(@path)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def current_directory?\n File.exist? current_directory\n end",
"def is_current_directory?(dir = nil)\n dir ||= Dir.pwd\n dir = File.expand_path(dir)\n File.directory?(dir) and (dir == File.expand_path(Dir.pwd))\n end",
"def is_working_dir path\n File.exist? File.expand_path \".gi... | [
"0.8176597",
"0.78471494",
"0.6993995",
"0.66793257",
"0.6520829",
"0.6401081",
"0.63960457",
"0.63663304",
"0.6353409",
"0.6351403",
"0.6331093",
"0.63238937",
"0.6310894",
"0.62939686",
"0.6282812",
"0.62558603",
"0.62252194",
"0.61945635",
"0.61775666",
"0.61280817",
"0.61... | 0.7521997 | 2 |
Check whether the app directory is empty? This is useful to know if we are trying to create the new application in an empty directory or not, so that we may know if we need to create this application forcefully? ==== Return +boolean+ :: True, if the app directory is an empty one. | def create_in_empty_directory?
is_empty_directory?(@path)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def empty?\n Dir.empty?(path)\n end",
"def empty_directory?\n directory? && Dir.entries(to_s).reject { |entry| entry == '.' || entry == '..' }.empty?\n end",
"def empty?( dir_path )\n connection.nlst( dir_path ).empty?\n end",
"def is_empty_directory?(dir = nil)\n dir ||= Dir.pwd... | [
"0.7720633",
"0.73840463",
"0.7190939",
"0.7189074",
"0.71495414",
"0.6966294",
"0.67965746",
"0.67876965",
"0.6669369",
"0.6601089",
"0.65078175",
"0.64743793",
"0.64563066",
"0.6444204",
"0.6403268",
"0.6388249",
"0.63646597",
"0.6342541",
"0.63320583",
"0.63096166",
"0.629... | 0.7992309 | 0 |
Check whether the specified source is a local directory or a URL? ==== Return +boolean+ :: True, if the source is a local directory. | def source_is_local?
File.directory?(@source)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_file_source_a_remote_url?\n !self.remote_url.blank?\n end",
"def local_valid_repo?\n @local_dir_path.directory?\n end",
"def local_dir_exists?(full_path)\n File.directory?(full_path)\nend",
"def local?\n @uri.scheme == 'file'\n end",
"def is_local_path(path)\n (path =~ /^.:(\\/|\\\... | [
"0.71893734",
"0.70237935",
"0.6998091",
"0.697964",
"0.6873225",
"0.68724835",
"0.6759035",
"0.6664996",
"0.6627768",
"0.6596963",
"0.653044",
"0.6491668",
"0.64716196",
"0.63899654",
"0.6377403",
"0.6345643",
"0.63219124",
"0.6296141",
"0.6288866",
"0.62444174",
"0.62131816... | 0.8530504 | 0 |
Return the path to the configuration file for the current application ==== Return +string+ :: path to the configuration file | def config_file
File.join(@path, %w[ application config application.php ])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def app_config_path\n Pathname.new('.').join('config')\n end",
"def config_file\n File.join AppRoot, ConfigFile\n end",
"def configuration_file_path; end",
"def config_path\n @config_path ||= local_config_path\n end",
"def config_file\n CONFIG_FILE\n end",
"def con... | [
"0.8710351",
"0.85291845",
"0.8201271",
"0.811794",
"0.80136657",
"0.7929726",
"0.7921384",
"0.7830639",
"0.7786527",
"0.7777559",
"0.77421814",
"0.77030224",
"0.7688194",
"0.76841587",
"0.76562816",
"0.765533",
"0.75824237",
"0.75769",
"0.7561342",
"0.7485603",
"0.7481143",
... | 0.82415223 | 2 |
Return the path to a tasks file by its name ==== Parameters +name+ :: string name of the tasks file ==== Return +string+ :: path to the tasks file | def tasks_file(name)
File.expand_path(File.join(@path, %w[ application tasks ], name))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def file_name\n \"#{task_name}.rake\"\n end",
"def path_with_task_name(task_name)\n \"#{path}:#{task_name}\"\n end",
"def file_path\n File.join 'lib', 'woro_tasks', file_name\n end",
"def find_task(name)\n name = name.to_sym unless name.nil?\n @tasks[name]\n end",
"def ... | [
"0.7656034",
"0.7329245",
"0.71107155",
"0.6982276",
"0.6861047",
"0.6798232",
"0.65880334",
"0.64466214",
"0.64102185",
"0.63920736",
"0.6363892",
"0.628988",
"0.62888545",
"0.6229122",
"0.6141346",
"0.6029299",
"0.5956704",
"0.59522754",
"0.5868086",
"0.5866187",
"0.5860112... | 0.8417948 | 0 |
check if laravel framework exists in the current application's directory currently, this is performed by looking for the presence of 'artisan' file and the 'laravel' subdirectory. ==== Return +boolean+ :: true, if laravel framework exists | def has_laravel?
laravel_exists_in_directory?(@path)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def laravel_exists_in_directory?(directory = nil, relative_to = nil)\n return false unless directory\n directory = File.expand_path(directory, relative_to)\n return false unless File.exists? File.join(directory, \"artisan\")\n return false unless File.directory? File.join(directory, \"laravel\"... | [
"0.7489911",
"0.6882119",
"0.66582793",
"0.6546062",
"0.6417397",
"0.6417397",
"0.6262782",
"0.6239475",
"0.6209952",
"0.61106825",
"0.61106825",
"0.60987264",
"0.6097039",
"0.60789406",
"0.60486525",
"0.6011561",
"0.60081226",
"0.59987277",
"0.59533024",
"0.5925606",
"0.5905... | 0.81347567 | 0 |
check if the cache exists for the source specified by the current application's directory this further makes sure that the cache really has laravel framework as we would expect it to ==== Return +boolean+ :: true, if the cache exists | def has_cache?
laravel_exists_in_directory?(@cache)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cache_exist?\n File.exist?(@cache_file)\n end",
"def cache_exists?\n File.exist?(cached_file)\n end",
"def cached?\n cache_path.exist?\n end",
"def exists?(path)\n return unless @cache_base\n\n File.exists?(@cache_base + path)\n end",
"def cached?\n cache_path.exis... | [
"0.8005785",
"0.7997671",
"0.76418144",
"0.76353294",
"0.7589856",
"0.74197555",
"0.7374245",
"0.71036744",
"0.70137954",
"0.6914038",
"0.6910787",
"0.6860674",
"0.68509674",
"0.6792968",
"0.67497194",
"0.66971934",
"0.6676467",
"0.6583283",
"0.65780044",
"0.6535317",
"0.6515... | 0.8678215 | 0 |
Depending on whether the 'force' parameter is provided, this method removes all the files in the directory specified by the application path, if the directory exists. Further, if the directory doesn't exist, it tries to create the directory specified by the application path. | def apply_force
show_info "Creating application forcefully!" if @options[:force]
FileUtils.rm_rf("#{@path}/.", :secure => true) if File.exists?(@path) and @options[:force]
FileUtils.mkdir_p @path
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clean_app()\n wd = FileUtils.pwd()\n FileUtils.rm_f( [\n '/app/assets/*',\n '/app/components/*',\n '/app/controllers/*',\n '/app/helpers/*',\n '/app/models/*',\n '/app/views/*'\n ].collect!{|e| Dir.glob(wd + e)}.flatten.compact )\n end",
"def destroy\n delete_fi... | [
"0.66909933",
"0.648186",
"0.64702094",
"0.6443755",
"0.6360182",
"0.6353173",
"0.6324998",
"0.625953",
"0.6253838",
"0.6253676",
"0.62265384",
"0.6222619",
"0.6222619",
"0.62038606",
"0.6202752",
"0.61912227",
"0.61766917",
"0.6137194",
"0.6097808",
"0.6086241",
"0.60836846"... | 0.70723313 | 0 |
This method downloads or updates the local cache for the current source. If the source is a directory on this machine, it will simply not do anything since that can interfere with an offline installation, and the user must update the source manually in this case. Otherwise, it uses git to update or download the source as required and caches it locally. | def download_or_update_local_cache
# we have nothing to download if the source is a local directory
return if source_is_local?
# we need git for this purpose
raise RequiredLibraryMissingError, "git" if `which git`.empty?
# create the cache, and download or update as required
FileUtils.mkdir_p @cache
Dir.chdir(@cache) do
if has_cache?
show_info "Repository exists in local cache.."
show_info "Updating local cache.."
`git pull -q`
else
show_info "Downloading repository to local cache.."
`git clone -q #{@source} .`
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fetch_local(new_dest, fetch_if_missing = true)\n if !File.exists? @repo.cache_path\n if fetch_if_missing\n fetch\n else\n raise \"Source cache #{@repo.cache_path} not readable.\"\n end\n end\n FileUtils.cp_r @repo.cache_path, new_dest\n end",
"def after_source_download\... | [
"0.74836445",
"0.689803",
"0.6890024",
"0.6844942",
"0.67704976",
"0.6727353",
"0.66981936",
"0.66831",
"0.6519328",
"0.64912283",
"0.64382005",
"0.6381833",
"0.6327686",
"0.6295119",
"0.62374246",
"0.617224",
"0.61714286",
"0.61714286",
"0.6169956",
"0.61563486",
"0.6114985"... | 0.8832719 | 0 |
This method copies the files from the local cache to the directory of the application. | def copy_over_cache_files
FileUtils.cp_r "#{@cache}/.", @path
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def copy_cache\n @copy_cache ||= configuration[:copy_cache] == true ?\n File.join(Dir.tmpdir, configuration[:application]) :\n configuration[:copy_cache]\n end",
"def copy_cache\n @copy_cache ||= configuration[:copy_cache] == true ?\n File.join(Dir.tmpdir... | [
"0.7012994",
"0.7012419",
"0.64852726",
"0.6473215",
"0.6467962",
"0.6375926",
"0.63359153",
"0.6267059",
"0.62501717",
"0.62361443",
"0.6204939",
"0.6188377",
"0.6160009",
"0.61597955",
"0.613772",
"0.613772",
"0.61052877",
"0.60990757",
"0.60870713",
"0.60385495",
"0.600242... | 0.7810412 | 0 |
This method updates the permissions on the storage/ directory inside the newly created application. This method does not have a separate exposed call from the CLI. This can be skipped by passing 'noperms' flag for the 'new' command. | def update_permissions_on_storage
if @options[:perms]
response = system("chmod -R o+w #{File.join(@path, 'storage')}")
if response
say_success "Updated permissions on storage/ directory."
else
say_failed "Could not update permissions on storage/ directory."
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_new_permissions\n @permissions.each do |key|\n next if Lockdown::System.permission_assigned_automatically?(key)\n str = Lockdown.get_string(key)\n p = ::Permission.find(:first, :conditions => [\"name = ?\", str])\n unless p\n Lockdown.logger.info \">... | [
"0.5805985",
"0.5756673",
"0.57172704",
"0.5640863",
"0.54232675",
"0.53868926",
"0.53581667",
"0.5310384",
"0.52916706",
"0.52620053",
"0.52620053",
"0.52620053",
"0.52620053",
"0.52620053",
"0.52620053",
"0.52620053",
"0.52620053",
"0.52620053",
"0.52620053",
"0.52620053",
... | 0.7075284 | 0 |
Once, we are done with the intallation, and an error occurs, this method handles the clean_up routine by removing the application directory we created, as well as the local cache for the source, that may exist. Keeping the local cache does not make sense, since we anyways can not create applications based on these 'corrupt' repositories. | def clean_up
FileUtils.rm_rf "#{@path}" unless create_in_current_directory?
FileUtils.rm_rf "#{@cache}"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cleanup\n tmpdir = File.join(OBS_BUILD_DIR,OBS_LOCAL_TMP)\n if File.exists?(tmpdir)\n FileUtils.rm_rf(tmpdir)\n end\n end",
"def cleanup\n FileUtils.rm(@out_filename)\n\n # XXX: could be rm-rf, but be safe for now. Might hav... | [
"0.6883739",
"0.6783197",
"0.6661202",
"0.6596878",
"0.6569509",
"0.6569509",
"0.65541524",
"0.6499908",
"0.6496716",
"0.64849186",
"0.6408572",
"0.6372577",
"0.6368637",
"0.63353187",
"0.63040847",
"0.62705773",
"0.62540424",
"0.6242853",
"0.62291646",
"0.62134784",
"0.61960... | 0.7219504 | 0 |
s(:class, NAME, PARENT, BODY) | def process_class exp
name = class_name(exp.class_name)
parent = class_name(exp.parent_name)
# If inside an inner class we treat it as a library.
if @current_class
Railroader.debug "[Notice] Treating inner class as library: #{name}"
Railroader::LibraryProcessor.new(@tracker).process_library exp, @file_name
return exp
end
handle_class exp, @tracker.models, Railroader::Model
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def s(type, *children); end",
"def new_anon_class(parent, name=\"\", &proc)\n klass = Class.new(parent) \n mc = klass.instance_eval{ class << self ; self ; end }\n mc.send(:define_method, :to_s) {name}\n klass.class_eval(&proc) if proc\n klass\nend",
"def call\n klass = Class.new(parent)\n\n kl... | [
"0.66017395",
"0.6006788",
"0.59766257",
"0.58545053",
"0.5828077",
"0.5729366",
"0.5705696",
"0.5705696",
"0.5650151",
"0.56176203",
"0.5603581",
"0.5603581",
"0.55614185",
"0.55614185",
"0.55614185",
"0.55614185",
"0.55614185",
"0.55614185",
"0.55614185",
"0.55614185",
"0.5... | 0.0 | -1 |
Handle calls outside of methods, such as include, attr_accessible, private, etc. | def process_call exp
return exp unless @current_class
return exp if process_call_defn? exp
target = exp.target
if sexp? target
target = process target
end
method = exp.method
first_arg = exp.first_arg
# Methods called inside class definition
# like attr_* and other settings
if @current_method.nil? and target.nil?
if first_arg.nil?
case method
when :private, :protected, :public
@visibility = method
when :attr_accessible
@current_class.set_attr_accessible
else
# ??
end
else
case method
when :include
@current_class.add_include class_name(first_arg) if @current_class
when :attr_accessible
@current_class.set_attr_accessible exp
when :attr_protected
@current_class.set_attr_protected exp
else
if @current_class
@current_class.add_option method, exp
end
end
end
exp
else
call = make_call target, method, process_all!(exp.args)
call.line(exp.line)
call
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def method_missing(wh,*therest)\n # xxx internal methods must be protected at some point\n end",
"def internal; end",
"def internal_methods; end",
"def private_method\n end",
"def included; end",
"def protected_method\n end",
"def accessibility; end",
"def ignore_method_conflicts; e... | [
"0.65077424",
"0.6240586",
"0.60360795",
"0.6001385",
"0.59529465",
"0.5931626",
"0.59065366",
"0.5864792",
"0.58286405",
"0.58241624",
"0.5811471",
"0.5811471",
"0.57930607",
"0.57841784",
"0.57530504",
"0.5734461",
"0.5715461",
"0.57126075",
"0.5692284",
"0.5667195",
"0.565... | 0.56006986 | 22 |
takes an array and splits it into left (less than) and right (greater than) by moving in from both sides, swapping values as positions move towards the midpoint | def partition_array(array, pivot)
left_i = 0
right_i = (last_i = array.length - 1)
# haven't crossed/met yet...
while left_i < right_i
while array[left_i] <= pivot && left_i < last_i
left_i += 1
end
while array[right_i] >= pivot && right_i > 0
right_i -= 1
end
# four possibilities (extract this part)
if left_i < right_i # stopped but not crossed
# swap left and right values
tmp = array[left_i]
array[left_i] = array[right_i]
array[right_i] = tmp
# repeat loop
else
if left_i > right_i # # crossed, midpoint found
midpoint = left_i #left_i is to right of midpoint after cross
left = array
right = left.slice!(midpoint..-1)
elsif right_i == 0 # right marker came all the way over: ALL GREATER THAN
left, right = [], array
else left_i == last_i # left marker came all the way right: ALL LESS THEN
left, right = array, []
end
break
end
end
return left, right
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def halve array\n middle = (array.size / 2.0).round - 1\n left = array[0..middle]\n right = array[(middle+1)..(array.last)]\n [left,right]\nend",
"def halve array\n middle = (array.length / 2.0).round\n left = [0..middle]\n right = [middle..(array.last)]\n [left,right]\nend",
"def partition_array(array... | [
"0.67236334",
"0.6612655",
"0.6607327",
"0.65570325",
"0.65525836",
"0.65409666",
"0.6538006",
"0.6522212",
"0.64546245",
"0.6434378",
"0.64074564",
"0.638098",
"0.6380611",
"0.6379941",
"0.63777274",
"0.6377023",
"0.63633555",
"0.6322366",
"0.6304697",
"0.6297341",
"0.628591... | 0.66755337 | 1 |
GET /messages GET /messages.json | def index
@messages = current_user.received_messages.paginate(:page => params[:page])
@title = "Входящие сообщения"
@path = "index"
respond_to do |format|
format.html # index.html.erb
format.json { render json: @messages }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def messages\n get_json('messages.json')\n end",
"def index\n messages = Message.all\n render json: messages\n end",
"def index\n @messages = Message.all\n render json: @messages\n end",
"def index\n @messages = Message.all\n render json: @messages\n end",
"def index\n @mess... | [
"0.8392115",
"0.755332",
"0.7461291",
"0.7461291",
"0.74388546",
"0.74314713",
"0.74295616",
"0.74287003",
"0.7412067",
"0.73680776",
"0.7355837",
"0.7349781",
"0.72963905",
"0.72897035",
"0.72890514",
"0.7267814",
"0.71833634",
"0.7156361",
"0.71530104",
"0.71393275",
"0.710... | 0.70300335 | 24 |
GET /messages/1 GET /messages/1.json | def show
@message = Message.read(params[:id], current_user)
@title = @message.subject
if current_user == @message.sender
@this_user = true
else
@this_user = false
end
# @this_user = current_user == @message.sender ? true : false
respond_to do |format|
format.html # show.html.erb
format.json { render json: @message }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @v1_message = V1::Message.find(params[:id])\n\n render json: @v1_message\n end",
"def messages\n get_json('messages.json')\n end",
"def show\n @message = Message.find(params[:id])\n render json: @message\n\n end",
"def show\n\t\t@messages = Message.where(recipient: params[:id... | [
"0.75848913",
"0.75048095",
"0.722935",
"0.7189061",
"0.71235263",
"0.7086403",
"0.7069309",
"0.70688313",
"0.70688313",
"0.70688313",
"0.70688313",
"0.70688313",
"0.70688313",
"0.70688313",
"0.70688313",
"0.70688313",
"0.70688313",
"0.70688313",
"0.70688313",
"0.70688313",
"... | 0.0 | -1 |
GET /messages/new GET /messages/new.json | def new
@message = Message.new
@title = "Новое сообщение"
if params[:reply_to]
@reply_to = current_user.received_messages.find(params[:reply_to])
unless @reply_to.nil?
@message.to = @reply_to.sender.username
@message.subject = "Re: #{@reply_to.subject}"
@message.body = "bq. #{@reply_to.body}\n\n"
end
end
if params[:to]
@message.to = params[:to]
end
respond_to do |format|
format.html # new.html.erb
format.json { render json: @message }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @message = Message.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @message }\n end\n end",
"def new\n @message = Message.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @message }\n end... | [
"0.81525946",
"0.81525946",
"0.8146461",
"0.8146461",
"0.8146461",
"0.8146461",
"0.8146461",
"0.8146461",
"0.8146461",
"0.8146461",
"0.8146461",
"0.8146461",
"0.8146461",
"0.8146461",
"0.8146461",
"0.8146461",
"0.8146461",
"0.8146461",
"0.8146461",
"0.81073797",
"0.8089234",
... | 0.7037203 | 70 |
POST /messages POST /messages.json | def create
@message = Message.new(params[:message])
@message.sender = current_user
@message.recipient = User.find_by_username(params[:message][:to])
respond_to do |format|
if @message.save
format.html { redirect_to @message, notice: 'Сообщение отправлено.' }
format.json { render json: @message, status: :created, location: @message }
else
format.html { render action: "new" }
format.json { render json: @message.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def post(content)\n post_to(\"/api/v1/messages/\", {:body => content})\n end",
"def create\n message = Message.new(message_params)\n message.message = params[:message_text]\n message.display_name = params[:display_name]\n message.save!\n render json: message\n end",
"def create\n @messag... | [
"0.7465386",
"0.71694404",
"0.7112854",
"0.7095524",
"0.70685273",
"0.70200527",
"0.69382447",
"0.6844289",
"0.683413",
"0.683015",
"0.68281627",
"0.68281627",
"0.6783851",
"0.6763146",
"0.67002374",
"0.6698929",
"0.66701055",
"0.66322166",
"0.66246116",
"0.6623654",
"0.66130... | 0.0 | -1 |
DELETE /messages/1 DELETE /messages/1.json | def destroy
@message = Message.find(params[:id])
@message.mark_deleted(current_user)
respond_to do |format|
format.html { redirect_to messages_url }
format.json { head :ok }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @v1_message = V1::Message.find(params[:id])\n @v1_message.destroy\n\n head :no_content\n end",
"def delete\n @client.post('/api/del_msg', id: get_attribute(:name))\n end",
"def destroy\n # delete a specific message\n end",
"def destroy\n @message.destroy\n \n ... | [
"0.79590774",
"0.7747881",
"0.771779",
"0.76623553",
"0.7639338",
"0.76313365",
"0.7628893",
"0.76116306",
"0.76056355",
"0.7605057",
"0.7605057",
"0.7592493",
"0.75893265",
"0.75893265",
"0.75893265",
"0.75893265",
"0.7552685",
"0.7550845",
"0.7550845",
"0.7550845",
"0.75508... | 0.7340958 | 59 |
TODO: change to guard clause | def check_valid_time(hours, minutes)
if hours > 24 || hours < 0
raise ArgumentError.new('ERROR: invalid hours')
elsif minutes > 59 || minutes < 0
raise ArgumentError.new('ERROR: invalid minutes')
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def guard; end",
"def conditionally(*) end",
"def conditionally(*) end",
"def condition; end",
"def cond; end",
"def cond; end",
"def cond; end",
"def check ; true ; end",
"def private; end",
"def missed?; end",
"def sharded?; false; end",
"def checks; end",
"def sharded?; true; end",
"de... | [
"0.7301945",
"0.63842285",
"0.63842285",
"0.63330686",
"0.6162099",
"0.6162099",
"0.6162099",
"0.61471164",
"0.61059016",
"0.60625136",
"0.598362",
"0.59765637",
"0.596979",
"0.59451175",
"0.59436965",
"0.59436965",
"0.58986694",
"0.57197785",
"0.5694375",
"0.5694375",
"0.569... | 0.0 | -1 |
/Domain/EmailForward/Remove The command is intended to remove an existing Email Forwarding rule. Returned data: STATUS=SUCCESS or FAILURE TRANSACTID=Transaction ID Example return data: transactid=5c6690939950db9fad0a667eef0ebd8e status=SUCCESS | def remove_email_forward(source)
validate_list([["Source", source, :email] ])
options = { "Source" => source }
connection = Connection.new
connection.post("Domain/EmailForward/Remove", options)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_rule!(objectID, forward_to_replicas = false, request_options = {})\n res = delete_rule(objectID, forward_to_replicas, request_options)\n wait_task(res['taskID'], WAIT_TASK_DEFAULT_TIME_BEFORE_RETRY, request_options)\n return res\n end",
"def delete_rcpt( email )\n RESPONSE[\... | [
"0.62917656",
"0.6098368",
"0.5955882",
"0.5932887",
"0.5835132",
"0.57444125",
"0.57317466",
"0.57110476",
"0.5705981",
"0.5676933",
"0.56649",
"0.5634626",
"0.5616452",
"0.56115717",
"0.56015515",
"0.5593104",
"0.55889994",
"0.5573354",
"0.5528151",
"0.5524846",
"0.5507042"... | 0.66377723 | 0 |
/Domain/EmailForward/Update The command is intended to add a new Email Forwarding rule. Returned data: STATUS=SUCCESS or FAILURE TRANSACTID=Transaction ID Example return data: transactid=5c6690939950db9fad0a667eef0ebd8e status=SUCCESS | def update_email_forward(source, destination)
validate_list([["Source", source, :email],
["Destination", destination, :email]
])
options = {
"Source" => source,
"Destination" => destination
}
connection = Connection.new
connection.post("Domain/EmailForward/Update", options)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def updateAnsweringRuleOnRoutingExt(client, accountId, extensionId, answeringRuleId, forwardingNumberId)\n body = {\n 'enabled' => true,\n 'forwarding' => {\n 'notifyMySoftPhones' => true,\n 'softPhonesRingCount' => 5,\n 'ringingMode' => 'Sequentially',\n 'rules': [{\n 'index': 1,... | [
"0.6653373",
"0.6351729",
"0.6191149",
"0.6186863",
"0.6149999",
"0.59082484",
"0.5866592",
"0.5849404",
"0.57930136",
"0.57204133",
"0.5687966",
"0.56239426",
"0.5602864",
"0.5567944",
"0.5561976",
"0.5529223",
"0.54956514",
"0.5493252",
"0.5486213",
"0.54797596",
"0.5466662... | 0.71392584 | 0 |
/Domain/EmailForward/List The command is intended to retrieve the list of email forwarding rules for a domain. Returned data: STATUS=SUCCESS or FAILURE RULE_[x]_SOURCE = the source for the rule [x] where [x] is a number starting with 1 and incrementing for each rule RULE_[x]_DESTINATION = the destination for rule [x] Example return data: transactid=b88831878b31225bd9c743b28ac52bf7 total_rules=3 | def list_email_forwards(domain, range_from_optional, range_to_optional)
validate_list([ ["Domain", domain, :domain_format] ])
options = { "Domain" => domain }
optional_fields = [ ["rangeFrom", range_from_optional], ["rangeTo", range_to_optional] ]
options = set_optional_fields(optional_fields, options)
connection = Connection.new
connection.post("Domain/EmailForward/List", options)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list_forwarding_rules(opts = {})\n data, _status_code, _headers = list_forwarding_rules_with_http_info(opts)\n return data\n end",
"def list_forwarding_rules_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: ForwardingRuleApi... | [
"0.6648423",
"0.59676236",
"0.56102943",
"0.5593586",
"0.54867613",
"0.5458402",
"0.52998596",
"0.5162054",
"0.5085621",
"0.5046843",
"0.49879074",
"0.4986631",
"0.49463314",
"0.49278456",
"0.49263114",
"0.48895684",
"0.48881832",
"0.487571",
"0.48212102",
"0.4819853",
"0.481... | 0.7180608 | 0 |
Returns a collection of usersowners of apps for selection on challenge create or edit each User should be valid, i.e. to have an Org, otherwise skipped | def app_owners_for_select
User.real.map { |u| [u.select_text, u.id] if u.org }.compact
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def approvable_users\n @approvable_users ||= (controllable_users + editable_request_applicants + controllable_users.map{|uu|uu.editable_request_applicants}).flatten.uniq\n end",
"def unassigned_approvers_for_contract(contract)\n\n # todo: shouldnt have to use select here... theres a better way\n user_i... | [
"0.68761355",
"0.6455158",
"0.6327592",
"0.6300272",
"0.6257901",
"0.60782826",
"0.6037363",
"0.6017995",
"0.5982276",
"0.59057945",
"0.5870208",
"0.5833938",
"0.58004457",
"0.57840556",
"0.5711231",
"0.57083935",
"0.570725",
"0.57026416",
"0.5691462",
"0.56893307",
"0.567089... | 0.7603173 | 0 |
Returns a collection of Site admins and challenge admins | def host_lead_dxusers
User.site_admins.or(User.challenge_admins).order(:dxuser).distinct.pluck(:dxuser)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @site_admins = SiteAdmin.all\n end",
"def admins\n app_users.select(&:admin?)\n end",
"def get_admins\n\t\t@sm = Member.where(society_id: self.id)\n\t\t@admins = []\n\t\t@sm.each do |m|\n\t\t #if is an admin, add to array\n\t\t if m.admin then @admins << User.find_by_id(m.user_id) end... | [
"0.7457911",
"0.7408283",
"0.7276864",
"0.71543795",
"0.71151084",
"0.70422775",
"0.6932943",
"0.68824244",
"0.6839848",
"0.6750798",
"0.67470515",
"0.6744809",
"0.6727442",
"0.67062026",
"0.661232",
"0.6602632",
"0.6580056",
"0.6561919",
"0.6561919",
"0.6561919",
"0.6528465"... | 0.6544892 | 20 |
Returns a collection of Site admins, challenge evaluators and challenge admins | def guest_lead_dxusers
User.site_admins.
or(User.challenge_admins).
or(User.challenge_evaluators).
order(:dxuser).distinct.pluck(:dxuser)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @site_admins = SiteAdmin.all\n end",
"def admins\n app_users.select(&:admin?)\n end",
"def get_admins\n\t\t@sm = Member.where(society_id: self.id)\n\t\t@admins = []\n\t\t@sm.each do |m|\n\t\t #if is an admin, add to array\n\t\t if m.admin then @admins << User.find_by_id(m.user_id) end... | [
"0.71780044",
"0.7064868",
"0.7014453",
"0.6884545",
"0.6868511",
"0.6767423",
"0.66854346",
"0.6657168",
"0.66530436",
"0.6567124",
"0.65520495",
"0.65520495",
"0.65520495",
"0.6521446",
"0.6419314",
"0.63916934",
"0.63889843",
"0.6383546",
"0.63315034",
"0.63212305",
"0.630... | 0.59945494 | 56 |
Returns a collection of challenges for selection on challenge edit page | def challenge_order_for_select
Challenge.not_status(Challenge::STATUS_ARCHIVED).all.map { |ch| [ch.name, ch.id] }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def team_challenge_list\n @team_challenges = TeamChallenge.find_by_user(current_user.id)\n end",
"def index\n @user_challenges = UserChallenge.all\n end",
"def index\n @challenges = Challenge.all\n end",
"def index\n @challenges = Challenge.all\n end",
"def index\n @challenges = Challeng... | [
"0.7152797",
"0.66272515",
"0.6515581",
"0.6515581",
"0.6515581",
"0.6515581",
"0.6369654",
"0.633059",
"0.62554073",
"0.607645",
"0.607645",
"0.6020836",
"0.5980763",
"0.59603393",
"0.5954202",
"0.5949412",
"0.59379953",
"0.592673",
"0.58657146",
"0.5747622",
"0.5714936",
... | 0.55902135 | 30 |
GET /suggestions GET /suggestions.json | def index
@suggestions = Suggestion.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @suggestions }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def suggestions\n response.try(:[], \"suggest\").try(:[], @suggest_key).try(:[], request_params[:q]).try(:[], \"suggestions\") || []\n end",
"def suggestions\n with_monitoring do\n Faraday.get(suggestions_url, query_params)\n end\n rescue => e\n e\n end",
"def suggest\n ... | [
"0.7921654",
"0.76962346",
"0.7659703",
"0.7499706",
"0.7480025",
"0.7480025",
"0.7419286",
"0.72764426",
"0.7064508",
"0.70626795",
"0.7046857",
"0.7025311",
"0.69745696",
"0.6971177",
"0.6860192",
"0.6709187",
"0.67090434",
"0.66637874",
"0.6660277",
"0.6649667",
"0.6641161... | 0.76882756 | 2 |
GET /suggestions/1 GET /suggestions/1.json | def show
@suggestion = Suggestion.new
@suggestion.game = Game.find_by_slug(params[:id])
@suggestion.user = current_user
respond_to do |format|
format.html # show.html.erb
format.json { render json: @suggestion }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def suggestions\n response.try(:[], \"suggest\").try(:[], @suggest_key).try(:[], request_params[:q]).try(:[], \"suggestions\") || []\n end",
"def index\n @suggestions = Suggestion.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @suggestions }... | [
"0.75693065",
"0.75616205",
"0.744794",
"0.744794",
"0.7447549",
"0.7300006",
"0.7091594",
"0.70371497",
"0.7029383",
"0.6920914",
"0.6914963",
"0.6909951",
"0.6850886",
"0.680707",
"0.67673445",
"0.67305946",
"0.6652034",
"0.65906036",
"0.6565364",
"0.6549162",
"0.6527178",
... | 0.60488445 | 58 |
POST /suggestions POST /suggestions.json | def create
@suggestion = Suggestion.new(params[:suggestion])
@suggestion.user = current_user
respond_to do |format|
if @suggestion.save
format.html { redirect_to :controller => 'profile', :action => 'index', notice: 'Suggestion was successfully created.' }
else
format.html { render action: "new" }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def suggest\n @suggestions = suggestions_service.suggestions\n render 'suggest', layout: false\n end",
"def suggestions\n suggest(search_suggestions)\n end",
"def create\n @suggestion = Suggestion.new(suggestion_params)\n\n if @suggestion.save\n render :show, status: :created, locatio... | [
"0.71769315",
"0.69647485",
"0.69324344",
"0.6886024",
"0.6859701",
"0.6859701",
"0.6831595",
"0.6822349",
"0.6787382",
"0.6739569",
"0.66942817",
"0.6672928",
"0.6663233",
"0.66093683",
"0.6562772",
"0.65519756",
"0.653803",
"0.65379304",
"0.65335053",
"0.6528325",
"0.652559... | 0.56217647 | 96 |
PUT /suggestions/1 PUT /suggestions/1.json | def update
@suggestion = Suggestion.find(params[:id])
respond_to do |format|
if @suggestion.update_attributes(params[:suggestion])
format.html { redirect_to @suggestion, notice: 'Suggestion was successfully updated.' }
format.json { head :ok }
else
format.html { render action: "edit" }
format.json { render json: @suggestion.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update!(**args)\n @suggestions = args[:suggestions] if args.key?(:suggestions)\n end",
"def update!(**args)\n @suggestions = args[:suggestions] if args.key?(:suggestions)\n end",
"def update!(**args)\n @suggestions = args[:suggestions] if args.key?(:suggestions)\n ... | [
"0.73000157",
"0.72999185",
"0.7298716",
"0.7027647",
"0.68784666",
"0.6868386",
"0.67499083",
"0.67188364",
"0.66793126",
"0.6664064",
"0.665388",
"0.6591542",
"0.65357953",
"0.65357953",
"0.65357953",
"0.65357953",
"0.65357953",
"0.65357953",
"0.65357953",
"0.65355194",
"0.... | 0.70185274 | 4 |
GET /metric_sources GET /metric_sources.json | def index
@metric_sources = MetricSource.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def data_sources\n src.collect{|v| v['source']}\n end",
"def v1_measurement_sources_get_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: MeasurementsApi.v1_measurement_sources_get ...\"\n end\n # resource path\n local_var_... | [
"0.66277605",
"0.6445829",
"0.6391722",
"0.6261962",
"0.62494874",
"0.62383044",
"0.6093816",
"0.60848826",
"0.60661703",
"0.60651433",
"0.6038971",
"0.6007916",
"0.5851436",
"0.58012366",
"0.57615757",
"0.5693575",
"0.5676205",
"0.5592717",
"0.55799645",
"0.55794305",
"0.556... | 0.7550348 | 0 |
GET /metric_sources/1 GET /metric_sources/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @metric_sources = MetricSource.all\n end",
"def v1_measurement_sources_get_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: MeasurementsApi.v1_measurement_sources_get ...\"\n end\n # resource path\n local_var_p... | [
"0.7297286",
"0.6602979",
"0.633395",
"0.60801166",
"0.5999042",
"0.5980836",
"0.5931754",
"0.58899045",
"0.58243006",
"0.5783212",
"0.5709409",
"0.56490606",
"0.5644356",
"0.562067",
"0.56043553",
"0.56009334",
"0.5578092",
"0.5577744",
"0.55491894",
"0.55279607",
"0.5522895... | 0.0 | -1 |
POST /metric_sources POST /metric_sources.json | def create
@metric_source = MetricSource.new(metric_source_params)
respond_to do |format|
if @metric_source.save
format.html { redirect_to @metric_source, notice: 'Metric source was successfully created.' }
format.json { render :show, status: :created, location: @metric_source }
else
format.html { render :new }
format.json { render json: @metric_source.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @metric_sources = MetricSource.all\n end",
"def metric_source_params\n params.require(:metric_source).permit(:host, :port, :database)\n end",
"def v1_measurement_sources_post(body, opts = {})\n v1_measurement_sources_post_with_http_info(body, opts)\n return nil\n end",
"d... | [
"0.6303889",
"0.6221403",
"0.5960758",
"0.583662",
"0.58281815",
"0.58133495",
"0.572284",
"0.5559883",
"0.554318",
"0.53869396",
"0.5359682",
"0.53440577",
"0.53251487",
"0.52945566",
"0.5258054",
"0.52345407",
"0.52301395",
"0.5214242",
"0.5211699",
"0.51959276",
"0.5182485... | 0.709647 | 0 |
PATCH/PUT /metric_sources/1 PATCH/PUT /metric_sources/1.json | def update
respond_to do |format|
if @metric_source.update(metric_source_params)
format.html { redirect_to @metric_source, notice: 'Metric source was successfully updated.' }
format.json { render :show, status: :ok, location: @metric_source }
else
format.html { render :edit }
format.json { render json: @metric_source.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_metric_source\n @metric_source = MetricSource.find(params[:id])\n end",
"def update\n source = Source.find_by(id: params[:source_id])\n unless source_params[:name] == source.name\n render json: {error: 'You cannot change external api for a source, you must delete that source if you wis... | [
"0.6190008",
"0.61090916",
"0.5785837",
"0.5718648",
"0.5637591",
"0.56240416",
"0.5618999",
"0.5611183",
"0.5611183",
"0.55883193",
"0.55845875",
"0.5579154",
"0.5569169",
"0.5560742",
"0.5555492",
"0.55501014",
"0.55487114",
"0.55292803",
"0.55226487",
"0.5513215",
"0.54824... | 0.7165161 | 0 |
DELETE /metric_sources/1 DELETE /metric_sources/1.json | def destroy
@metric_source.destroy
respond_to do |format|
format.html { redirect_to metric_sources_url, notice: 'Metric source was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @source = Source.find(params[:id])\n @source.destroy\n\n respond_to do |format|\n format.html { redirect_to report_sources_path }\n format.json { head :no_content }\n end\n end",
"def destroy\n @metric = Metric.find(params[:id])\n @metric.destroy\n\n head :no_content... | [
"0.66007483",
"0.65632063",
"0.6531628",
"0.6472765",
"0.6459897",
"0.6456585",
"0.6456585",
"0.6414121",
"0.6391749",
"0.6391665",
"0.6391665",
"0.6309538",
"0.62866175",
"0.62614095",
"0.62511986",
"0.6240843",
"0.6223965",
"0.6222224",
"0.6214232",
"0.62033653",
"0.6199345... | 0.77900636 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_metric_source
@metric_source = MetricSource.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 metric_source_params
params.require(:metric_source).permit(:host, :port, :database)
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.6980957",
"0.6783065",
"0.6747844",
"0.6741468",
"0.67356336",
"0.6592548",
"0.65036845",
"0.64978707",
"0.64825076",
"0.64795035",
"0.64560914",
"0.64397955",
"0.6379666",
"0.6376688",
"0.6366702",
"0.6319728",
"0.6300833",
"0.6300629",
"0.6294277",
"0.6293905",
"0.629117... | 0.0 | -1 |
Thumbnail sizing Gives a thumbnail size automatically on create | def test_thumb_size_too_big
assert @photo.valid?
@photo.thumb_l = 169
assert !@photo.valid?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def thumbnail(size); end",
"def sized(width, height)\n\t\t\t@sized_thumb = @template\n\t\t\t@sized_thumb.sub! \"{width}\", width.to_s\n\t\t\t@sized_thumb.sub! \"{height}\", height.to_s\n\t\tend",
"def create_thumbnail\n return create_resized_pic(THUMBNAIL_HEIGHT, THUMBNAIL_WIDTH, SIZE_THUMBNAIL)\n end",
... | [
"0.8350897",
"0.7682651",
"0.75983894",
"0.75393814",
"0.7445365",
"0.73863333",
"0.73693365",
"0.71127594",
"0.7040139",
"0.7033831",
"0.7029926",
"0.69692695",
"0.69013536",
"0.6894124",
"0.68636084",
"0.6832816",
"0.6830081",
"0.6827806",
"0.68221",
"0.68144923",
"0.679277... | 0.0 | -1 |
puts "this is a debug message" | def solution(a)
# write your code in Ruby 2.2
left, right = 0, a.reduce(:+)
min = 0
(1...a.size).to_a.each do |i|
left = left + a[i-1]
right = right - a[i-1]
diff = (left - right).abs
if i == 1
min = diff
else
min = diff < min ? diff : min
end
end
min
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def debug(msg)\n #puts msg\n end",
"def debug(s)\n\t#puts \"DEBUG: #{s}\"\nend",
"def print_debug(msg)\n puts msg if (@debug) \n STDOUT.flush\n end",
"def debug(message)\n puts message if debug?\n end",
"def debug(s) if $DEBUG then $stderr.print(\"#{s}\\n\") end end",
"def debug_ms... | [
"0.8406359",
"0.8268479",
"0.8211071",
"0.8138492",
"0.8107914",
"0.80671936",
"0.8004696",
"0.79987866",
"0.7975501",
"0.7975501",
"0.7975501",
"0.79284",
"0.78572273",
"0.78488684",
"0.7837523",
"0.7821288",
"0.7821288",
"0.7792199",
"0.7773948",
"0.7743215",
"0.7739327",
... | 0.0 | -1 |
method to extract minors | def minor(m,i)
n = m.length
mb = m[1..-1]
mb.map{|row| row.first(i) + row[i+1..n-1]}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def minions\r\n @minions.list\r\n end",
"def extract_min\n extract_key = peek_min.key\n min_head = new_heap_from_children\n remove_min_from_heap\n\n # Union\n @head = union(self, BinomialHeap.new(min_head))\n h_next = head.sibling\n consolidate(head, h_next)\n # get new @min\n\n ... | [
"0.6580026",
"0.63092816",
"0.5910332",
"0.57574993",
"0.5753128",
"0.5694006",
"0.55936056",
"0.5586039",
"0.5547664",
"0.5510748",
"0.5480937",
"0.5468981",
"0.5422632",
"0.5415852",
"0.5403625",
"0.53320736",
"0.53131187",
"0.5299023",
"0.5299023",
"0.52903056",
"0.5261932... | 0.0 | -1 |
Marshals the _request_object_ to a JSON string using request_objectto_h | def marshal(request_object)
JSON.pretty_generate(request_object.to_h)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_json(*_args)\n @request.to_json\n end",
"def to_json(*_args)\n @request.to_json\n end",
"def encode(object)\n object.to_json\n end",
"def json\n Oj.to_json(@req)\n end",
"def to_json\n request.clone.to_json\n end",
"def toJSON(object)\n\t\tre... | [
"0.69770724",
"0.69770724",
"0.6881005",
"0.6627694",
"0.6525249",
"0.6495019",
"0.64930177",
"0.64788723",
"0.6333703",
"0.63162804",
"0.6252275",
"0.6227398",
"0.6222578",
"0.61889935",
"0.6159585",
"0.6138563",
"0.6137749",
"0.6137749",
"0.6108434",
"0.6108434",
"0.6097783... | 0.8793168 | 0 |
Unmarshals a JSON string into an object of type _klass_ using klass.new_from_hash | def unmarshal(json_string, klass)
if json_string.nil?
return nil
elsif json_string.length == 0
return ''
end
if klass.respond_to?(:new_from_hash)
klass.new_from_hash(JSON.load(json_string))
else
raise NotImplementedError
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def from_json(json:, klass:)\n hash = JSON.load(json)\n from_hash(hash: hash, klass: klass)\n end",
"def from_json(json:, klass:, use_alias: false)\n hash = JSON.load(json)\n from_hash(hash: hash, klass: klass, use_alias: use_alias)\n end",
"def from_json(json)\n new JSON.par... | [
"0.7809021",
"0.7148607",
"0.70119697",
"0.695165",
"0.6752648",
"0.65935934",
"0.6579648",
"0.638095",
"0.63557273",
"0.6327854",
"0.63100433",
"0.6272995",
"0.6204618",
"0.620255",
"0.6185165",
"0.61575234",
"0.6112106",
"0.6112106",
"0.6105587",
"0.6105587",
"0.60926837",
... | 0.8070366 | 0 |
titleSlide() This is the first method that runs, and then calls menu() | def titleSlide()
=begin
print "\n-------------------------------------------------------------------------\n"
print $titleSlideFont.write("Console Light Show")
print "\nA program for Joshua Bruce\nWritten with love by Robert Leslie\n"
print "---------------------------------------------------------------------------\n"
=end
titleSlideFont = TTY::Font.new(:standard)
titleBox = TTY::Box.frame(
width: TTY::Screen.width-1,
height: 15,
border: :thick,
align: :center,
padding: 1
)do
"#{titleSlideFont.write("Console Light Show")}
\nA program for Joshua Bruce\nWritten with love by Robert Leslie\n2019"
end
print titleBox
menu()
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run_normal\n welcome_header\n main_menu \n end",
"def goto_title(delay = 30)\r\n fadeout_all\r\n Graphics.wait(delay)\r\n SceneManager.goto(Scene_Title)\r\n end",
"def command_to_title\r\n # Play decision SE\r\n $game_system.se_play($data_system.decision_se)\r\n # Fad... | [
"0.6799781",
"0.6745861",
"0.64579237",
"0.6402513",
"0.63225865",
"0.6228538",
"0.61887145",
"0.61698556",
"0.6157576",
"0.6118033",
"0.6112168",
"0.60834444",
"0.60691595",
"0.6065486",
"0.6064926",
"0.6064926",
"0.6064926",
"0.60427964",
"0.6037542",
"0.6032545",
"0.603136... | 0.6222469 | 6 |
menu() instead of having to run a very long command line, every single method calls this function in some form to return the user to this place, which can then safely end the program (unless the user performs an interrupt using Ctrl + C in the command\/terminal prompt, but that is not very nice, now is it?) | def menu()
print "\n-------------------------------------------------------------------------\n"
puts "1) Print Random Letters, Numbers, and Symbols (For a given set of time in seconds)"
puts "2) Enter a string to be printed in random colors (For a given set of time in seconds)"
puts "99) Beta Functions"
puts "100) End Program"
coin = gets.to_i
case(coin)
when 1
printRandom(getDuration())
when 2
puts "Enter your strings to be printed, separated by a comma"
str = gets.chomp
printStringS(str, getDuration())
when 99
puts "Entering Beta Functions..."
betaFuntions()
when 100
puts "Bye Bye"
when -1
infiniteLoopWarning(1)
else
puts "Undefined input"
menu()
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show_menu\n puts \"Type 'q' to quit\"\n puts \"Or press Return to continue\"\nend",
"def menu()\n system('clear')\n puts '==================== M E N U ===================='.colorize(:light_blue)\n puts \" Press enter to start\".colorize(:green)\n gets.chomp\n @@support.help\n ... | [
"0.79807675",
"0.7569223",
"0.7413971",
"0.7380073",
"0.7360637",
"0.73490816",
"0.73489606",
"0.7323422",
"0.73112",
"0.71781754",
"0.7174452",
"0.71654123",
"0.7164307",
"0.71610934",
"0.7147149",
"0.7144417",
"0.71277463",
"0.71277463",
"0.711951",
"0.711951",
"0.711223",
... | 0.0 | -1 |
This method is a menu used to call and test functions which I quite haven't yet ironed out the kinks, I haven't thrown into the menu yet, or don't fit quite right for the menu | def betaFuntions()
print "\n-------------------------------------------------------------------------\n"
puts "These are the Beta Functions, these are functions that are not quite thought"
puts "yet, I havne't put into the main menu yet, or isn't quite right for the menu"
puts "Use these at your own discretion, I'm not your dad"
puts "1) getIsMe()"
puts "2) getOnMe() (heheheheh)"
puts "3) printStringRandomFont(string, duration)"
puts "4) printRandomFont(duration)"
puts "5) getFont()"
puts "99) Infinite Loop warning Message"
puts "100) Return to safety"
coin = gets.to_i
case(coin)
when 1
getIsMe()
when 2
getOnMe() #heheheheheh
when 99
infiniteLoopWarning(0)
when 100
menu()
when 3
puts "Enter your strings to be printed, separated by a comma"
str = gets.chomp
printStringRandomFont(str, getDuration())
when 4
printRandomFont(getDuration())
when 5
getFont()
else
puts "Undefined Input\nReturning To Safety"
menu()
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def main_menu\n name_selector\n puts \"Okay #{@name}, what would you like to do?\"\n loop do\n case menu_arrows\n when '1'\n @recommendation.recommendation_menu\n when '2'\n puts 'you have the following number of games in your library: '\n @game_library.game_instances\n... | [
"0.7416875",
"0.73825264",
"0.719878",
"0.7191419",
"0.71611387",
"0.7099529",
"0.70819247",
"0.7017779",
"0.70097107",
"0.6987493",
"0.6982442",
"0.6972278",
"0.69594455",
"0.6957965",
"0.6950839",
"0.6934846",
"0.6919071",
"0.68772995",
"0.68765634",
"0.6871877",
"0.6871877... | 0.0 | -1 |
isMe(str) Passed a string, and returns the string as a pastel with the background depending on a randomly generated number | def isMe(str)
case $prng1.rand(1..6)
when 1
return $pastel.red(str)
when 2
return $pastel.green(str)
when 3
return $pastel.yellow(str)
when 4
return $pastel.blue(str)
when 5
return $pastel.magenta(str)
when 6
return $pastel.cyan(str)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def onMe(str)\n case $prng1.rand(1..6)\n when 1\n return $pastel.on_red(str)\n when 2\n return $pastel.on_green(str)\n when 3\n return $pastel.on_yellow(str)\n when 4\n return $pastel.on_blue(str)\n when 5\n return $pastel.on_magenta(str)\n when 6\n re... | [
"0.6822564",
"0.62595063",
"0.5952448",
"0.58726877",
"0.57527214",
"0.5648092",
"0.5625498",
"0.56076586",
"0.5595542",
"0.55714715",
"0.5563615",
"0.556184",
"0.5527345",
"0.5523645",
"0.5500495",
"0.54868793",
"0.5482332",
"0.5478909",
"0.5471816",
"0.5457307",
"0.54439515... | 0.8011491 | 0 |
onMe(str) Passed a string, and returns it as a pastel string with the background changed Depending on a random number | def onMe(str)
case $prng1.rand(1..6)
when 1
return $pastel.on_red(str)
when 2
return $pastel.on_green(str)
when 3
return $pastel.on_yellow(str)
when 4
return $pastel.on_blue(str)
when 5
return $pastel.on_magenta(str)
when 6
return $pastel.on_cyan(str)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def isMe(str)\n case $prng1.rand(1..6)\n when 1\n return $pastel.red(str)\n when 2\n return $pastel.green(str)\n when 3\n return $pastel.yellow(str)\n when 4\n return $pastel.blue(str)\n when 5\n return $pastel.magenta(str)\n when 6\n return $pastel.cy... | [
"0.7293182",
"0.6238231",
"0.61357147",
"0.60416496",
"0.60021955",
"0.5953776",
"0.5866313",
"0.5863987",
"0.5830028",
"0.57968444",
"0.5793305",
"0.57177734",
"0.56975555",
"0.5678245",
"0.5678075",
"0.5672203",
"0.5615061",
"0.5598038",
"0.5596516",
"0.553829",
"0.5522357"... | 0.7763928 | 0 |
returnFont(str) Passed a string, and returns it as a TTYfont which always has a new line at the end, which the font is dependent on a random number | def returnFont(str)
case $prng1.rand(1..5)
# when 1
# $fontFont = TTY::Font.new("3d")
# return $fontFont.write(str)
when 2
$fontFont = TTY::Font.new(:doom)
return $fontFont.write(str)
when 3
$fontFont = TTY::Font.new(:standard)
return $fontFont.write(str)
when 4
$fontFont = TTY::Font.new(:starwars)
return $fontFont.write(str)
when 5
$fontFont = TTY::Font.new(:straight)
return $fontFont.write(str)
else
$fontFont = TTY::Font.new(:standard)
return $fontFont.write(str)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def printStringRandomFont(printMe, duration)\n x = printMe.split(\", \")\n currentTime = Time.now.to_i\n futureTime = currentTime + duration\n while (currentTime <= futureTime) do\n print \"#{isMe(onMe(\"\\n#{returnFont(x[$prng.rand(0...x.length())])}\\n\\n\"))}\"\n currentTime = Time.now... | [
"0.6373198",
"0.62699497",
"0.5854242",
"0.5825746",
"0.5771107",
"0.5691184",
"0.5671456",
"0.56694084",
"0.56310356",
"0.56266737",
"0.56012356",
"0.5599312",
"0.55815506",
"0.55778265",
"0.5555534",
"0.5555534",
"0.55336475",
"0.5479716",
"0.5475523",
"0.5461922",
"0.54548... | 0.7918338 | 0 |
getIsMe() Returns an integer array (max 6) of user picked numbers, which corresponds to the colors that work well with the command prompt (this program has not yet been tested to work in any Linux Kernel, for reasons of lazyness) Note to self: GET THIS SHIT TO WORK, THEN MAKE EACH SELECTION REPRESENT THAT COLOR, DO THIS FOR getOnMe() TOO | def getIsMe()
puts "Enter the colors you want the printed string to be"
puts "1) Red\n2) Green\n3) Yellow\n4) Blue\n5) Magenta\n6) Cyan"
isMeString = gets.chomp.split(", ")
(0...isMeString.length()).each do |i|
isMeString[i] = isMeString[i].to_i
end
puts "Chosen Numbers: #{isMeString}"
return isMeString
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getOnMe()\n puts \"Enter the colors you want the background of the printed strings to be ON (the background)\"\n puts \"1) Red\\n2) Green\\n3) Yellow\\n4) Blue\\n5) Magenta\\n6) Cyan\"\n onMeString = gets.chomp.split(\", \")\n (0...onMeString.length()).each do |i|\n onMeString[i] = onMeStrin... | [
"0.6934101",
"0.6502392",
"0.6462207",
"0.6407704",
"0.63438225",
"0.6285216",
"0.6257975",
"0.61168754",
"0.6062321",
"0.60447246",
"0.59515584",
"0.59136915",
"0.5904335",
"0.58938307",
"0.58680624",
"0.58318514",
"0.5769378",
"0.5742568",
"0.5686361",
"0.56224257",
"0.5611... | 0.67435735 | 1 |
getOnMe() See: getIsMe(). Its exactly the same as that but it is for the background color of the stirng printed. I'm realising now that I can just call the getisMe() method twice for a statement, but I like the name of this method too much, so I'm keeping it. | def getOnMe()
puts "Enter the colors you want the background of the printed strings to be ON (the background)"
puts "1) Red\n2) Green\n3) Yellow\n4) Blue\n5) Magenta\n6) Cyan"
onMeString = gets.chomp.split(", ")
(0...onMeString.length()).each do |i|
onMeString[i] = onMeString[i].to_i
end
puts "Chosen Numbers: #{onMeString}"
return onMeString
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def blue = \"\\e[36m#{self}\\e[0m\"",
"def colorized?; end",
"def isMe(str)\n case $prng1.rand(1..6)\n when 1\n return $pastel.red(str)\n when 2\n return $pastel.green(str)\n when 3\n return $pastel.yellow(str)\n when 4\n return $pastel.blue(str)\n when 5\n ... | [
"0.610704",
"0.6044335",
"0.60258615",
"0.6012948",
"0.6012948",
"0.5934339",
"0.5932155",
"0.5932155",
"0.5895948",
"0.5895948",
"0.5895948",
"0.5815126",
"0.576262",
"0.576262",
"0.5751427",
"0.5732536",
"0.5730394",
"0.57264024",
"0.56779146",
"0.5668724",
"0.56199825",
... | 0.0 | -1 |
getFont() See: getIsMe(). Its exactly the same as that except this is for the FONT of the printed strings. This will eventually be passed into a method that calls those font(s) the user picked. | def getFont()
puts "Enter font(s) you want"
puts "1) Doom\n2) Standard\n3) Star Wars\n4) Straight\n"
fontMe = gets.chomp.split(", ")
(0...fontMe.length()).each do |i|
fontMe[i] = fontMe[i].to_i
end
puts "Chosen Numbers: #{fontMe}"
return fontMe
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def font\n return @font\n end",
"def font\n\t\treturn @font\n\tend",
"def fontName\n return @font_name\n end",
"def font\n @font_path\n end",
"def font(name=nil, size=nil, options={})\n cur_page.font(name, size, options)\n end",
"def font=(value)\n ... | [
"0.7163284",
"0.70176446",
"0.6831852",
"0.6807011",
"0.67599624",
"0.6721139",
"0.6718104",
"0.66663325",
"0.6623491",
"0.65921557",
"0.6590611",
"0.65260506",
"0.65060997",
"0.64129794",
"0.63956726",
"0.63722026",
"0.63655585",
"0.636294",
"0.6294848",
"0.6267017",
"0.6203... | 0.0 | -1 |
Hahahha its not like I even need this method now, do I? | def getDuration()
puts "Enter duration (in seconds)"
return gets.to_i
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def private; end",
"def schubert; end",
"def suivre; end",
"def probers; end",
"def who_we_are\r\n end",
"def specie; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def weber; end",
"def refutal()\n end",
"def zuruecksetzen()\n end",
"def anchored; end",
"def jack_ha... | [
"0.7655734",
"0.72888225",
"0.7284377",
"0.71844465",
"0.69513756",
"0.6845551",
"0.6845551",
"0.6845551",
"0.6845551",
"0.6751847",
"0.6706008",
"0.6664528",
"0.6652801",
"0.6595214",
"0.6591525",
"0.6519477",
"0.64988214",
"0.64988214",
"0.6467656",
"0.6463441",
"0.6463441"... | 0.0 | -1 |
printRandom(int duration) Passed an integer, interpreted as a duration in seconds for a while loop to run, prints out random symbols in a string array in randomly picked colors for a given duration, and then calls the menu function | def printRandom(duration)
st = "q,w,e,r,t,y,u,i,o,p,a,s,d,f,g,h,j,k,l,z,x,c,v,b,n,m,Q,W,E,R,T,Y,U,I,O,P,A,S,D,F,G,H,J,K,L,Z,X,C,V,B,N,M,1,2,3,4,5,6,7,8,9,0,!,@,#,$,%,^,&,*,(,),_,+,[,],|,{,}"
x = st.split(",")
currentTime = Time.now.to_i
futureTime = currentTime + duration
while (currentTime <= futureTime) do
print "#{isMe(onMe( x[$prng.rand(0...x.length())] ))}"
currentTime = Time.now.to_i
end
menu()
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def printStringRandomFont(printMe, duration)\n x = printMe.split(\", \")\n currentTime = Time.now.to_i\n futureTime = currentTime + duration\n while (currentTime <= futureTime) do\n print \"#{isMe(onMe(\"\\n#{returnFont(x[$prng.rand(0...x.length())])}\\n\\n\"))}\"\n currentTime = Time.now... | [
"0.7819071",
"0.7719222",
"0.7337845",
"0.6795813",
"0.6752646",
"0.6651901",
"0.65144366",
"0.6267164",
"0.6201734",
"0.618687",
"0.6175224",
"0.6157515",
"0.6077647",
"0.6062917",
"0.6056033",
"0.6046337",
"0.60086596",
"0.59682584",
"0.5912481",
"0.5898218",
"0.58981365",
... | 0.78929853 | 0 |
printStringS(string printMe, int duration) Passed a string and a duration, the code creates a string array split at a comma followed by a space. I know there can be some problems with this but this was the first thing that came to mind. I could use a regex but what ever. This does the same exact thing as the other printing functions so I expect the person reading this code to assume what this method does. | def printStringS(printMe, duration)
x = printMe.split(", ")
currentTime = Time.now.to_i
futureTime = currentTime + duration
while (currentTime <= futureTime) do
print "#{isMe(onMe(x[$prng.rand(0...x.length())]))}"
currentTime = Time.now.to_i
end
menu()
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def string_splitter( string )\n\n array = []\n array = string.split(\"\")\n p array\n return array\n\nend",
"def space_separated(str: raise)\n\tfirst_index = 0\n\tlast_index = 0\n\tresults = []\n\n\tstr.size.times do\n\t\tcheck_string = str[first_index..last_index]\n\t\tif DICTIONARY[check_string]\n\t\t\tres... | [
"0.5394821",
"0.5392412",
"0.53802735",
"0.53696316",
"0.5271568",
"0.525917",
"0.5206748",
"0.5192149",
"0.5184887",
"0.5177218",
"0.5157017",
"0.51315856",
"0.51269263",
"0.5062674",
"0.5057844",
"0.5055729",
"0.5043236",
"0.50301117",
"0.5020443",
"0.49807832",
"0.497843",... | 0.6095845 | 0 |
printStringFont(printMe, duration) Passed a string and a duration, the code creates an array | def printStringRandomFont(printMe, duration)
x = printMe.split(", ")
currentTime = Time.now.to_i
futureTime = currentTime + duration
while (currentTime <= futureTime) do
print "#{isMe(onMe("\n#{returnFont(x[$prng.rand(0...x.length())])}\n\n"))}"
currentTime = Time.now.to_i
end
menu()
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def printRandomFont(duration)\n st = \"A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,0,1,2,3,4,5,6,7,8,9\"\n x = st.split(\",\")\n currentTime = Time.now.to_i\n futureTime = currentTime + duration\n while (currentTime <= futureTime)do\n ... | [
"0.7082753",
"0.70182985",
"0.6287385",
"0.59701514",
"0.5935123",
"0.57840484",
"0.5696641",
"0.5671314",
"0.5583725",
"0.55798",
"0.55558866",
"0.55276823",
"0.5523067",
"0.5484647",
"0.5476543",
"0.54740113",
"0.5458908",
"0.54549724",
"0.5443103",
"0.54390556",
"0.5432878... | 0.7331457 | 0 |
printRandomFont(duration) Prints random fonts in random colors. THere's a weird issue about a space at the end of the print statement and I don't like it :( | def printRandomFont(duration)
st = "A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,0,1,2,3,4,5,6,7,8,9"
x = st.split(",")
currentTime = Time.now.to_i
futureTime = currentTime + duration
while (currentTime <= futureTime)do
print "#{isMe(onMe("\n#{returnFont(x[$prng.rand(0...x.length())])}\n\n"))}"
currentTime = Time.now.to_i
end
menu()
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def printStringRandomFont(printMe, duration)\n x = printMe.split(\", \")\n currentTime = Time.now.to_i\n futureTime = currentTime + duration\n while (currentTime <= futureTime) do\n print \"#{isMe(onMe(\"\\n#{returnFont(x[$prng.rand(0...x.length())])}\\n\\n\"))}\"\n currentTime = Time.now... | [
"0.8265744",
"0.67774516",
"0.66434515",
"0.6322893",
"0.62821245",
"0.60768193",
"0.60268307",
"0.59610516",
"0.59377813",
"0.59319305",
"0.5915328",
"0.587851",
"0.5870912",
"0.58537483",
"0.58437955",
"0.5835893",
"0.58138955",
"0.58035374",
"0.57865846",
"0.5748406",
"0.5... | 0.84779274 | 0 |
infiniteLoopWarning() This was written early in development incase I knew some logic at some point would cause an infinite loop. I'm keeping this method in here just in case logic is written that could accidentally cause an infinite loop Note to self: make this into a box using TTY | def infiniteLoopWarning(whereAmIFrom)
puts "______________________________________________________________________"
puts "|********************************************************************|"
puts "|********************************************************************|"
puts "|***************************WARNING!*********************************|"
puts "|*************This Method Causes an Infinite Loop!*******************|"
puts "|*******To stop this infinite loop, press CTRL+C in the terminal*****|"
puts "|**********If you wish to continue, enter 'Y' and hit return*********|"
puts "|*********Otherwise, enter anything else and return to safety********|"
puts "|********************************************************************|"
puts "|********************************************************************|"
puts "|____________________________________________________________________|"
case(whereAmIFrom)
when 0
betaFuntions()
when 1
menu()
else
puts "I forgot where I came from, I'm going back to the main menu"
menu()
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def infinite_loop?; end",
"def endless_loop?; end",
"def check_for_infinite_loop(processed_source, offenses_by_iteration); end",
"def loop; end",
"def infinite?; end",
"def keep_looping?\n true\n end",
"def loop_forever; end",
"def pre_loop; end",
"def say_hello\n p \"hello\"\n # say_hello # ... | [
"0.77953",
"0.76390487",
"0.6622432",
"0.65400165",
"0.65247416",
"0.6403027",
"0.6373231",
"0.6268196",
"0.62585306",
"0.61858463",
"0.61858463",
"0.6183321",
"0.61659527",
"0.6134492",
"0.61285883",
"0.608467",
"0.60680455",
"0.60055166",
"0.5943251",
"0.59350204",
"0.59182... | 0.62529755 | 9 |
Takes an enumerator to work with as argument. | def initialize(enum = nil, &blk)
if enum
#The enumerator being used.
@enum = enum
elsif blk
@enum = Enumerator.new do |yielder|
blk.call(yielder)
end
else
raise "No enum or block was given."
end
@eles = []
@end_eles = []
# Used to calculate length without depending corruption.
@length_cache = 0
# If the virtual array has become corrupted because of forgotten elements (by calling each and enumerating through elements).
@array_corrupted = false
# To allow the object to be thread-safe.
@mutex = Mutex.new
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def enumerator ; end",
"def enumerator ; end",
"def enumerator; end",
"def initialize(enumerator)\n @enumerator = enumerator\n end",
"def each &block\n if block_given?\n iterate_each &block\n self\n else\n self.to_enum\n end\n end",
"def each\n if block_given?\n ... | [
"0.76930577",
"0.76930577",
"0.74891657",
"0.69930017",
"0.6499236",
"0.63552153",
"0.63498425",
"0.6319797",
"0.6299976",
"0.6237401",
"0.6231643",
"0.6198141",
"0.6145268",
"0.6138899",
"0.61232275",
"0.6090671",
"0.607028",
"0.6049706",
"0.6042774",
"0.60382044",
"0.602971... | 0.5290933 | 91 |
Cache the first elements (if not cached already) and returns it. | def first
check_corrupted
cache_ele if @eles.empty?
return @eles.first
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def first\n items.compact.first\n end",
"def get_first\n return @head.data if @head\n return @head\n end",
"def first\n self.take(1)[0]\n end",
"def first\n @head.lru_next\n end",
"def first\n @ordered_elements.first\n end",
"def get_first\n return @head ? @head.data : n... | [
"0.6740814",
"0.67160505",
"0.6685045",
"0.6624165",
"0.6600085",
"0.6591254",
"0.6564186",
"0.65391654",
"0.6535495",
"0.65317184",
"0.6508876",
"0.65011096",
"0.6491118",
"0.64525986",
"0.64417773",
"0.6436038",
"0.64311564",
"0.6399928",
"0.6399928",
"0.6398635",
"0.637434... | 0.73728454 | 0 |
Returns true if the arrayenumerator is empty. | def empty?
if @empty == nil
cache_ele if @length_cache == 0
if @length_cache > 0
@empty = false
else
@empty = true
end
end
return @empty
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def empty?\n @iterator.nil?\n end",
"def empty?\n iterator.nil?\n end",
"def empty?\r\n @arr.empty?\r\n end",
"def empty?\n to_ary.empty?\n end",
"def empty?\n to_ary.empty?\n end",
"def empty?\n to_ary.empty?\n end",
"def empty?\n @ary.emp... | [
"0.8013646",
"0.8012338",
"0.7983263",
"0.789861",
"0.789861",
"0.78563607",
"0.7804117",
"0.7783732",
"0.77368253",
"0.77368253",
"0.77368253",
"0.7724417",
"0.77150285",
"0.77150285",
"0.77045745",
"0.7695986",
"0.7680893",
"0.7679936",
"0.7670419",
"0.7660207",
"0.7660207"... | 0.0 | -1 |
Returns each element and releases them from cache. | def each(&block)
if block
to_enum.each(&block)
return nil
else
return to_enum
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cache(count)\n @cached_elements = active_elements.pop(count)\n return\n end",
"def free\n cache.clear\n nil\n end",
"def invalidate_cache!\n elements.each do |element|\n element.invalidate_cache!\n end\n\n self\n end",
"def cache_all\n begin\n @mut... | [
"0.6973532",
"0.6196989",
"0.6178804",
"0.60938716",
"0.5883575",
"0.58788705",
"0.5837647",
"0.5801962",
"0.5778058",
"0.5765341",
"0.57640266",
"0.57034814",
"0.56749713",
"0.56749713",
"0.56749713",
"0.56749713",
"0.56749713",
"0.56749713",
"0.56749713",
"0.56175804",
"0.5... | 0.0 | -1 |
This method should only be used with 'each_index'. | def [](key)
if @each_index && @each_index.key?(key)
ret = @each_index[key]
@each_index.delete(key)
return ret
end
raise "This only works when also using 'each_index'. Invalid key: '#{key}'."
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def each_child_with_index\n end",
"def each_child_index\n end",
"def my_each_with_index\n\t\tself.length.times do |index|\n\t\t\tyield(self[index], index)\n\t\tend\n\tend",
"def raise_index!\n @index += 1\n end",
"def each_with_index(&block)\n to_a.each_with_index(&block)\n end",
"def e... | [
"0.6800131",
"0.66231084",
"0.6539461",
"0.6506758",
"0.63712955",
"0.63712955",
"0.6327163",
"0.62712497",
"0.6257605",
"0.625735",
"0.62397224",
"0.62275606",
"0.6197853",
"0.6178756",
"0.6135701",
"0.6129638",
"0.61199296",
"0.61155254",
"0.6112531",
"0.6110354",
"0.610673... | 0.0 | -1 |
Yields each countkey and caches element for returning it by using the []method. | def each_index(&block)
enum = Enumerator.new do |yielder|
begin
@each_index = {}
count = 0
self.each do |ele|
# Remove previous element to not take up memory.
count_before = count - 1
@each_index.delete(count_before) if @each_index.key?(count_before)
# Add current element to cache.
@each_index[count] = ele
yield(count)
# Increase count for next run.
count += 1
end
ensure
@each_index = nil
end
end
if block
enum.each(&block)
return nil
else
return enum
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def [](key)\n i = 1\n desired_index = index(key, size)\n while @items[desired_index].key != key\n desired_index += i**2\n i += 1\n end\n\n return @items[desired_index].value\n end",
"def each_key(&block); end",
"def finalize\n yield [key, @count]\n end",
"def each\n @... | [
"0.65200365",
"0.641567",
"0.64118683",
"0.6328605",
"0.63226575",
"0.6300463",
"0.6259036",
"0.62395865",
"0.61929506",
"0.6191512",
"0.61428714",
"0.6076651",
"0.5988484",
"0.5986315",
"0.5951433",
"0.59340775",
"0.59340775",
"0.59335816",
"0.5923167",
"0.5921202",
"0.59028... | 0.6580912 | 0 |
Returns a enumerator that can yield all the elements (both cached and future uncached ones). | def to_enum
check_corrupted
@array_corrupted = true
return Enumerator.new do |yielder|
while ele = @eles.shift
yielder << ele
end
yield_rest do |ele|
yielder << ele
end
while ele = @end_eles.shift
yielder << ele
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cache_all\n begin\n @mutex.synchronize do\n while ele = @enum.next\n @length_cache += 1\n @eles << ele\n end\n end\n rescue StopIteration\n @end = true\n end\n end",
"def cycle()\n Enumerator.new do |out|\n values = self.touch{|x| out.yield x}.... | [
"0.7156392",
"0.6508514",
"0.63153464",
"0.63153464",
"0.62896097",
"0.62733287",
"0.6248347",
"0.62035775",
"0.617342",
"0.6169629",
"0.6157273",
"0.6156464",
"0.6151761",
"0.6151761",
"0.6143435",
"0.61367726",
"0.61337703",
"0.6119522",
"0.6086988",
"0.6078656",
"0.6071887... | 0.0 | -1 |
Returns the counted length. Can only be called after the end of the enumerator has been reached. | def length
raise CannotCallBeforeEnd, "Cant call length before the end has been reached." unless @end
return @length_cache
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def length\n each.count\n end",
"def length\n count\n end",
"def length\n @count\n end",
"def length\r\n self.count\r\n end",
"def length; count end",
"def length\n count = 0\n each { count += 1 }\n count\n end",
"def size\n it = iterator\n it.size\n ... | [
"0.77859384",
"0.75392175",
"0.7527459",
"0.74279743",
"0.74182385",
"0.7343085",
"0.7341371",
"0.7329341",
"0.7302966",
"0.7255458",
"0.72254574",
"0.7207516",
"0.71943486",
"0.71807534",
"0.7151463",
"0.70933056",
"0.70712405",
"0.7069975",
"0.703647",
"0.703647",
"0.700926... | 0.7076803 | 16 |
Giving slice negaive arguments will force it to cache all elements and crush the memory for big results. | def slice(*args)
check_corrupted
if args[0].is_a?(Range) && !args[1]
need_eles = args[0].begin + args[0].end
elsif args[0] && !args[1]
need_eles = args[0]
elsif args[0] && args[1] && args[0] > 0 && args[1] > 0
need_eles = args[0] + args[1]
elsif args[0] < 0 || args[1] < 0
raise ArgumentError, "Slice cant take negative arguments."
else
raise ArgumentError, "Dont now what to do with args: '#{args}'."
end
@eles ||= []
cache_eles = need_eles - @eles.length if need_eles
cache_ele(cache_eles) if need_eles && cache_eles > 0
return @eles.slice(*args)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def slice!(*args)\n # lazy load the collection, and remove the matching entries\n orphaned = orphan_resources(super)\n\n # Workaround for Ruby <= 1.8.6\n compact! if RUBY_VERSION <= '1.8.6'\n\n unless orphaned.kind_of?(Enumerable)\n return orphaned\n end\n\n offset, limit ... | [
"0.6689691",
"0.6555951",
"0.6256087",
"0.61413586",
"0.6070657",
"0.6068402",
"0.6068402",
"0.60481393",
"0.60481393",
"0.60481393",
"0.6035638",
"0.5954487",
"0.59522265",
"0.594318",
"0.5934288",
"0.59161437",
"0.59161437",
"0.5891549",
"0.5881322",
"0.58536875",
"0.583162... | 0.6435965 | 2 |
Caches necessary needed elements and then returns the result as on a normal array. | def shift(*args)
check_corrupted
if args[0]
amount = args[0]
else
amount = 1
end
@eles ||= []
cache_ele(amount - @eles.length) if @eles.length < amount
res = @eles.shift(*args)
# Since we are removing an element, the length should go down with the amount of elements captured.
if args[0]
@length_cache -= res.length
else
@length_cache -= 1
end
return res
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_cache\n []\n end",
"def cache\n @transpose\n end",
"def cache\n rows.each(&:cache)\n end",
"def data_caches\n (@data_caches || [])\n end",
"def getCache\n keys = Rails.cache.instance_variable_get(:@data).keys\n data = [keys.length]\n\n #If a ci... | [
"0.6984168",
"0.6394703",
"0.6152861",
"0.6102456",
"0.60799986",
"0.6042356",
"0.5970591",
"0.5967334",
"0.59621054",
"0.59621054",
"0.59621054",
"0.59621054",
"0.59621054",
"0.59621054",
"0.59621054",
"0.5935178",
"0.58838564",
"0.58155787",
"0.58038986",
"0.5792339",
"0.57... | 0.0 | -1 |
Returns a normal array with all elements. Can also raise corrupted error if elements have been thrown out. | def to_a
check_corrupted
cache_all
return @eles
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_a; Array(force) end",
"def coerce_array(array, non_empty)\n unless array.kind_of?(Array)\n coercion_error!\n end\n if non_empty and array.empty?\n coercion_error!\n end\n array\n end",
"def to_a; []; end",
"def a... | [
"0.6327811",
"0.6207902",
"0.60584545",
"0.6018229",
"0.5999955",
"0.5979181",
"0.5963324",
"0.5918077",
"0.5899368",
"0.58793414",
"0.5876633",
"0.58589774",
"0.5846337",
"0.58371603",
"0.58151656",
"0.57924086",
"0.5755562",
"0.5750376",
"0.57429296",
"0.57337123",
"0.56966... | 0.61041963 | 2 |
Raises error because elements have been forgotten to spare memory. | def check_corrupted
raise ArrayCorruptedError, "Too late to call. Corrupted." if @array_corrupted
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def try_allocate_next\n while not @waiting_list.empty? and @waiting_list.first[1] <= @free do\n first = @waiting_list.shift\n first[0].req(self, first[1])\n first[0].ready\n end\n end",
"def book_execution(fill)\n# allocate(fill)\n end",
"def allocate_memory( amount )\n return ... | [
"0.56459045",
"0.5611767",
"0.55496514",
"0.55346745",
"0.55346745",
"0.5508365",
"0.5498803",
"0.54919183",
"0.54238194",
"0.53638256",
"0.53223276",
"0.53086746",
"0.529422",
"0.52939916",
"0.52900803",
"0.5275704",
"0.5266398",
"0.522226",
"0.5221263",
"0.51804155",
"0.517... | 0.0 | -1 |
Yields the rest of the elements to the given block. | def yield_rest
@array_corrupted = true
begin
@mutex.synchronize do
loop do
ele = @enum.next
@length_cache += 1
yield(ele)
end
@end = true # How it actually breaks is beyond me...
end
rescue StopIteration
@end = true
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def each(&block)\n i = @elements.length - 1\n while i >= 0\n yield @elements[i]\n i -= 1\n end\n end",
"def each(&block)\n return @parts.each(&block)\n end",
"def each_mid(&block)\n \n end",
"def each(&block)\n each_element(block) if ... | [
"0.72132117",
"0.67873955",
"0.67869896",
"0.6676489",
"0.65819436",
"0.65683365",
"0.6558794",
"0.6537509",
"0.6506344",
"0.6471794",
"0.6457197",
"0.6453752",
"0.6442493",
"0.6432216",
"0.6426067",
"0.64234626",
"0.6405001",
"0.63957584",
"0.6386053",
"0.63793635",
"0.63789... | 0.0 | -1 |
Caches a given amount of elements. | def cache_ele(amount = 1)
begin
@mutex.synchronize do
while @eles.length <= amount
@eles << @enum.next
@length_cache += 1
end
end
rescue StopIteration
@end = true
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cache(count)\n @cached_elements = active_elements.pop(count)\n return\n end",
"def caching rows\n raise ArgumentError, \"Invalid caching size. Must be a non-negative integer.\" unless rows.is_a?(Fixnum) && rows >= 0\n spawn :@caching, rows\n end",
"def reappend_el(index)\n element = @cache... | [
"0.7288147",
"0.65581906",
"0.6442266",
"0.6291514",
"0.6197986",
"0.61684155",
"0.61306196",
"0.6063331",
"0.6041663",
"0.60035473",
"0.60035473",
"0.60035473",
"0.60035473",
"0.60035473",
"0.60035473",
"0.60035473",
"0.5966043",
"0.5913687",
"0.58923423",
"0.58374834",
"0.5... | 0.6586287 | 1 |
Forces the rest of the elements to be cached. | def cache_all
begin
@mutex.synchronize do
while ele = @enum.next
@length_cache += 1
@eles << ele
end
end
rescue StopIteration
@end = true
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cache(count)\n @cached_elements = active_elements.pop(count)\n return\n end",
"def update_cache\n # Does nothing...up to subclasses to implement.\n end",
"def invalidate_cache!\n elements.each do |element|\n element.invalidate_cache!\n end\n\n self\n en... | [
"0.7424256",
"0.7407792",
"0.727837",
"0.7251613",
"0.7251613",
"0.7251613",
"0.7251613",
"0.7251613",
"0.7251613",
"0.7251613",
"0.70731896",
"0.7022682",
"0.70201015",
"0.7003864",
"0.6951931",
"0.690355",
"0.68360835",
"0.6832704",
"0.6832704",
"0.6794257",
"0.6747019",
... | 0.0 | -1 |
Obtiene los elementos HTML | def get_html path
array = []
archivo = File.open(path, 'r:UTF-8')
archivo.each do |l|
array.push(l.strip)
end
archivo.close
return array
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def element\n c = content()\n c = [ c + HTML.div.form_button_bar { @buttons } ] if @buttons\n HTML.form(@attrib) { c }\n end",
"def inner_html\n # This sets up the inner html for the to_html call\n end",
"def html\n `#{@el}.innerHTML`\n end",
"def inner_html\n self.inner_... | [
"0.6872056",
"0.67273533",
"0.6704301",
"0.6558897",
"0.6413072",
"0.64096683",
"0.63698095",
"0.6368281",
"0.6347792",
"0.6347792",
"0.63243484",
"0.63209945",
"0.6314407",
"0.6307073",
"0.6231574",
"0.62306076",
"0.62286973",
"0.61824906",
"0.6156695",
"0.6146184",
"0.60173... | 0.0 | -1 |
Crea los MD a partir de las ayudas de las herramientas | def create_md tool
original = tool[1].split("\n")
new = []
note = false
# Cambia las rutas y < y > por código HTML
def diple l
return l.gsub('de +++YAML+++ en <http://pecas.cliteratu.re>', 'de [+++YAML+++](yaml.html)')
.gsub('de JavaScript en <http://pecas.cliteratu.re>', 'de [JavaScript](js.html)')
.gsub('Lista de acrónimos: <https://github.com/tesseract-ocr/tesseract/blob/master/doc/tesseract.1.asc#languages>', '[Lista de acrónimos](https://github.com/tesseract-ocr/tesseract/blob/master/doc/tesseract.1.asc#languages)')
.gsub('<','<').gsub('>','>')
end
# Agrega versalitas
def smallcaps l
return l.gsub(/([A-Z]{3,})/, '+++\1+++')
end
# Cambia comillas por sintaxis para línea de código
def to_code l
return l.gsub(/«(.+?)»/, '`\1`')
end
# Añade líneas de código en las opciones
def to_code_option l
return l.gsub(/^(\S+)/, '`\1`')
end
new.push('# ' + $l_g_pc_docs_creation + '`' + tool[0] + '`')
original.each_with_index do |l, i|
l = to_code(diple(smallcaps(l)))
if l =~ /^\S/
# Encabezados 2
if l !~ /^Nota/ && i != 1
new.push('## ' + l + "\n\n")
# Párrafos
else
# Notas
if l =~ /^Nota/
if !note
new.push("--- {.espacio-arriba3}\n\n")
note = true
new.push(l + ' {.espacio-arriba3}')
else
new.push(l + ' {.espacio-arriba1 .sin-sangria}')
end
# Descripción
else
# Esto servirá para crear «herramientas.md»
$tools_md["#{tool[0]}"] = [tool[0], l.gsub(/^\S+\s+/, '')]
new.push(l)
end
end
else
if l.strip != ''
l = l.strip
# Opciones de Pecas
if l =~ /^-/
new.push('* ' + to_code_option(l))
# Comandos de Pecas
elsif l =~ /^pc-/
new.push('```')
new.push(l)
new.push('```')
# Explicaciones
elsif l =~ /^[A-Z]/
new.push("\n" + l)
# Dependencias / Tipos
else
# Evita que se quede como línea de código el tipo y su descripción
l_final = []
l.split(/\s+/).each_with_index do |ll, i|
# Solo la primera palabra se va como código
if i == 0
l_final.push('* `' + ll + '`')
# El resto de las palabras se quedan como texto
else
l_final.push(ll)
end
end
new.push(l_final.join(' '))
end
# Líneas en blanco
else
new.push(l)
end
end
end
archivo = File.new(Dir.pwd + '/md/' + tool[0] + '.md', 'w:UTF-8')
archivo.puts new
archivo.close
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_md\n @md ||= [\n \"[🔙 🏡](#{project_readme_path})\",\n '',\n \"# #{title} (#{year})\",\n '',\n \"By the #{adjective} [#{author}](#{homepage})\",\n '',\n '## Links:',\n '',\n \"- [Purchase #{title}](#{purchase})\",\n '',\n '## Chapter Notes:',\n ... | [
"0.5654948",
"0.5615741",
"0.5470057",
"0.541697",
"0.5363079",
"0.53075135",
"0.53068924",
"0.52131814",
"0.52057517",
"0.51363",
"0.51253265",
"0.51243556",
"0.50982094",
"0.50778276",
"0.50778276",
"0.5072326",
"0.50687176",
"0.5067654",
"0.5010212",
"0.49945396",
"0.49335... | 0.61998576 | 0 |
Crea los HTML a partir de los MD | def create_html path
html_name = "#{File.basename(path, '.md')}.html"
if html_name !~ /^index/
html_name = 'md/' + html_name
end
puts "Ejecutando «pc-pandog -i #{path} -o #{html_name}»…"
system("pc-pandog -i #{path} -o #{html_name}")
html = get_html(html_name)
new_html = []
write = true
html.each do |l|
if l =~ /<head>/
write = false
if html_name !~ /^index/
new_html.push($head.join("\n"))
else
new_html.push($head.join("\n").gsub('<link type="text/css" rel="stylesheet" href="../css/styles.css">', '<link type="text/css" rel="stylesheet" href="css/styles.css">').gsub('<script type="text/javascript" src="../js/piwik.js"></script>', '<script type="text/javascript" src="js/piwik.js"></script>'))
end
elsif l =~ /<\/head>/
write = true
elsif l =~ /<style>/
if html_name !~ /^index/
new_html.push($header.join("\n"))
else
new_html.push($header.join("\n").gsub('../index.html', '').gsub(/"(\S+?\.html)"/, 'html/' + '\1'))
end
elsif l =~ /<\/body>/
new_html.push($footer.join("\n"))
new_html.push(l)
else
if write == true
new_html.push(l)
end
end
end
new_html = beautifier_html(new_html)
# Se actualiza la información
archivo = File.new(html_name, 'w:UTF-8')
archivo.puts new_html
archivo.close
# Si no es el index, lo mueve a la carpeta «html»
if html_name !~ /^index/
FileUtils.mv(html_name, 'html')
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate(options = {})\n embed_outline(options[:selflink]) if options[:outline]\n\n #if options[:dirmap]\n # md_dir = Pathname.new(@md_file).dirname.expand_path\n # embed_sidebar( Madowu::DirectoryMapper.dirmap(md_dir) )\n #end\n\n if options[:sidebar]\n #lines = File.open( options[:si... | [
"0.7052148",
"0.6775882",
"0.64302987",
"0.63986224",
"0.6344221",
"0.6278271",
"0.62523043",
"0.6219281",
"0.6187609",
"0.6187192",
"0.6144861",
"0.61413157",
"0.61411023",
"0.6118311",
"0.60868794",
"0.6044552",
"0.6028312",
"0.60194486",
"0.6008795",
"0.599306",
"0.5992095... | 0.67557853 | 2 |
Need variable in view to know if caching is enabled. Used to save javascript into cached page so that certain dynamic things are handled by clientside javascript since Rails is skipped when page caching is on TODO: better way? | def set_page_caching_status
if perform_caching && caching_allowed
@page_caching_active = true
else
@page_caching_active = false
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cacheable?\n true\n end",
"def cache?\n false\n end",
"def cache?\n caching && true\n end",
"def cache_on?; end",
"def cache_on?; end",
"def cacheable?\n @cacheable\n end",
"def allow_page_to_be_cached?\n return !(agent_logged_in? or current_user.is_admin?)\n end",
... | [
"0.7261158",
"0.72413623",
"0.7237386",
"0.7150613",
"0.7150613",
"0.7056725",
"0.704111",
"0.70056087",
"0.6990013",
"0.6985611",
"0.6858229",
"0.6832103",
"0.67350006",
"0.6732197",
"0.6723559",
"0.66722894",
"0.66353464",
"0.6632723",
"0.66268206",
"0.66029155",
"0.6601035... | 0.6897646 | 10 |
Get locale code from request subdomain (like | def extract_locale_from_subdomain
unless request.subdomains.empty?
parsed_locale = request.subdomains.first
else # Assume no tld if no subdomains (assume something like "es.localhost")
parsed_locale = request.domain.split('.')[0]
end
if parsed_locale
if I18n.available_locales.include?(parsed_locale.intern)
parsed_locale.intern
else
nil
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def extract_locale_from_subdomain\n parsed_locale = request.subdomains.first\n \n end",
"def get_locale_from_subdomain\n locale = @rh.match( /(.+)\\.demowatch\\.[a-z]{2,3}$/i)[1]\n return locale if ( I18N_ALL_LANGUAGES.include?( locale))\n return nil\n end",
"def extract_locale_from_subd... | [
"0.8537563",
"0.8402093",
"0.8291987",
"0.8176371",
"0.8157528",
"0.8143707",
"0.81155235",
"0.7962062",
"0.7789393",
"0.7786918",
"0.77175075",
"0.77090496",
"0.77090496",
"0.7708932",
"0.77087075",
"0.76737785",
"0.76634765",
"0.76173943",
"0.75250655",
"0.74508166",
"0.719... | 0.8096817 | 7 |
"cache_page" alias method which effectivly forces the domain name to be prepended to the page cache path. Note that the "caches_page" method called on actions within a controller is affected by this as well | def cache_page_with_domain(content = nil, options = nil)
return unless perform_caching && caching_allowed
path = "/#{request.host}"
path << case options
when Hash
url_for(options.merge(:only_path => true,
:skip_relative_url_root => true, :format => params[:format]))
when String
options
else
if request.path.empty? || request.path == '/'
'/index'
else
request.path
end
end
cache_page_without_domain(content, path)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def page_cache(page)\n if page\n \"/page-#{page}\"\n else\n \"\"\n end\n end",
"def cache_page(content = nil, options = nil)\n return unless perform_caching && caching_allowed\n\n path = case options\n when Hash\n url_for(options.merge(:only_path => true, :sk... | [
"0.7399514",
"0.6926317",
"0.68699867",
"0.67377055",
"0.6641414",
"0.66082925",
"0.65276724",
"0.6514265",
"0.6491977",
"0.6366616",
"0.61459774",
"0.6093058",
"0.6084344",
"0.5999851",
"0.59539056",
"0.5940506",
"0.5912845",
"0.5832463",
"0.58030003",
"0.5802468",
"0.579204... | 0.7539716 | 0 |
Appending = at the end of a method name, allows to implement a "setter". A setter is a method that is assignable. Example: p.tag_names = "stuff,yo" The code in the example above would call the method we wrote below where the value on the righthand side of the = would become the argument to the method. This is similar to implementing an `attr_writer`. | def tag_names=(rhs)
self.tags = rhs.strip.split(/\s*,\s*/).map do |tag_name|
Tag.find_or_initialize_by(name: tag_name)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setter_method\n :\"#{self[:name]}=\"\n end",
"def setter_method\n :\"#{self[:name]}=\"\n end",
"def attribute_setter(attribute_name)\n \"set#{attribute_name.to_s.camelcase(:upper)}\"\n end",
"def setter( name ) (name.to_s + '=').to_sym end",
"def create_setter(name, ... | [
"0.75186193",
"0.739029",
"0.7325416",
"0.73035663",
"0.7255241",
"0.71206915",
"0.70761937",
"0.7072722",
"0.70363855",
"0.69919664",
"0.69786155",
"0.6961414",
"0.6865732",
"0.68431723",
"0.6816614",
"0.68067795",
"0.67480546",
"0.67087877",
"0.66799504",
"0.6654127",
"0.66... | 0.0 | -1 |
If doesn't have a current appointment, was already given a dose, allow them to all changes they'd like to Otherwise check if patient can schedule (checking the conditions) | def can_update_profile?
!@patient.appointments.current || # if there's no appointment, allow
@patient.doses.count.positive? || # if there's already a dose, allow
@patient.can_schedule? # if it's the user 1st dose and there's an appointment, check if they can still schedule
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def doctor_double_booked #We check this against all of the doctors appointments \n this_start = self.start_time #Instance methods that are called on a particular doctor's appointment \n this_end = self.end_time \n conflict = doctor.appointments.any? do |appointment| \n #Look through all of the doctors... | [
"0.7215266",
"0.68634623",
"0.65881354",
"0.6581343",
"0.6581343",
"0.6477333",
"0.64772683",
"0.6449904",
"0.64198446",
"0.639106",
"0.6371733",
"0.6347831",
"0.63122517",
"0.62951106",
"0.6294801",
"0.6292406",
"0.62743455",
"0.6224108",
"0.6198988",
"0.61689717",
"0.616555... | 0.7544121 | 0 |
returns the list of media types available for this resource to be deserialized from | def media_types
Restfulie::MediaType.default_types + MediaType.medias_for(self)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def media_types\n return @media_types\n end",
"def media_type_representations\n custom_representations + Restfulie::MediaType.default_representations.dup\n end",
"def media_types=(value)\n @media_types = value\n end",
"def available_content_types\n ... | [
"0.81824464",
"0.7180635",
"0.69721913",
"0.6924355",
"0.6907955",
"0.6860248",
"0.68008566",
"0.6589313",
"0.6581141",
"0.654005",
"0.65085536",
"0.6504488",
"0.6468978",
"0.64427537",
"0.6439476",
"0.6425805",
"0.6425805",
"0.64250743",
"0.6379401",
"0.63503253",
"0.6342117... | 0.83236927 | 0 |
returns a list of media types that this resource can be serialized to | def media_type_representations
custom_representations + Restfulie::MediaType.default_representations.dup
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def media_types\n Restfulie::MediaType.default_types + MediaType.medias_for(self)\n end",
"def media_types\n return @media_types\n end",
"def media_types=(value)\n @media_types = value\n end",
"def mime_types\n safe_const_get(:MIME_TYPES) || []... | [
"0.82937324",
"0.8271455",
"0.70387685",
"0.68488765",
"0.68208706",
"0.67429936",
"0.6669111",
"0.6653061",
"0.6613159",
"0.6607771",
"0.6602479",
"0.6579117",
"0.65451986",
"0.65254384",
"0.65254384",
"0.64999086",
"0.64642197",
"0.6437094",
"0.6436229",
"0.64359564",
"0.64... | 0.7419579 | 2 |
this model's custom representations. those representations were added through media_type definitions | def custom_representations
@custom_representations ||= []
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def media_type_representations\n custom_representations + Restfulie::MediaType.default_representations.dup\n end",
"def get_field_deserializers()\n return super.merge({\n \"content\" => lambda {|n| @content = n.get_object_value(lambda {|pn| Base64url.create_from_discrimi... | [
"0.81593436",
"0.6921461",
"0.69098604",
"0.69098604",
"0.6891906",
"0.67368144",
"0.67271805",
"0.6653601",
"0.6595624",
"0.6521771",
"0.64532167",
"0.6426585",
"0.64094967",
"0.63534504",
"0.63534504",
"0.63127947",
"0.62968343",
"0.62768227",
"0.6275648",
"0.61798555",
"0.... | 0.73142064 | 1 |
TODO rename to type for mt | def media_type(name)
name = normalize(name)
raise Restfulie::UnsupportedContentType.new("unsupported content type '#{name}'") if media_types[name].nil?
media_types[name].type
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def nonregular_type; end",
"def type() end",
"def type(type); end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; en... | [
"0.69271946",
"0.67360437",
"0.669799",
"0.66325885",
"0.66325885",
"0.66325885",
"0.66325885",
"0.66325885",
"0.66325885",
"0.66325885",
"0.66325885",
"0.66325885",
"0.66325885",
"0.66325885",
"0.66325885",
"0.66325885",
"0.66325885",
"0.66325885",
"0.66325885",
"0.66325885",
... | 0.0 | -1 |
TODO move to MediaTypeControl.custom_media_types | def medias_for(type)
found = {}
type.media_type_representations.each do |key|
found[key] = media_types[key]
end
found.values
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def media_type; end",
"def media_type; end",
"def media_types\n Restfulie::MediaType.default_types + MediaType.medias_for(self)\n end",
"def set_media_type\n media_types = self.class.head(@endpoint).headers['accept']\n Occi::Log.debug(\"Available media types: #{media_types}\")\n ... | [
"0.7655368",
"0.7655368",
"0.74709594",
"0.74512",
"0.72484314",
"0.70772976",
"0.70754254",
"0.6980882",
"0.6922792",
"0.68780917",
"0.67966944",
"0.67823637",
"0.6747582",
"0.6747582",
"0.6747582",
"0.6747582",
"0.6690993",
"0.6676044",
"0.6638374",
"0.6605297",
"0.65976506... | 0.0 | -1 |
Structure and Content assertions Fully assert db structure after full migration | def see_full_schema
assert_schema do |s|
s.table "activities" do |t|
t.column "id", :integer
t.column "actor_id", :integer
t.column "action", :string
t.column "created_at", :datetime
t.column "updated_at", :datetime
t.column "project_id", :integer
t.column "affected_id", :integer
t.column "affected_type", :string
end
s.table "comments" do |t|
t.column "id", :integer
t.column "content", :text
t.column "created_at", :datetime
t.column "updated_at", :datetime
t.column "commenter_id", :integer
t.column "commentable_id", :integer
t.column "commentable_type", :string
end
s.table "groups" do |t|
t.column "id", :integer
t.column "name", :string
t.column "created_at", :datetime
t.column "updated_at", :datetime
end
s.table "groups_privileges" do |t|
t.column "id", :integer
t.column "group_id", :integer
t.column "privilege_id", :integer
t.column "created_at", :datetime
t.column "updated_at", :datetime
end
s.table "invitations" do |t|
t.column "id", :integer
t.column "inviter_id", :integer
t.column "recipient", :string
t.column "project_id", :integer
t.column "code", :string
t.column "message", :string
t.column "created_at", :datetime
t.column "updated_at", :datetime
end
s.table "buckets" do |t|
t.column "id", :integer
t.column "start_date", :date
t.column "end_date", :date
t.column "project_id", :integer
t.column "name", :string
t.column "description", :text
t.column "budget", :integer
t.column "type", :string
t.column "created_at", :datetime
t.column "updated_at", :datetime
end
s.table "logged_exceptions" do |t|
t.column "id", :integer
t.column "exception_class", :string
t.column "controller_name", :string
t.column "action_name", :string
t.column "message", :text
t.column "backtrace", :text
t.column "environment", :text
t.column "request", :text
t.column "created_at", :datetime
end
s.table "priorities" do |t|
t.column "id", :integer
t.column "name", :string
t.column "color", :string
t.column "position", :integer
t.column "created_at", :datetime
t.column "updated_at", :datetime
end
s.table "privileges" do |t|
t.column "id", :integer
t.column "name", :string
t.column "created_at", :datetime
t.column "updated_at", :datetime
end
s.table "project_permissions" do |t|
t.column "id", :integer
t.column "project_id", :integer
t.column "accessor_id", :integer
t.column "accessor_type", :string
t.column "created_at", :datetime
t.column "updated_at", :datetime
end
s.table "projects" do |t|
t.column "id", :integer
t.column "name", :string
t.column "iteration_length", :string
t.column "created_at", :datetime
t.column "updated_at", :datetime
end
s.table "statuses" do |t|
t.column "id", :integer
t.column "name", :string
t.column "color", :string
t.column "created_at", :datetime
t.column "updated_at", :datetime
end
s.table "stories" do |t|
t.column "id", :integer
t.column "summary", :string
t.column "description", :text
t.column "points", :integer
t.column "position", :integer
t.column "bucket_id", :integer
t.column "project_id", :integer
t.column "responsible_party_id", :integer
t.column "responsible_party_type", :string
t.column "status_id", :integer
t.column "priority_id", :integer
t.column "created_at", :datetime
t.column "completed_at", :datetime
t.column "updated_at", :datetime
end
s.table "taggings" do |t|
t.column "id", :integer
t.column "tag_id", :integer
t.column "taggable_id", :integer
t.column "taggable_type", :string
end
s.table "tags" do |t|
t.column "id", :integer
t.column "name", :string
end
s.table "time_entries" do |t|
t.column "id", :integer
t.column "hours", :decimal
t.column "comment", :string
t.column "date", :date
t.column "project_id", :integer
t.column "timeable_id", :integer
t.column "timeable_type", :string
t.column "created_at", :datetime
t.column "updated_at", :datetime
end
s.table :user_reminders do |t|
t.column :id, :integer
t.column :user_id, :integer
t.column :token, :string
t.column :expires_at, :datetime
end
s.table "users" do |t|
t.column "id", :integer
t.column "password_hash", :string
t.column "first_name", :string
t.column "last_name", :string
t.column "email_address", :string
t.column "group_id", :integer
t.column "active", :boolean
t.column "created_at", :datetime
t.column "updated_at", :datetime
t.column "salt", :string
t.column "remember_me_token", :string
t.column "remember_me_token_expires_at", :datetime
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def assert_content_model\n add_relationship(:has_model, \"info:fedora/hull-cModel:examPaper\")\n add_relationship(:has_model, \"info:fedora/hydra-cModel:compoundContent\")\n add_relationship(:has_model, \"info:fedora/hydra-cModel:commonMetadata\")\n end",
"def assert_content_model\n add_relationship... | [
"0.65234965",
"0.64974135",
"0.629223",
"0.6128113",
"0.6087569",
"0.601674",
"0.5858129",
"0.584822",
"0.58205354",
"0.58180493",
"0.57787365",
"0.57128763",
"0.5705589",
"0.5703517",
"0.57033545",
"0.5679172",
"0.5679172",
"0.5662987",
"0.5647087",
"0.5620317",
"0.56112397"... | 0.67981 | 0 |
Make sure data you expect your migrations to load are in there: | def see_default_data
assert Status.find_by_name("defined")
assert Status.find_by_name("in progress")
assert Status.find_by_name("complete")
assert Status.find_by_name("rejected")
assert Status.find_by_name("blocked")
assert Privilege.find_by_name("user")
assert Group.find_by_name("Developer")
assert Group.find_by_name("Customer")
assert Group.find_by_name("Customer Admin")
assert Group.find_by_name("Admin")
assert User.find_by_email_address("admin@example.com")
priority_high = Priority.find_by_name("High")
assert_equal "red", priority_high.color
assert_nil priority_high.position
priority_medium = Priority.find_by_name("Medium")
assert_equal "yellow", priority_medium.color
assert_nil priority_medium.position
priority_low = Priority.find_by_name("Low")
assert_equal "green", priority_low.color
assert_nil priority_low.position
assert_equal 1, Project.count(:conditions=>"name='Example Project'")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def migrations\n @migrations ||= {}\n end",
"def run_before_migrate_setup\n Chef::Log.info 'No before migrate setup defined.'\n end",
"def pre_migrate_database\n old_schema_version = get_schema_version\n new_schema_version = File.read(File.join(source_directory,'db','schema_version'))... | [
"0.63979584",
"0.62646455",
"0.62423986",
"0.6127222",
"0.6124297",
"0.6114264",
"0.608918",
"0.6070095",
"0.5991623",
"0.5958342",
"0.5910198",
"0.5905127",
"0.5893607",
"0.5893607",
"0.58831155",
"0.58831155",
"0.587724",
"0.587724",
"0.587724",
"0.5854941",
"0.5854941",
... | 0.0 | -1 |
Create a new user using the strong params. | def create
user = User.new(user_params)
if user.save
render json: {status: 200, msg: 'User was created.'}
else
render json: {
errors: user.errors.full_messages
}, status: :unprocessable_entity
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n\t\t\t\t@user = User.create!(create_user_params)\n\t\t\tend",
"def create\n @user = User.create( user_params )\nend",
"def create\n user = User.new(user_params)\n\n respond_to do |format|\n if user.save\n render json: user, status: :ok\n else\n format.json... | [
"0.83630896",
"0.8006522",
"0.7971518",
"0.7955403",
"0.7955403",
"0.79353535",
"0.79224926",
"0.78954744",
"0.78931195",
"0.7859713",
"0.78448313",
"0.78405404",
"0.7831208",
"0.78295004",
"0.78252316",
"0.78247285",
"0.78056234",
"0.77924716",
"0.77924716",
"0.7787343",
"0.... | 0.78221184 | 16 |
If authorized, return the loggedin user information based on different conditionals: user has profile image and previous geolocation coordinates. | def auth
@user = current_user
render json: @user
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def user_info\n auth_hash['user_info']\n end",
"def user_info\n @user_info ||= raw_info.nil? ? {} : raw_info['query']['results'][\"profile\"]\n end",
"def get_user_info()\n return_map = nil\n if session[:google_unique] != nil && user_credentials.access_token != nil\n re... | [
"0.68944895",
"0.6792831",
"0.67667216",
"0.648974",
"0.64877",
"0.6427148",
"0.64122933",
"0.64032084",
"0.6386255",
"0.6381735",
"0.636093",
"0.63083535",
"0.6277406",
"0.6266921",
"0.6258286",
"0.62361145",
"0.6229214",
"0.6229214",
"0.61505204",
"0.61495095",
"0.61393285"... | 0.0 | -1 |
A simple structure to use as the content for the nodes. Create this structure for the tests ++ | ROOT | +++ | | ++ ++ CHILD1 | | ++ | | ++ ++ CHILD2 | | ++ | | ++ ++ ++ CHILD3 ++ CHILD4 | ++ ++ Some basic setup to create the nodes for the test tree. | def setup
@root = Tree::TreeNode.new("ROOT", "Root Node")
@child1 = Tree::TreeNode.new("Child1", "Child Node 1")
@child2 = Tree::TreeNode.new("Child2", "Child Node 2")
@child3 = Tree::TreeNode.new("Child3", "Child Node 3")
@child4 = Tree::TreeNode.new("Child4", "Grand Child 1")
@child5 = Tree::TreeNode.new("Child5", "Child Node 4")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setup_test_tree\n @root << @child1\n @root << @child2\n @root << @child3 << @child4\n end",
"def test_root_setup\n assert_not_nil(@root , \"Root cannot be nil\")\n assert_nil(@root.parent , \"Parent of root node should be nil\")\n assert_not_nil(@root.name , \"Na... | [
"0.74892026",
"0.69768673",
"0.6536382",
"0.6532576",
"0.64579844",
"0.6425516",
"0.6425516",
"0.6415502",
"0.63244176",
"0.63095903",
"0.6268332",
"0.6256298",
"0.6199389",
"0.6199389",
"0.6164461",
"0.61095846",
"0.6101349",
"0.60315055",
"0.60315055",
"0.6016662",
"0.60127... | 0.76316243 | 0 |
Create the actual test tree. | def setup_test_tree
@root << @child1
@root << @child2
@root << @child3 << @child4
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_csharp_test_node\n @stack = []\n @stack.push(@root)\n @test_case_stack = []\n csharp_regex = Regexp.union([/^namespace/, /^public/, /^\\[TestFixture\\]/, /^\\[Test\\]/, /^\\[TestCase/])\n original_file_string = File.read(@file_name)\n lines = original_file_string.split(\"\\n\")\n li... | [
"0.74843407",
"0.74843407",
"0.7450539",
"0.7450539",
"0.6970523",
"0.67445105",
"0.67445105",
"0.673366",
"0.6630002",
"0.6599638",
"0.65196586",
"0.6453513",
"0.6437223",
"0.63942397",
"0.63213277",
"0.6312018",
"0.6307778",
"0.6289122",
"0.62722176",
"0.62221694",
"0.62182... | 0.7683765 | 0 |
Tear down the entire structure | def teardown
@root = nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def shut_down\n end",
"def tear_down; end",
"def tear_down!\n return unless created?\n\n detach! if attached?\n destroy!\n end",
"def tear_down\n self.instance.tear_down unless self.instance.nil?\n self.instance = nil\n end",
"def shutdown\n @container = nil\n en... | [
"0.7634876",
"0.7227283",
"0.6968223",
"0.6789342",
"0.65773785",
"0.6557551",
"0.65418464",
"0.6479788",
"0.6439508",
"0.6439508",
"0.64275897",
"0.6426667",
"0.64209545",
"0.6413427",
"0.6411198",
"0.6399946",
"0.6380038",
"0.6380038",
"0.6380038",
"0.6380038",
"0.6379036",... | 0.6168886 | 56 |
Test for presence of the VERSION constant | def test_has_version_number
assert_not_nil(Tree::VERSION)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has_version?; end",
"def valid_version?\n !statement[\"ver\"].empty?\n end",
"def version?(version)\n !!version_named(version.to_sym)\n end",
"def has_version?\n return (@name != @metaname)\n end",
"def test_it_has_a_version_number\n refute_nil ::ApMessageIo::VERSION\n e... | [
"0.73936874",
"0.72455746",
"0.7100905",
"0.7093173",
"0.705587",
"0.6731751",
"0.6705082",
"0.66778785",
"0.66554826",
"0.6620286",
"0.6610916",
"0.65979165",
"0.65637785",
"0.6563375",
"0.65327036",
"0.64933884",
"0.64911956",
"0.64896244",
"0.6430234",
"0.6413429",
"0.6397... | 0.6756435 | 5 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.