query stringlengths 7 6.41k | document stringlengths 12 28.8k | metadata dict | negatives listlengths 30 30 | negative_scores listlengths 30 30 | document_score stringlengths 5 10 | document_rank stringclasses 2
values |
|---|---|---|---|---|---|---|
Grep file for regex. Returns true if found, false otherwise. ==== Options +grep+:: Regular expression +path+:: Path to file ==== Example utils.egrep("^mail.\\", "/etc/syslog.conf") => true | def egrep(grep, path)
found = true
run_via %{egrep '#{grep}' #{path} || echo $?} do |channel, stream, data|
if data =~ /^(\d+)/
if $1.to_i > 0
logger.trace "Not found"
found = false
end
end
end
found
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def egrep(pattern)\n Dir['**/*'].\n find_all { |fn| FileTest.file?(fn) }.\n reject { |fn| File.basename(fn) =~ /^\\./ }.\n reject { |fn| fn =~ /^hosting\\// }.\n each do |fn|\n line_count = 0\n open(fn) do |f|\n while line = f.gets\n line_count += 1\n if line =~ patt... | [
"0.6894042",
"0.6479809",
"0.6439984",
"0.6224579",
"0.6024856",
"0.59779793",
"0.5928665",
"0.58295995",
"0.5786929",
"0.57851905",
"0.5760323",
"0.56986886",
"0.568912",
"0.5663096",
"0.56393987",
"0.55635476",
"0.55056506",
"0.5457294",
"0.53684425",
"0.5338383",
"0.515937... | 0.71789104 | 0 |
Append data to a file. Optionally check that it exists before adding. ==== Options +path+:: Path to file to append to +data+:: String data to append +check+:: If not nil, will check to see if egrep matches this regex and will not reappend +left_strip+:: If true (default), remove whitespace before lines +should_exist+::... | def append_to(path, data, check = nil, left_strip = true, should_exist = true)
# If checking and found expression then abort append
return if check and egrep(check, path)
# If should exist and doesn't then abort append
raise "Can't append to file. File should exist: #{path}" if should_exist and !exist?... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def append(path, data)\n append_all(path, [data])\n end",
"def append_to_file(path, *args, &block)\n options = args.last.is_a?(Hash) ? args.pop : {}\n options.merge!(before: /\\z/)\n insert_into_file(path, *(args << options), &block)\n end",
"def append_to_file(path, *args, &block)\n ... | [
"0.56431776",
"0.56079525",
"0.554554",
"0.52561873",
"0.5220501",
"0.5192943",
"0.5103816",
"0.51016814",
"0.5072856",
"0.50637037",
"0.5056971",
"0.49248248",
"0.4906291",
"0.4896212",
"0.48764458",
"0.483463",
"0.4824028",
"0.47990674",
"0.47815636",
"0.4780256",
"0.476874... | 0.8033233 | 0 |
Updates the project's config/stations.yml with the latest data | def update_station_list
log('This script overwrites your local copy of config/stations.yml with the latest data from nationalrail.co.uk and '\
'railwaycodes.org.uk')
log('Press [ENTER] to continue or [Ctrl+c] to quit')
gets
# Fetch data from the web
stations = fetch_stations
locations = fetch_locations... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_stations\n\n State.all.each do |s|\n fetch_stations(s)\n end\n\n end",
"def reload_config\n @config = YAML.load_file('config/mse_router_info.yml')\n end",
"def update\n\t\t\tpath = File.join(Config[:lists_directory], @name.downcase.gsub(/ /, '_') +'.yml')\n\t\t\tFile.open(path, '... | [
"0.60823065",
"0.6051133",
"0.5908637",
"0.586426",
"0.5831725",
"0.5792561",
"0.5762153",
"0.56759757",
"0.5665405",
"0.5652359",
"0.56044865",
"0.5520707",
"0.54454124",
"0.5413685",
"0.5391292",
"0.5369639",
"0.5365964",
"0.5365936",
"0.5360263",
"0.53476155",
"0.5311275",... | 0.7758356 | 0 |
Gets the current list of stations from the national rail website's station codes csv file | def fetch_stations
log(' - Fetching station list...', false)
results = {}
response = get_response('https://www.nationalrail.co.uk/static/documents/content/station_codes.csv')
CSV.new(response, headers: true).each do |row|
results[row['CRS Code']] ||= {}
results[row['CRS Code']][:name] = row['Station Nam... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def stations\n stations = []\n CSV.foreach(LOCAL_DATA, :col_sep =>':') do |row|\n callsign, origin, destination, client = row[0].to_s, row[11].to_s, row[13].to_s, row[3].to_s\n for cs in @callsign\n stations << row if callsign[0...cs.length] == cs # && client == \"ATC\") unless @ro... | [
"0.74480873",
"0.69337845",
"0.6796676",
"0.6729238",
"0.67204165",
"0.67038745",
"0.65798676",
"0.64318585",
"0.6427037",
"0.63155234",
"0.6304272",
"0.6202676",
"0.615029",
"0.6125535",
"0.6075097",
"0.6074721",
"0.6069872",
"0.58857256",
"0.5827722",
"0.58218485",
"0.58048... | 0.74827105 | 0 |
Scrapes location data for stations from the railwaycodes.org.uk website | def fetch_locations
log(' - Fetching location data (takes ~25s)...', false)
results = {}
('a'..'z').to_a.each do |letter|
response = get_response("http://www.railwaycodes.org.uk/stations/station#{letter}.shtm")
Nokogiri::HTML(response).xpath('//table/tr').each do |row|
cols = row.xpath('./td').map(&... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fetch_stations\n log(' - Fetching station list...', false)\n results = {}\n response = get_response('https://www.nationalrail.co.uk/static/documents/content/station_codes.csv')\n CSV.new(response, headers: true).each do |row|\n results[row['CRS Code']] ||= {}\n results[row['CRS Code']][:name] = row['... | [
"0.7019532",
"0.69721776",
"0.6619542",
"0.6406317",
"0.63550836",
"0.6291045",
"0.62364876",
"0.62285507",
"0.6129416",
"0.61175174",
"0.6115178",
"0.6086678",
"0.6082721",
"0.60765636",
"0.6068141",
"0.6032643",
"0.600311",
"0.598479",
"0.5962095",
"0.5952711",
"0.5949453",... | 0.7884202 | 0 |
Write the stations.yml to disk | def write_yaml(stations)
log(' - Writing YAML...', false)
File.open(YAML_PATH.to_s, 'w') { |file| file.write(stations.to_yaml) }
log('DONE')
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save\n File.open(file_name, 'w') { |f| f.write config.to_yaml }\n end",
"def save\n open @config_path, 'w' do |io|\n io.write({'files' => @files.collect(&:to_hash)}.to_yaml)\n end\n end",
"def save\n if !Dir.exists? @config_directory\n FileUtils.mkdir_p @config_directory\n ... | [
"0.71399915",
"0.71231467",
"0.6833124",
"0.67595303",
"0.6741323",
"0.67238617",
"0.6718801",
"0.6692962",
"0.66747785",
"0.65909904",
"0.6585045",
"0.65687835",
"0.65416473",
"0.64866114",
"0.6483459",
"0.64626855",
"0.6445233",
"0.6388901",
"0.6383342",
"0.6336774",
"0.630... | 0.78969675 | 0 |
Get tags for an S3 bucket | def get_bucket_tagging(bucket_name)
unless bucket_name
raise ArgumentError.new('bucket_name is required')
end
request({
:expects => 200,
:headers => {},
:bucket_name => bucket_name,
:idempotent => true,
:method ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def objects\n bucket_obj = Aws::S3::Bucket.new(name: bucket, client: s3_client)\n bucket_obj.objects( prefix: prefix)\n end",
"def list_s3_buckets()\n\n s3 = connect_to_s3()\n response = s3.list_buckets\n\n response.buckets.each do |bucket|\n puts \"#{bucket.creation_date} #{bucket.name}\"\n end\n\... | [
"0.74992913",
"0.7484136",
"0.7456256",
"0.7429592",
"0.73793685",
"0.7342721",
"0.7334377",
"0.7285206",
"0.7279083",
"0.7237538",
"0.72151196",
"0.71678525",
"0.7045226",
"0.697166",
"0.6909694",
"0.6908615",
"0.6889206",
"0.6872525",
"0.6863063",
"0.68106854",
"0.6795594",... | 0.76849705 | 0 |
DB Here we can actually make an efficient query with both the domain and locale at the same time | def query_request
db = PhoneDNS::DB.new
return db.find(@domain, @locale)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def website_locales\n WebsiteLocale.where(locale: self.code)\n end",
"def query_context_values_for_locale(locale)\n case locale\n when \"US\"\n US_QUERY_CONTEXT_VALUES \n else\n US_QUERY_CONTEXT_VALUES\n end\n end",
"def with_locales(*locales)\r\n locales = local... | [
"0.63859767",
"0.60368353",
"0.60186625",
"0.589506",
"0.5874854",
"0.57998365",
"0.5765718",
"0.57459337",
"0.56993604",
"0.56993604",
"0.5674319",
"0.56723654",
"0.5597257",
"0.55960816",
"0.5562583",
"0.5527979",
"0.55152065",
"0.5492132",
"0.5490525",
"0.5482087",
"0.5441... | 0.6122164 | 1 |
Return boolean indicating if spec has a %check section | def has_check?
@metadata.has_key?(:has_check) && @metadata[:has_check]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has_specs?\n FileList[spec_pattern].any?\n end",
"def ok?\n @specs.all? { |spec|\n\tspec.dependencies.all? { |dep|\n\t @specs.find { |s| s.satisfies_requirement?(dep) }\n\t}\n }\n end",
"def section_classes_all_there?\n section_classes_to_check.all?(&:all_there?)\n end",
... | [
"0.61356276",
"0.60764885",
"0.60271496",
"0.6018409",
"0.6007447",
"0.59538865",
"0.5920807",
"0.59132826",
"0.59010524",
"0.58751607",
"0.5865623",
"0.5865623",
"0.5865623",
"0.5855523",
"0.5855523",
"0.58552295",
"0.5845337",
"0.5809722",
"0.5753064",
"0.57481515",
"0.5694... | 0.7375026 | 1 |
Return all the Requires for the specified gem | def requirements_for_gem(gem_name)
@metadata[:requires].nil? ? [] :
@metadata[:requires].select { |r| r.gem_name == gem_name }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gem_requirements\n @metadata[:requires].nil? ? [] :\n @metadata[:requires].select { |r| r.gem? }\n end",
"def extra_gem_requirements(gem)\n gem_reqs = gem.deps.collect { |d| requirements_for_gem(d.name) }.flatten\n gem_requirements - gem_reqs\n end",
"def e... | [
"0.80040956",
"0.7675247",
"0.7675247",
"0.76449025",
"0.75560653",
"0.75386906",
"0.75038576",
"0.7461104",
"0.7340646",
"0.73155725",
"0.73155725",
"0.7263488",
"0.7241406",
"0.7241406",
"0.7186854",
"0.7183271",
"0.7172267",
"0.69621104",
"0.68408877",
"0.68351054",
"0.682... | 0.83392173 | 0 |
Return all the BuildRequires for the specified gem | def build_requirements_for_gem(gem_name)
@metadata[:build_requires].nil? ? [] :
@metadata[:build_requires].select { |r| r.gem_name == gem_name }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gem_build_requirements\n @metadata[:build_requires].nil? ? [] :\n @metadata[:build_requires].select { |r| r.gem? }\n end",
"def extra_gem_build_requirements(gem)\n gem_reqs = gem.deps.collect { |d| requirements_for_gem(d.name) }.flatten\n gem_build_requirements - ge... | [
"0.7956537",
"0.7649496",
"0.7649496",
"0.7571615",
"0.73775095",
"0.727578",
"0.7154658",
"0.71063125",
"0.71063125",
"0.70693284",
"0.6963554",
"0.69446707",
"0.66307956",
"0.6495567",
"0.64904886",
"0.6465807",
"0.6449178",
"0.6381928",
"0.6377861",
"0.62782127",
"0.625711... | 0.82276887 | 0 |
Return bool indicating if this spec specifies all the requirements in the specified gem dependency | def has_all_requirements_for?(gem_dep)
reqs = self.requirements_for_gem gem_dep.name
# create a spec requirement dependency for each expanded subrequirement,
# verify we can find a match for that
gem_dep.requirement.to_s.split(',').all? { |greq|
Gem2Rpm::Helpers.expan... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ok?\n @specs.all? do |spec|\n spec.runtime_dependencies.all? do |dep|\n @specs.find { |s| s.satisfies_requirement? dep }\n end\n end\n end",
"def ok?\n @specs.all? { |spec|\n\tspec.dependencies.all? { |dep|\n\t @specs.find { |s| s.satisfies_requirement?(dep) }\n\t}\n }\n ... | [
"0.7509248",
"0.7437589",
"0.7234251",
"0.71505815",
"0.7129035",
"0.71249455",
"0.7114287",
"0.70675755",
"0.7060609",
"0.7025498",
"0.7008242",
"0.70036715",
"0.6982246",
"0.69707406",
"0.69687974",
"0.68911797",
"0.686583",
"0.6853289",
"0.6765665",
"0.6764929",
"0.6736777... | 0.8134189 | 0 |
Return list of gem dev dependencies for which we have no corresponding requirements | def missing_dev_deps_for(gem)
# Same note as in #missing_deps_for above
gem.dev_deps.select { |dep| build_requirements_for_gem(dep.name).empty? }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dependent_gems(check_dev=true)\n out = []\n Gem::Specification.each do |spec|\n deps = check_dev ? spec.dependencies : spec.runtime_dependencies\n deps.each do |dep|\n if self.satisfies_requirement?(dep)\n sats = []\n find_all_satisfiers(dep) do |sat|\n sats ... | [
"0.79816246",
"0.78688914",
"0.78491455",
"0.7745773",
"0.7578879",
"0.73604",
"0.72868645",
"0.72283745",
"0.7206016",
"0.7172765",
"0.70921886",
"0.7020585",
"0.69456106",
"0.69325477",
"0.68998003",
"0.68712646",
"0.6856421",
"0.6848235",
"0.6844712",
"0.67837274",
"0.6782... | 0.8326318 | 0 |
Return list of dependencies of upstream gem which have not been included | def excluded_deps
missing_deps_for(upstream_gem)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def excluded_dev_deps\n missing_dev_deps_for(upstream_gem)\n end",
"def unused_dependencies_list\n imports = all_unique_imports.map { |import| import.split.last }\n dependency_list - imports\n end",
"def missing_deps_for(gem)\n # Comparison by name here assuming if it is in exis... | [
"0.7707541",
"0.7599393",
"0.70768607",
"0.70239794",
"0.6968882",
"0.69328785",
"0.69328785",
"0.69328785",
"0.69294703",
"0.68707",
"0.6860442",
"0.6828495",
"0.681813",
"0.6806439",
"0.67656416",
"0.67144835",
"0.66742456",
"0.66441727",
"0.66212255",
"0.6603637",
"0.65846... | 0.8343008 | 0 |
Return boolean indicating if the specified gem is on excluded list | def excludes_dep?(gem_name)
excluded_deps.any? { |d| d.name == gem_name }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def excludes_dev_dep?(gem_name)\n excluded_dev_deps.any? { |d| d.name == gem_name }\n end",
"def excluded?(site, name)\r\n @config['exclude'].include? name\r\n end",
"def exclude?(production)\n !include?(production)\n end",
"def excluded_in_manifest?(package_name)\n pac... | [
"0.7045999",
"0.6904349",
"0.6822704",
"0.667933",
"0.6662879",
"0.6545669",
"0.6529984",
"0.64999",
"0.64977205",
"0.6469012",
"0.642258",
"0.64008135",
"0.6369375",
"0.6261711",
"0.6261711",
"0.6188836",
"0.6170802",
"0.61677164",
"0.6158755",
"0.6079697",
"0.60613596",
"... | 0.76878726 | 0 |
Return list of dev dependencies of upstream gem which have not been included | def excluded_dev_deps
missing_dev_deps_for(upstream_gem)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def excluded_deps\n missing_deps_for(upstream_gem)\n end",
"def missing_dev_deps_for(gem)\n # Same note as in #missing_deps_for above\n gem.dev_deps.select { |dep| build_requirements_for_gem(dep.name).empty? }\n end",
"def dependent_gems(check_dev=true)\n out = []\n ... | [
"0.802019",
"0.7529109",
"0.7401518",
"0.7325643",
"0.7075162",
"0.70070356",
"0.68912154",
"0.6847869",
"0.68293285",
"0.6712348",
"0.66706264",
"0.66649264",
"0.6619542",
"0.6598121",
"0.6588399",
"0.6576242",
"0.6576242",
"0.6576242",
"0.6548561",
"0.64404315",
"0.6420742"... | 0.84077597 | 0 |
Return boolean indicating if the specified gem is on excluded dev dep list | def excludes_dev_dep?(gem_name)
excluded_dev_deps.any? { |d| d.name == gem_name }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def excludes_dep?(gem_name)\n excluded_deps.any? { |d| d.name == gem_name }\n end",
"def excluded_dev_deps\n missing_dev_deps_for(upstream_gem)\n end",
"def missing_dev_deps_for(gem)\n # Same note as in #missing_deps_for above\n gem.dev_deps.select { |dep| buil... | [
"0.8301603",
"0.74998707",
"0.7026222",
"0.6679245",
"0.66597533",
"0.6637068",
"0.6505546",
"0.64745206",
"0.6448305",
"0.64128023",
"0.63961947",
"0.63957137",
"0.639031",
"0.63515246",
"0.6348039",
"0.6298262",
"0.62937367",
"0.62780184",
"0.6241609",
"0.6200809",
"0.61631... | 0.8841211 | 0 |
Return all gem Requires | def gem_requirements
@metadata[:requires].nil? ? [] :
@metadata[:requires].select { |r| r.gem? }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def requires\n require_items.collect(&:package)\n end",
"def required_gem_list\n Mack::Utils::GemManager.instance.required_gem_list\n end",
"def get_requirements\n result = `rake gems 2>&1`\n parse_required(result) + parse_missing(result) + parse_deps(result)\n end",
"def requires\n @requ... | [
"0.81167537",
"0.80577075",
"0.7955232",
"0.7891053",
"0.7870169",
"0.7870169",
"0.7779613",
"0.748002",
"0.7350287",
"0.7332056",
"0.72157",
"0.72157",
"0.7191012",
"0.7166352",
"0.71560174",
"0.7121761",
"0.7060577",
"0.7032609",
"0.7013483",
"0.69855285",
"0.6954951",
"0... | 0.81617785 | 0 |
Return all gem BuildRequires | def gem_build_requirements
@metadata[:build_requires].nil? ? [] :
@metadata[:build_requires].select { |r| r.gem? }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gem_requirements\n @metadata[:requires].nil? ? [] :\n @metadata[:requires].select { |r| r.gem? }\n end",
"def build_requirements_for_gem(gem_name)\n @metadata[:build_requires].nil? ? [] :\n @metadata[:build_requires].select { |r| r.gem_name == gem_name }\n en... | [
"0.7813414",
"0.7778188",
"0.7700233",
"0.7663836",
"0.7616184",
"0.7616184",
"0.7580091",
"0.727626",
"0.7268273",
"0.71795696",
"0.71329087",
"0.69731927",
"0.69731927",
"0.69633394",
"0.69085085",
"0.6857759",
"0.6857759",
"0.68087906",
"0.6614653",
"0.65820885",
"0.656456... | 0.8434125 | 0 |
Return all non gem Requires | def non_gem_requirements
@metadata[:requires].nil? ? [] :
@metadata[:requires].select { |r| !r.gem? }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def all_requires\n []\n end",
"def all_requires\n []\n end",
"def non_gem_build_requirements\n @metadata[:build_requires].nil? ? [] :\n @metadata[:build_requires].select { |r| !r.gem? }\n end",
"def gem_requirements\n @metadata[:requires].nil? ? [] :\n ... | [
"0.79319245",
"0.79319245",
"0.78823376",
"0.7619221",
"0.753511",
"0.73787093",
"0.7367521",
"0.7321788",
"0.7284858",
"0.71854585",
"0.7130878",
"0.7130878",
"0.71234214",
"0.7118899",
"0.70503414",
"0.7048146",
"0.6934306",
"0.68147767",
"0.68147767",
"0.67969376",
"0.6771... | 0.85777974 | 0 |
Return all non gem BuildRequires | def non_gem_build_requirements
@metadata[:build_requires].nil? ? [] :
@metadata[:build_requires].select { |r| !r.gem? }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gem_build_requirements\n @metadata[:build_requires].nil? ? [] :\n @metadata[:build_requires].select { |r| r.gem? }\n end",
"def non_gem_requirements\n @metadata[:requires].nil? ? [] :\n @metadata[:requires].select { |r| !r.gem? }\n end",
"def extra_gem_buil... | [
"0.808794",
"0.7988304",
"0.7581043",
"0.7581043",
"0.7405697",
"0.74054605",
"0.72203654",
"0.71572477",
"0.7083293",
"0.70512027",
"0.70512027",
"0.69212645",
"0.6918513",
"0.6918513",
"0.68823165",
"0.676585",
"0.67218244",
"0.6675017",
"0.6646113",
"0.6634509",
"0.6624661... | 0.86879677 | 0 |
Update spec dependencies from new source | def update_deps_from(new_source)
@metadata[:requires] =
non_gem_requirements +
extra_gem_requirements(new_source) +
new_source.deps.select { |r| !excludes_dep?(r.name) }
.collect { |r| RPM::Requirement.from_gem_dep(r) }.flatten
@metadata[:bu... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update!\n puts \"Updating gems...\"\n Bundler::CLI.new.update\n @new_spec_set = Bundler.definition.specs\n compute_changes\n end",
"def update_files_from(new_source)\n to_add = new_source.file_paths\n @metadata[:files] ||= {}\n @metadata[:files].each { |pkg,s... | [
"0.68556887",
"0.67198884",
"0.6539907",
"0.646059",
"0.6451124",
"0.6295985",
"0.6194238",
"0.6152833",
"0.6103472",
"0.60737646",
"0.6068849",
"0.605756",
"0.60083675",
"0.60083675",
"0.5986238",
"0.5981282",
"0.5963764",
"0.592853",
"0.59255964",
"0.5885336",
"0.5826517",
... | 0.69750834 | 0 |
Internal helper to update spec files from new source | def update_files_from(new_source)
to_add = new_source.file_paths
@metadata[:files] ||= {}
@metadata[:files].each { |pkg,spec_files|
(new_source.file_paths & to_add).each { |gem_file|
# skip files already included in spec or in dir in spec
has_file = ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_specfiles(version)\n spec_files.each do |spec_file|\n spec = File.read(spec_file)\n spec.gsub!(/^(\\s*)Version:(\\s*).*$/, \"\\\\1Version:\\\\2#{version}\")\n File.write(spec_file, spec)\n end\nend",
"def cover_source_by source, specfile\n _source = File.expand_path( \"../../../#{source}\"... | [
"0.7405899",
"0.712922",
"0.68801665",
"0.6859357",
"0.6672085",
"0.62861097",
"0.61503696",
"0.61348736",
"0.6122977",
"0.6105787",
"0.60835826",
"0.60281646",
"0.6020156",
"0.6018791",
"0.59977007",
"0.5971116",
"0.5927346",
"0.587188",
"0.58634996",
"0.5855605",
"0.5823852... | 0.7195628 | 1 |
Internal helper to update spec metadata from new source | def update_metadata_from(new_source)
# update to new version
@metadata[:version] = new_source.version
@metadata[:release] = "1%{?dist}"
# add changelog entry
changelog_entry = <<EOS
* #{Time.now.strftime("%a %b %d %Y")} #{RPM::Spec.current_author} - #{@metadata[:versio... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_files_from(new_source)\n to_add = new_source.file_paths\n @metadata[:files] ||= {}\n @metadata[:files].each { |pkg,spec_files|\n (new_source.file_paths & to_add).each { |gem_file|\n # skip files already included in spec or in dir in spec\n ... | [
"0.6862861",
"0.6513075",
"0.6470899",
"0.6407146",
"0.6383383",
"0.63161415",
"0.62185985",
"0.6171623",
"0.6141208",
"0.6129807",
"0.61264807",
"0.5971806",
"0.59356827",
"0.59356827",
"0.59356827",
"0.59356827",
"0.59356827",
"0.59356827",
"0.59356827",
"0.59356827",
"0.59... | 0.67376864 | 1 |
Compare this spec to a sepecified upstream gem source and return result. upstream_source should be an instance of Polisher::Gem, Polisher::Gemfile, or other class defining a 'deps' accessor that returns an array of Gem::Requirement dependencies Result will be a hash containing the shared dependencies as well as those t... | def compare(upstream_source)
same = {}
diff = {}
upstream_source.deps.each do |d|
spec_reqs = self.requirements_for_gem(d.name)
spec_reqs_specifier = spec_reqs.empty? ? nil :
spec_reqs.collect { |req| req.specifier }
if spec_reqs.nil?
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def target_is_upstream_source\n return if source&.upstream == target\n\n errors.add :source, I18n.t('openwebslides.validations.pull_request.target_is_upstream_source')\n end",
"def patched\n vendored.collect do |dep|\n # TODO: right now just handling git based alternate sources,\n # sho... | [
"0.58725435",
"0.58384055",
"0.55911046",
"0.55055064",
"0.54918385",
"0.52337176",
"0.512998",
"0.5120674",
"0.511616",
"0.511616",
"0.5093228",
"0.4934556",
"0.49239683",
"0.49144685",
"0.4904337",
"0.4900853",
"0.4879244",
"0.48754996",
"0.4873863",
"0.4869386",
"0.4831280... | 0.85392034 | 0 |
Rotates the image based on the EXIF Orientation | def fix_exif_rotation
manipulate! do |img|
img.auto_orient
img = yield(img) if block_given?
img
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fix_exif_rotation\n manipulate! do |img|\n img.tap(&:auto_orient)\n end\n end",
"def fix_exif_rotation\n return unless self.file.content_type.start_with? 'image'\n \n manipulate! do |img|\n img.tap(&:auto_orient)\n img = yield(img) if block_given?\n img\n end\n ... | [
"0.7754857",
"0.7740966",
"0.76978165",
"0.7362087",
"0.72326785",
"0.71300775",
"0.698376",
"0.66120464",
"0.64729464",
"0.6399693",
"0.63220435",
"0.6226592",
"0.6119372",
"0.6107671",
"0.6032383",
"0.6016191",
"0.5884359",
"0.5884359",
"0.5884359",
"0.5880022",
"0.5870346"... | 0.7767189 | 0 |
Are there any prerequisites with a later time than the given time stamp? | def out_of_date?(stamp)
@prerequisites.any? { |n| application[n].timestamp > stamp}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def out_of_date?(stamp)\n @prerequisites.any? do |n| \n prereq_time = application[n, @scope].timestamp\n return false if prereq_time == Rake::EARLY\n\n prereq_time > stamp\n end\n end",
"def out_of_date?(stamp)\n return true if stamp.is_a? Rake::EarlyTime\n ... | [
"0.7551927",
"0.72763467",
"0.7262603",
"0.7040142",
"0.67206854",
"0.66420317",
"0.630077",
"0.62771356",
"0.62771356",
"0.6129603",
"0.612923",
"0.6127672",
"0.61170053",
"0.6093891",
"0.6086675",
"0.6057503",
"0.60325825",
"0.6030525",
"0.6021573",
"0.6000135",
"0.5984032"... | 0.7517836 | 1 |
module Rake Declare a file task. Example: file "config.cfg" => ["config.template"] do open("config.cfg", "w") do |outfile| open("config.template") do |infile| while line = infile.gets outfile.puts line end end end end | def file(*args, &block)
Rake::FileTask.define_task(*args, &block)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def file(*args, &block)\n Rake::FileTask.define_task(*args, &block)\n end",
"def file!(*args, &block)\n task = Rake::FileTask.define_task(*args, &block)\n CLEAN.include(task.name)\n task\nend",
"def generate_file(task, &block)\n GenerateFileTask.define_task(task, &block)\n end",
"def f... | [
"0.7712839",
"0.7079847",
"0.69677216",
"0.69415593",
"0.6836613",
"0.6782593",
"0.67193663",
"0.6513875",
"0.64049387",
"0.636113",
"0.6322388",
"0.6308451",
"0.6272988",
"0.6239362",
"0.6113482",
"0.61101",
"0.6076254",
"0.6076254",
"0.6057535",
"0.60332125",
"0.5974595",
... | 0.7863632 | 0 |
Declare a file creation task. (Mainly used for the directory command). | def file_create(args, &block)
Rake::FileCreationTask.define_task(args, &block)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def file_create(args, &block)\n Rake::FileCreationTask.define_task(args, &block)\n end",
"def generate_file(task, &block)\n GenerateFileTask.define_task(task, &block)\n end",
"def create(file, task, mode)\n\n file = File.open(file, mode)\n #file.write(task)\n file.puts(task)\n file.clos... | [
"0.83126724",
"0.71743494",
"0.71329445",
"0.7125328",
"0.7111279",
"0.6687138",
"0.66524696",
"0.6561874",
"0.65514976",
"0.6524207",
"0.6450879",
"0.63945144",
"0.6392764",
"0.6392764",
"0.6377696",
"0.6372352",
"0.63668007",
"0.63172567",
"0.62784296",
"0.6257799",
"0.6244... | 0.8202174 | 1 |
Declare a set of files tasks to create the given directories on demand. Example: directory "testdata/doc" | def directory(dir)
Rake.each_dir_parent(dir) do |d|
file_create d do |t|
mkdir_p t.name if ! File.exist?(t.name)
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_rake_files(base_dir)\n\n one_task_fn = File.join(base_dir, 'one_task.rake')\n make_tasks_in_file(['one_task'], one_task_fn) if ok_to_create?(one_task_fn)\n\n another_task_fn = File.join(base_dir, 'another_task.rake')\n make_tasks_in_file(['another_task'], another_task_fn) if ok_to_create?(an... | [
"0.69951504",
"0.6594979",
"0.6563617",
"0.6465529",
"0.6422045",
"0.64202523",
"0.63622504",
"0.6352174",
"0.6352174",
"0.6309467",
"0.6243856",
"0.6242378",
"0.621869",
"0.6204845",
"0.6178213",
"0.61644566",
"0.6148434",
"0.61343867",
"0.6124763",
"0.6124167",
"0.612095",
... | 0.71917117 | 0 |
Faster implementation of count. Instead of parsing the whole file with Ruby, shell out to `wc l` to get the line count less the header row. | def count
`wc -l < #{filepath}`.to_i - 1
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def line_count(file_list)\n file_list.empty? ?\n nil :\n %x{wc -l #{file_list.join(' ')} | awk 'END {print $1}'}.to_i\n end",
"def total_count(file)\n file_obj = File.new(file,'r')\n file_obj.readlines.size\n end",
"def file_line_count(file_name)\n line_count = `wc... | [
"0.7533258",
"0.7422093",
"0.7296095",
"0.72538716",
"0.72446257",
"0.7200559",
"0.715027",
"0.70878357",
"0.7029153",
"0.702676",
"0.7013147",
"0.6944964",
"0.689677",
"0.6885198",
"0.6885198",
"0.68745446",
"0.68666714",
"0.68237793",
"0.67826444",
"0.67822605",
"0.6730159"... | 0.7558668 | 0 |
appends a new node of data: value | def append(value)
new_node = Node.new(value)
node = @node
while node.next
node = node.next
end
node.next = new_node
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def append( value )\n last.next = Node.new value\n end",
"def push(value)\n # IMPLEMENT ME!\n @data = Node.new(value, @data)\n end",
"def push(value)\n @data = LinkedListNode.new value, @data\n end",
"def append(key, value)\n node_for(key).append(key, value)\n end",
"def ap... | [
"0.72796077",
"0.70016223",
"0.69808525",
"0.6980771",
"0.6939678",
"0.69363123",
"0.6931024",
"0.6929061",
"0.692087",
"0.6872095",
"0.6865514",
"0.686101",
"0.68561614",
"0.6847596",
"0.6835342",
"0.6832084",
"0.6832084",
"0.6831559",
"0.68297756",
"0.6828386",
"0.6828386",... | 0.70865726 | 1 |
Render 401 page and stop the work | def access_denied!
render partial: 'errors/401', status: 401 && return
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def not_authorized\r\n render :file => 'public/401.html', :status => 401, :layout => false\r\n end",
"def render_unauthorized(message)\n head :unauthorized\n end",
"def unauthorized\n render \"errors/401\", :status => 401\n\tend",
"def access_denied\n render status: 401, text: \"nice try\"\n e... | [
"0.8083516",
"0.77960855",
"0.77643305",
"0.76811355",
"0.7547679",
"0.7507944",
"0.7496331",
"0.74397546",
"0.7425587",
"0.7425587",
"0.739917",
"0.7357528",
"0.735653",
"0.7344297",
"0.73370343",
"0.7333744",
"0.7332294",
"0.7284989",
"0.727261",
"0.7265804",
"0.7260171",
... | 0.8073811 | 1 |
Localize a fieldName if obj is present | def t_field(field_label = nil, obj = '')
return '' if field_label.blank?
case obj
when Class
I18n.t(field_label, scope: "activerecord.attributes.#{obj.class}", default: field_label).try(:capitalize)
when String
I18n.t(field_label, scope: "activerecord.attributes.#{obj}", default: field_labe... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def localize(field)\n if klass.fields[field.to_s].try(:localized?)\n field = \"#{field}.#{::I18n.locale}\".to_sym\n end\n field\n end",
"def translation_for(field)\n object.class.human_attribute_name(field)\n end",
"def localize(object, **options); end",
"de... | [
"0.64157623",
"0.6244754",
"0.6101673",
"0.6101673",
"0.5886811",
"0.58794194",
"0.58645064",
"0.5823621",
"0.57293004",
"0.5687891",
"0.56806165",
"0.5643081",
"0.5531259",
"0.55112916",
"0.54588056",
"0.5441425",
"0.54325783",
"0.54284745",
"0.54141426",
"0.5383049",
"0.535... | 0.6632558 | 0 |
POST /staff_workers POST /staff_workers.json | def create
@staff_worker = StaffWorker.new(staff_worker_params)
respond_to do |format|
if @staff_worker.save
format.html { redirect_to @staff_worker, notice: 'Данные сохранены' }
format.json { render :show, status: :created, location: @staff_worker }
else
format.html { rende... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @worker = Worker.new(worker_params)\n\n respond_to do |format|\n if @worker.save\n format.html { redirect_to tenant_workers_path, notice: 'Worker was successfully created.' }\n format.json { render :show, status: :created, location: @worker }\n else\n format.html {... | [
"0.6947815",
"0.67183036",
"0.6668612",
"0.6668612",
"0.6668612",
"0.6618786",
"0.6567185",
"0.6517283",
"0.63768846",
"0.62740093",
"0.62140656",
"0.6193138",
"0.6146582",
"0.6123193",
"0.6116307",
"0.60847956",
"0.60847956",
"0.60847956",
"0.60847956",
"0.60847956",
"0.6082... | 0.73074555 | 0 |
PATCH/PUT /staff_workers/1 PATCH/PUT /staff_workers/1.json | def update
respond_to do |format|
if @staff_worker.update(staff_worker_params)
format.html { redirect_to @staff_worker, notice: 'Данные сохранены' }
format.json { render :show, status: :ok, location: @staff_worker }
else
format.html { render :edit }
format.json { render j... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @worker = Worker.find(params[:id])\n\n respond_to do |format|\n if @worker.update_attributes(params[:worker])\n format.html { redirect_to @worker, notice: 'Worker was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: ... | [
"0.68921345",
"0.6831025",
"0.682848",
"0.6788736",
"0.67613775",
"0.67549795",
"0.66988367",
"0.6628822",
"0.6628822",
"0.6628822",
"0.6628822",
"0.6616776",
"0.65908563",
"0.65558666",
"0.65186435",
"0.65142864",
"0.65039796",
"0.645864",
"0.6324981",
"0.6320896",
"0.627036... | 0.7254535 | 0 |
DELETE /staff_workers/1 DELETE /staff_workers/1.json | def destroy
@staff_worker.destroy
respond_to do |format|
format.html { redirect_to staff_workers_url, notice: 'Staff worker was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @worker.destroy\n respond_to do |format|\n format.html { redirect_to workers_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @worker.destroy\n respond_to do |format|\n format.html { redirect_to workers_url }\n format.json { head :no_content ... | [
"0.7149248",
"0.7149248",
"0.71377444",
"0.70102173",
"0.6905355",
"0.68210465",
"0.68210465",
"0.6817284",
"0.6784668",
"0.67674124",
"0.6751715",
"0.6751715",
"0.6751715",
"0.6738858",
"0.66608405",
"0.66542506",
"0.66542506",
"0.66542506",
"0.66542506",
"0.66542506",
"0.66... | 0.73188215 | 0 |
POST /positives POST /positives.json | def create
@positive = Positive.new(positive_params)
respond_to do |format|
if @positive.save
format.html { redirect_to @positive, notice: 'Positive was successfully created.' }
format.json { render :show, status: :created, location: @positive }
else
format.html { render :ne... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n points = params[:solution][:points_earned]\n unless current_user.posse.current_solution?\n solution = current_user.posse.solutions.create(solution_params)\n current_user.posse.add_points(points.to_i)\n end\n render json: solution\n end",
"def create\n @goal = @todo.goal... | [
"0.61339045",
"0.5962907",
"0.5962644",
"0.5764218",
"0.5667303",
"0.5657126",
"0.5639613",
"0.5634564",
"0.56339425",
"0.5619743",
"0.5619299",
"0.56070226",
"0.5596418",
"0.5580475",
"0.55664915",
"0.5560917",
"0.55590403",
"0.55496585",
"0.55360365",
"0.5525691",
"0.552526... | 0.62360406 | 0 |
DELETE /positives/1 DELETE /positives/1.json | def destroy
@positive.destroy
respond_to do |format|
format.html { redirect_to positives_url, notice: 'Positive was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete\n client.delete(\"/#{id}\")\n end",
"def delete(path)\n RestClient.delete request_base+path\n end",
"def delete path\n make_request(path, \"delete\", {})\n end",
"def delete\n render json: Item.delete(params[\"id\"])\n end",
"def delete\n render json: Post.delete(p... | [
"0.6958753",
"0.6827413",
"0.6826436",
"0.6816422",
"0.68047947",
"0.68044895",
"0.6790449",
"0.67768383",
"0.67351115",
"0.6724736",
"0.6724736",
"0.6724736",
"0.6724736",
"0.6708416",
"0.669331",
"0.66727996",
"0.6644749",
"0.66371465",
"0.66164446",
"0.66142935",
"0.661013... | 0.6855466 | 1 |
Given a number, find the level that includes it Ex: Number 7 returns level 1 Level 1: Min Value: 2 Max Value: 9 | def find_level
level = 0
max_value = max_number_of_a_level(level)
while max_value < input
level += 1
max_value = max_number_of_a_level(level)
end
level
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def min_number_of_a_level(level)\n max_number_of_a_level(level - 1) + 1\n end",
"def by_level(range, max_at:)\n level >= max_at ? range.last :\n range.first + (((range.size - 1)/max_at.to_f)*level).to_i\n end",
"def get_level(key)\n case key\n when \"L\", \"l\" then 0 # Level L\... | [
"0.7395198",
"0.71062714",
"0.6725487",
"0.6684878",
"0.66810113",
"0.6663994",
"0.66560423",
"0.6545247",
"0.6436386",
"0.6398142",
"0.63862497",
"0.6305735",
"0.63021517",
"0.62912244",
"0.6275081",
"0.62496877",
"0.62187016",
"0.6150314",
"0.6143422",
"0.61397547",
"0.6106... | 0.78657734 | 0 |
update product cache stock | def update_product_cache_stock
self.product.update_cache_stock if self.product.present?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_product_cache_stock\n\t\t\tself.state_check_details.each do |scd|\n scd.update_product_cache_stock\n end\n\t\tend",
"def update_stock\n \tproduct = FileOperations.search_by_name(self)\n \tproduct = product[0].split(';')\n \tself.id = product[0]\n \tself.name = product[1]\n \tself.pric... | [
"0.83098114",
"0.764758",
"0.72880715",
"0.71947026",
"0.71198666",
"0.7048175",
"0.6981914",
"0.69696885",
"0.69134766",
"0.69046766",
"0.6853029",
"0.684212",
"0.6833739",
"0.68245345",
"0.6713819",
"0.6664722",
"0.66323066",
"0.6593814",
"0.6556672",
"0.65207905",
"0.65190... | 0.8790568 | 0 |
def remove_all_children self.to_be_removed = true self.save self.tags.each do |i| i.to_be_removed = true i.save end end | def retrieve_all_children
self.to_be_removed = false
self.save
self.tags.each do |i|
i.to_be_removed = false
i.save
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_children_when_delete\n if self.to_be_removed == true\n self.tag_types.each do |m|\n if m.to_be_removed == false\n m.to_be_removed = true\n m.save\n end\n end\n end\n end",
"def remove\n each { |x| x.parent.children.delete(x) }\n end",
"def rem... | [
"0.82328236",
"0.7009207",
"0.70056564",
"0.6906464",
"0.67890275",
"0.6683836",
"0.6651831",
"0.659164",
"0.6552822",
"0.6549208",
"0.64957726",
"0.6489836",
"0.6428154",
"0.64065266",
"0.6389913",
"0.63605005",
"0.63448095",
"0.6317193",
"0.63033366",
"0.6294256",
"0.628414... | 0.91514367 | 0 |
GET /moresmalltrials/1 GET /moresmalltrials/1.json | def show
@moresmalltrial = Moresmalltrial.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @moresmalltrial }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @moresmalltrial = Moresmalltrial.new\n max_id = Moresmalltrial.maximum(:id)\n max_id = 1 if max_id.nil?\n next_id = max_id + 1\n @moresmallmaps = Moresmallmap.where('start_trial_id <= ?', next_id).where('end_trial_id >= ?', next_id)\n\n respond_to do |format|\n format.html # new.ht... | [
"0.716695",
"0.68076646",
"0.66779023",
"0.6663466",
"0.6631849",
"0.65963566",
"0.65652233",
"0.6442629",
"0.63992923",
"0.63868815",
"0.61134785",
"0.6101197",
"0.605216",
"0.6040546",
"0.6021467",
"0.6004728",
"0.5950679",
"0.5935729",
"0.593069",
"0.5921621",
"0.5916741",... | 0.7763802 | 0 |
POST /moresmalltrials POST /moresmalltrials.json | def create
@moresmalltrial = Moresmalltrial.new(params[:moresmalltrial])
respond_to do |format|
if @moresmalltrial.save
format.html { redirect_to @moresmalltrial, notice: 'Moresmalltrial was successfully created.' }
format.json { render json: @moresmalltrial, status: :created, location: @... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @moresmalltrial = Moresmalltrial.new\n max_id = Moresmalltrial.maximum(:id)\n max_id = 1 if max_id.nil?\n next_id = max_id + 1\n @moresmallmaps = Moresmallmap.where('start_trial_id <= ?', next_id).where('end_trial_id >= ?', next_id)\n\n respond_to do |format|\n format.html # new.ht... | [
"0.6589716",
"0.6442382",
"0.643282",
"0.64206207",
"0.63953453",
"0.6309926",
"0.6182574",
"0.60563034",
"0.6003",
"0.5991035",
"0.5976615",
"0.5943033",
"0.5859429",
"0.5814396",
"0.5762834",
"0.5760689",
"0.5749525",
"0.57071453",
"0.56892467",
"0.5636526",
"0.55937165",
... | 0.76854515 | 0 |
PUT /moresmalltrials/1 PUT /moresmalltrials/1.json | def update
@moresmalltrial = Moresmalltrial.find(params[:id])
respond_to do |format|
if @moresmalltrial.update_attributes(params[:moresmalltrial])
format.html { redirect_to @moresmalltrial, notice: 'Moresmalltrial was successfully updated.' }
format.json { head :no_content }
else
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @moresmalltrial = Moresmalltrial.new(params[:moresmalltrial])\n\n respond_to do |format|\n if @moresmalltrial.save\n format.html { redirect_to @moresmalltrial, notice: 'Moresmalltrial was successfully created.' }\n format.json { render json: @moresmalltrial, status: :created, ... | [
"0.66722953",
"0.6413313",
"0.64067096",
"0.63649887",
"0.62892205",
"0.6211682",
"0.61859596",
"0.60644203",
"0.6031823",
"0.6013322",
"0.60030776",
"0.6000524",
"0.5951241",
"0.5942575",
"0.59059215",
"0.580721",
"0.58007234",
"0.5777142",
"0.5735435",
"0.5735435",
"0.57354... | 0.75724864 | 0 |
DELETE /moresmalltrials/1 DELETE /moresmalltrials/1.json | def destroy
@moresmalltrial = Moresmalltrial.find(params[:id])
@moresmalltrial.destroy
respond_to do |format|
format.html { redirect_to moresmalltrials_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @mosttinytrial = Mosttinytrial.find(params[:id])\n @mosttinytrial.destroy\n\n respond_to do |format|\n format.html { redirect_to mosttinytrials_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @trial.destroy\n respond_to do |format|\n format.ht... | [
"0.7178326",
"0.7156257",
"0.7130006",
"0.70846915",
"0.68739235",
"0.68045586",
"0.6801004",
"0.6801004",
"0.6749269",
"0.67466396",
"0.671006",
"0.66621035",
"0.6648582",
"0.6600067",
"0.6546773",
"0.6546406",
"0.6543899",
"0.6535698",
"0.65352637",
"0.6507185",
"0.65015906... | 0.79821914 | 0 |
GET /moresmalltrials/select_mobunits GET /moresmalltrials/1/select_mobunits | def select_mobunits
@def_unit_data = Moresmallmobunit.where('cur_map_id = ?', params[:map_id]).where('tgt_map_id = ?', params[:map_id]).where('is_prepared = "t"').collect{|m| [m.name, m.id]}
@atk_unit_data = Moresmallmobunit.where('cur_map_id != ?', params[:map_id]).where('tgt_map_id = ?', params[:map_id]).wher... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def select_mob_and_unit\n @mobs = Moresmallmob.find_all_by_moresmalluser_id(params[:user_id]).collect{|m| [m.name, m.id]}\n @selected_mob = Moresmallmobsquad.find(params[:id]).mob_ids unless Moresmallmobsquad.find_by_moresmalluser_id(params[:user_id]).nil?\n @units = Moresmallmobunit.find_all_by_moresmall... | [
"0.7767612",
"0.67045027",
"0.6238261",
"0.6097225",
"0.60156",
"0.5676386",
"0.5630235",
"0.55827385",
"0.5499818",
"0.549147",
"0.54616195",
"0.54372257",
"0.536816",
"0.53639144",
"0.5348078",
"0.5348078",
"0.5346673",
"0.5336801",
"0.5318684",
"0.5304373",
"0.5261055",
... | 0.767579 | 1 |
This scripts checks the group membership of each user on the machine to to see if they are in the local admin group | def local_admins
list_of_users_tocheck = []
for x in Dir.entries("/Users")
if !x.start_with?(".")
list_of_users_tocheck.push(x)
end
end
localadmins = []
for x in list_of_users_tocheck
if `dsmemberutil checkmembership -U #{x} -G admin 2>/dev/null`.chomp == "user is a member of the group"
localadmins.pus... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def user_in_admin_group?\r\n cmd_exec(\"groups `whoami`\").split(/\\s+/).include?(SUDOER_GROUP)\r\n end",
"def admin_of?(group)\n memberships.exists?(group_id: group.id, admin: true)\n end",
"def is_admin?\n cmd_exec('groups | grep -wq admin && echo true').eql? 'true'\n end",
"def user_is_admin?\... | [
"0.7384816",
"0.7222062",
"0.7219268",
"0.70986426",
"0.70076305",
"0.69900006",
"0.6904335",
"0.68876874",
"0.68767476",
"0.6792933",
"0.67712164",
"0.67275745",
"0.66510236",
"0.664713",
"0.6566432",
"0.6557021",
"0.6555653",
"0.6534765",
"0.65182966",
"0.65170693",
"0.6408... | 0.7812426 | 0 |
returns the list of available page layouts | def list_page_layouts(layouts=[])
if layouts.empty?
layouts_path = Rails.root + "app/views/layouts"
if Dir.exists? layouts_path
Dir.foreach(layouts_path) do |file_name|
if file_name.include? '.html.haml'
layouts << File.basename(file_name,'.html.haml')
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def available_layouts\n layouts = Array.new\n extension_dirs.each do |ext|\n Dir.entries(\"#{RAILS_ROOT}/vendor/extensions/#{ext}/app/views/layouts\").only_files.collect{ |e| layouts << e.scan(/\\w+/).first } if File.exist?(\"#{RAILS_ROOT}/vendor/extensions/#{ext}/app/views/layouts\")\n end\n\n la... | [
"0.71930134",
"0.7095451",
"0.6915558",
"0.6800581",
"0.6614504",
"0.6593947",
"0.6593947",
"0.6562008",
"0.6546522",
"0.6284322",
"0.6284322",
"0.62566537",
"0.61939174",
"0.6190009",
"0.6176771",
"0.6161486",
"0.61513245",
"0.6150834",
"0.6150793",
"0.61333925",
"0.61264974... | 0.74132097 | 0 |
Compares two die values from AllowedDice, useable for +sort+ _if_ you use it with a block. i.e.: [:d6, :d10, :d8].sort do |d1, d2| compare_dice(d1, d2) end => [:d6, :d8, :d10] | def compare_dice(die1, die2)
idx1 = AllowedDiceOrder.index(die1)
idx2 = AllowedDiceOrder.index(die2)
# This handles values -not- in AllowedDice
idx1 = -1 if idx1.nil?
idx2 = -1 if idx2.nil?
return idx1 <=> idx2
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sort_dice(dice=[])\n return [] if not dice.is_a?(Array)\n return dice.sort {|d1, d2| compare_dice(d1, d2) }\n end",
"def score_dice(dice)\n score(dice_values(dice))\n end",
"def scorelist(roll)\n #return a hash that shows all the possible scores for these dice, sorted\n categories = ['yahtzee'... | [
"0.7356072",
"0.52847916",
"0.5277148",
"0.52326214",
"0.521826",
"0.5194588",
"0.51915973",
"0.5120726",
"0.5078136",
"0.50256276",
"0.499052",
"0.49794155",
"0.49698907",
"0.49549085",
"0.4946462",
"0.48435494",
"0.48420608",
"0.48389658",
"0.4830706",
"0.48208693",
"0.4819... | 0.77219313 | 0 |
Used to sort an array of dice. NOTE: Values not in AllowedDice end up at the front of the array. | def sort_dice(dice=[])
return [] if not dice.is_a?(Array)
return dice.sort {|d1, d2| compare_dice(d1, d2) }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compare_dice(die1, die2)\n idx1 = AllowedDiceOrder.index(die1)\n idx2 = AllowedDiceOrder.index(die2)\n\n # This handles values -not- in AllowedDice\n idx1 = -1 if idx1.nil?\n idx2 = -1 if idx2.nil?\n\n return idx1 <=> idx2\n end",
"def sort\n sorted = []\n\n # Iterate Over Array Leng... | [
"0.62039465",
"0.593092",
"0.5883547",
"0.5554808",
"0.5543136",
"0.5527346",
"0.55195254",
"0.55148035",
"0.5514463",
"0.5506463",
"0.54830354",
"0.545409",
"0.54452163",
"0.5436267",
"0.54168856",
"0.5409858",
"0.54074436",
"0.5392816",
"0.5392816",
"0.5383297",
"0.5368558"... | 0.76090306 | 0 |
GET /authors/1 GET /authors/1.xml | def show
@author = Author.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @author }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @author_repository = AuthorRepository.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @author_repository }\n end\n end",
"def show_authors\n tag = params['query']\n\n @article = Article.where('arxiv_id = ?', tag).first... | [
"0.68134266",
"0.6810114",
"0.6691908",
"0.65655464",
"0.65010214",
"0.65010214",
"0.65010214",
"0.65010214",
"0.649269",
"0.64491683",
"0.63969254",
"0.63959527",
"0.63925344",
"0.6384979",
"0.63823915",
"0.63539195",
"0.63266855",
"0.63105977",
"0.62936586",
"0.62145835",
"... | 0.70273745 | 0 |
Returns a scope for this object by its identifier | def get_scope_by_id(id)
id = id.to_s
scopes.find{|s| s.id == id }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def scope\n read_attr :scope, :to_sym\n end",
"def scope\n @scope\n end",
"def scope\n @scope\n end",
"def scope\n return @scope\n end",
"def scope\n return @scope\n end",
"def scope\n return @scope\n ... | [
"0.6986587",
"0.69153583",
"0.69153583",
"0.6775095",
"0.6775095",
"0.6775095",
"0.6775095",
"0.6775095",
"0.6775095",
"0.67681456",
"0.6573853",
"0.6573853",
"0.6544657",
"0.6534917",
"0.6349983",
"0.6338787",
"0.6282708",
"0.6270241",
"0.6237588",
"0.6230415",
"0.6224204",
... | 0.7012059 | 0 |
This function imports the JASON file and stores it into a hash table | def read_jason(file_path)
json_file = File.read(file_path)
data_hash = JSON.parse(json_file)
return data_hash
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def import\n Map.import(params[:file])\n end",
"def jload(fname)\n return j2h(loadfile(fname)) unless (res = @preload)\n verbose { 'Loading from Preloading' }\n @preload = nil\n res\n rescue InvalidData\n show_err\n Hashx.new\n end",
"def importFromFile(type, json_hash)\... | [
"0.5931426",
"0.5915452",
"0.58235085",
"0.57677865",
"0.57677865",
"0.57223034",
"0.56863755",
"0.5564768",
"0.5520754",
"0.54119825",
"0.5411914",
"0.53963196",
"0.53963196",
"0.53963196",
"0.53963196",
"0.5351877",
"0.52670175",
"0.5264046",
"0.52624375",
"0.5262029",
"0.5... | 0.5917401 | 1 |
Procedure to reduce the life of the player | def lose_life()
@life -= 1
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def lose_life\n @life -= 1\n end",
"def reduce_life\n if @lives > 0\n @lives -= 1\n end\n end",
"def lose_life\n @lives -= 1\n end",
"def lose_life\n @lives -= 1\n end",
"def lose_life\n @lives -= 1\n end",
"def lose_life\n @lives -= 1\n end",
"def lose_life(player)\n p... | [
"0.7591858",
"0.75863034",
"0.7402945",
"0.7402945",
"0.7402945",
"0.7402945",
"0.73868203",
"0.73052967",
"0.72994196",
"0.72235984",
"0.71686816",
"0.70550114",
"0.7036182",
"0.6953916",
"0.6926268",
"0.68712837",
"0.6800104",
"0.6708862",
"0.66474104",
"0.6575665",
"0.6532... | 0.77073747 | 0 |
Move the Space Ship to the right | def move_right
if @x + @vel_x < SCREEN_WIDTH - GAME_PRESET["player_move_right"]
@x += @vel_x
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def move_right\n\t\tmove([1,0])\n\tend",
"def moveRight\n if (@x + @size) < 510\n call Screen.setColor(false)\n call Screen.drawRectangle(@x, @y, @x + 1, @y + @size)\n let @x = @x + 2\n call Screen.setColor(true)\n call Screen.drawRectangle((@x + @size) - 1, @y, @x + @size, @y + @size... | [
"0.7360024",
"0.6865995",
"0.6825685",
"0.68051517",
"0.6802973",
"0.6776518",
"0.67689365",
"0.67439413",
"0.67415863",
"0.6721613",
"0.67200565",
"0.67092615",
"0.6702407",
"0.6700961",
"0.668674",
"0.65932626",
"0.6518812",
"0.6516152",
"0.64827204",
"0.6449603",
"0.644280... | 0.7194565 | 1 |
Returns the score of the Game | def get_score()
return @player.score()
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def score(game)\n if game.winner.nil?\n 0\n elsif game.winner == game.computer_player\n 1\n else\n -1\n end\n end",
"def score\n return @score\n end",
"def total_score\n sum = self.games.sum{|game|game.points}\n sum.to_i / self... | [
"0.8222461",
"0.7991709",
"0.79298407",
"0.7864132",
"0.7749373",
"0.7735888",
"0.77311563",
"0.76271975",
"0.7601157",
"0.75438535",
"0.751995",
"0.7510693",
"0.7493977",
"0.74937433",
"0.74776304",
"0.7466759",
"0.74565023",
"0.7433489",
"0.7420655",
"0.7398368",
"0.7388757... | 0.82753354 | 0 |
Returns the time of the Gameplay | def get_game_play_time()
return @game_play_time
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gametime\n \"#{self.gametime_maths/60} minutes\"\n end",
"def play_time\n sum = 0\n @tracks.each {|n| sum += n.total_time}\n return Time.at(sum/1000.0).strftime('%R:%S')\n end",
"def current_play_time\n time = $trainer.update_play_time\n hours = time / 3600\n minutes = (tim... | [
"0.7788315",
"0.7620484",
"0.74139893",
"0.7297721",
"0.7272682",
"0.7245473",
"0.7144879",
"0.7115967",
"0.71093667",
"0.7103704",
"0.70830953",
"0.70655817",
"0.7063819",
"0.7044452",
"0.6992768",
"0.6963224",
"0.69628036",
"0.6941735",
"0.6926208",
"0.6926208",
"0.6926208"... | 0.86502063 | 0 |
Removing the bullets which have moved pass the screen | def remove_unused_bullets()
# All the bullet objects are looped through
@bullets.dup.each { |bullet|
# Determines if a bullet is outside the screen
bullet.x > SCREEN_HEIGHT || bullet.x < 0
}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_bullets_of_screen args\n args.state.bullets = args.state.bullets.reject { |bullet| bullet.x > 1280 } # screen width is 1280\nend",
"def hit_by_bullet\n $p_bullets.delete_if do |b|\n if self.bounding_box_collision?(b)\n @meter.change_width(b.dmg)\n b.destroy\n during(100) ... | [
"0.7979599",
"0.7443645",
"0.7413888",
"0.7027271",
"0.6901875",
"0.67119205",
"0.66250396",
"0.6540389",
"0.64774126",
"0.63767713",
"0.6344758",
"0.6327287",
"0.6307901",
"0.6238692",
"0.62229186",
"0.6170551",
"0.6143313",
"0.6118596",
"0.6087417",
"0.60821563",
"0.6079519... | 0.8526866 | 0 |
Procedure for the aliens to fire bullets | def alien_fire_bullet()
# The aliens will fire bullets at random,
# The randomness is controlled by @alien_fire_rand
@aliens.each { |alien|
if rand(@alien_fire_rand) == 0
@bullets.push Bullet.new(alien.x, alien.y+ 40, 'evil')
end
}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fire \n\n # Could end up spawning a number of bullets, depending on the weapon\n bullets = []\n\n # For now, we'll just spawn a small green laser bolt!\n bullets << Laser.new( :laser_small_green, @x - 64, @y + 64, false )\n\n # And just hand back that collection of bullets\n ... | [
"0.78516734",
"0.736843",
"0.7359826",
"0.72630507",
"0.6600291",
"0.64875835",
"0.6484551",
"0.6447797",
"0.6353175",
"0.62963086",
"0.6233595",
"0.6233384",
"0.6197353",
"0.6188431",
"0.6146357",
"0.6132934",
"0.6097139",
"0.60820276",
"0.60766965",
"0.60751086",
"0.6005284... | 0.81691897 | 0 |
Procedure allows the player to fire bullets | def player_fire_bullet()
# This makes sure that bullets are fired after certain intervals
if Gosu.milliseconds > (@seconds_elapsed * COUNTER)
@seconds_elapsed = Gosu.milliseconds
@bullet_sound.bmp.play()
# Generating a bullet object
@bullets.push Bullet.new((@player.x+ 33), @player... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fire \n\n # Could end up spawning a number of bullets, depending on the weapon\n bullets = []\n\n # For now, we'll just spawn a small green laser bolt!\n bullets << Laser.new( :laser_small_green, @x - 64, @y + 64, false )\n\n # And just hand back that collection of bullets\n ... | [
"0.8171409",
"0.7454516",
"0.7333679",
"0.6954393",
"0.6928069",
"0.68463326",
"0.6845657",
"0.6830427",
"0.6787185",
"0.6743746",
"0.67229474",
"0.6687603",
"0.66550285",
"0.6642569",
"0.66419464",
"0.65892076",
"0.6567191",
"0.65120614",
"0.64631444",
"0.6458526",
"0.634888... | 0.83281463 | 0 |
Introcusing a new fleet of aliens in the game | def add_alien_fleet()
# Only generate new fleet of aliens if the current count of fleets is less than @fleet_limit
if rand(@random) == 0 and @fleet < @fleet_limit
@fleet +=1
position = rand(SCREEN_WIDTH/2)
@height -= GAME_PRESET["space_fleet"]
# Calling the procedure to generate al... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_aliens(position, height)\r\n # Looping until the number of Aliens in a fleet is reached\r\n for i in 0...@alien_count\r\n @aliens.push(Alien.new(i, position, height))\r\n @alien_sound.bmp.play\r\n end\r\n end",
"def eat\n inventory[:fish] -= @daily_appetite = 10\n\n if inve... | [
"0.6533823",
"0.5957225",
"0.5903877",
"0.5743698",
"0.5684314",
"0.56683844",
"0.56669354",
"0.56624097",
"0.5655215",
"0.5651407",
"0.5649855",
"0.5638109",
"0.5629744",
"0.55864453",
"0.55712163",
"0.5549444",
"0.55309695",
"0.55247116",
"0.5504321",
"0.54954064",
"0.54801... | 0.8170831 | 0 |
Procedure to generate aliens | def generate_aliens(position, height)
# Looping until the number of Aliens in a fleet is reached
for i in 0...@alien_count
@aliens.push(Alien.new(i, position, height))
@alien_sound.bmp.play
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def alias_generator(agent)\n\n# changes vowels into array and uses .reverse method to account \n# for edge cases\n\tvowels = \"aeiou\"\n\tnew_vowels = \"aeiou\".split('').reverse\n\n# changes consonants into array and uses .reverse method to account\n# for edge cases\n\tconsonants = \"bcdfghjklmnpqrstvwxyz\"\n\tne... | [
"0.67415905",
"0.67098373",
"0.6628147",
"0.65566397",
"0.6149982",
"0.61312085",
"0.6122917",
"0.6062984",
"0.6040096",
"0.59317064",
"0.5923171",
"0.5914449",
"0.5912977",
"0.58781105",
"0.5877148",
"0.581815",
"0.581815",
"0.5815876",
"0.5802117",
"0.5714952",
"0.5690303",... | 0.7044341 | 0 |
Procedure to add the visuals of explosion | def explode()
# drawing explosion scene
@explosion.bmp.draw(@explode_x, @explode_y, ZOrder::TOP)
# Playing the sound of an explosion
@explosion_sound.bmp.play
@count += 1
# Showing the visual for 20 update() counts
if @count == 20
@explode = false
@count = 0
e... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_explosion\n explosion = ParticleFactory.buildParticles(\"big\", 80).set! :emission_direction => Vector3f.new(0, 1, 0),\n :maximum_angle => FastMath::PI, :speed => 1, :minimum_life_time => 600, \n :start_size => 3, :end_size => 7, \n :start_color => ColorRGBA.new(1, 0.312, 0.121, 1), \n... | [
"0.668308",
"0.6274185",
"0.6200668",
"0.60736775",
"0.60326445",
"0.58870655",
"0.5825537",
"0.5759413",
"0.5726432",
"0.5726432",
"0.5723914",
"0.57106555",
"0.56994885",
"0.56796443",
"0.5664836",
"0.5664836",
"0.5603734",
"0.5565876",
"0.5558513",
"0.55577177",
"0.5539715... | 0.7037201 | 0 |
Procedure to place button on the screen | def place_button(x, y, message)
Gosu.draw_rect(x, y, 70, 45, Gosu::Color::GREEN, ZOrder::MIDDLE, mode=:default)
@button_font.draw_text(message, x+5, y+10, ZOrder::TOP, 1.0, 1.0, Gosu::Color::BLACK)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_the_button\n @theButton = UIButton.buttonWithType(UIButtonTypeRoundedRect)\n @theButton.setTitle('Refresh Weather!', forState:UIControlStateNormal)\n # @theButton.setTitleColor(BW.rgb_color(255, 255, 255), forState:UIControlStateNormal)\n @theButton.backgroundColor = BW.rgb_color(255, 255, 255)... | [
"0.6984616",
"0.69546276",
"0.68010515",
"0.65952176",
"0.6562371",
"0.654545",
"0.64923996",
"0.6409502",
"0.6349404",
"0.625855",
"0.6244189",
"0.6184829",
"0.61752456",
"0.6135543",
"0.61313856",
"0.6125126",
"0.61110425",
"0.6095421",
"0.6092659",
"0.60902447",
"0.6081898... | 0.7280034 | 0 |
When a user hovers over a button draw a border | def draw_border(x1, y)
if @function_UI.mouse_over_button(mouse_x, mouse_y)
draw_line(x1, y, Gosu::Color::BLUE, x1+60, y, Gosu::Color::BLUE, ZOrder::TOP, mode=:default)
draw_line(x1, y+35, Gosu::Color::BLUE, x1+60, y+35, Gosu::Color::BLUE, ZOrder::TOP, mode=:default)
draw_line(x1, y,G... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def draw_border(x1, y, mouse_x, mouse_y)\r\n if @function_UI.mouse_over_button(mouse_x, mouse_y)\r\n draw_line(x1, y, Gosu::Color::BLUE, x1+60, y, Gosu::Color::BLUE, ZOrder::TOP, mode=:default)\r\n draw_line(x1, y+35, Gosu::Color::BLUE, x1+60, y+35, Gosu::Color::BLUE, ZOrder::TOP, mode=:default)\r\n ... | [
"0.7456075",
"0.6786705",
"0.66233855",
"0.64731586",
"0.6234135",
"0.6140793",
"0.6121853",
"0.5982914",
"0.59605324",
"0.5950647",
"0.5891725",
"0.5875644",
"0.58139837",
"0.57779014",
"0.577331",
"0.573345",
"0.5727354",
"0.57118994",
"0.5699024",
"0.5689504",
"0.56780535"... | 0.7579696 | 0 |
When a user hovers over a button draw a border | def draw_border(x1, y, mouse_x, mouse_y)
if @function_UI.mouse_over_button(mouse_x, mouse_y)
draw_line(x1, y, Gosu::Color::BLUE, x1+60, y, Gosu::Color::BLUE, ZOrder::TOP, mode=:default)
draw_line(x1, y+35, Gosu::Color::BLUE, x1+60, y+35, Gosu::Color::BLUE, ZOrder::TOP, mode=:default)
draw_line... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def draw_border(x1, y)\r\n if @function_UI.mouse_over_button(mouse_x, mouse_y)\r\n draw_line(x1, y, Gosu::Color::BLUE, x1+60, y, Gosu::Color::BLUE, ZOrder::TOP, mode=:default)\r\n draw_line(x1, y+35, Gosu::Color::BLUE, x1+60, y+35, Gosu::Color::BLUE, ZOrder::TOP, mode=:default)\r\n draw... | [
"0.7579998",
"0.6786909",
"0.66236174",
"0.64722836",
"0.6234266",
"0.61411273",
"0.61221",
"0.598452",
"0.5958936",
"0.5951008",
"0.589083",
"0.5876123",
"0.58147824",
"0.5776819",
"0.5771609",
"0.57340175",
"0.57271856",
"0.5711821",
"0.5698336",
"0.56889844",
"0.5677698",
... | 0.7456396 | 1 |
GET /principal_establecs/1 GET /principal_establecs/1.json | def show
@principal_establec = PrincipalEstablec.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @principal_establec }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @principal_establec = PrincipalEstablec.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @principal_establec }\n end\n end",
"def get_principal(filter = nil, sort = nil)\n puts \"ACS: get_principal\"\n res = query(\"principal-list\", \n ... | [
"0.61725277",
"0.5739674",
"0.5683607",
"0.5643067",
"0.5642022",
"0.5622067",
"0.5571116",
"0.55657357",
"0.5544598",
"0.5529464",
"0.5519646",
"0.5506317",
"0.54886705",
"0.5472257",
"0.5470508",
"0.5462052",
"0.5455519",
"0.5450254",
"0.54342055",
"0.5429684",
"0.54123986"... | 0.72588146 | 0 |
GET /principal_establecs/new GET /principal_establecs/new.json | def new
@principal_establec = PrincipalEstablec.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @principal_establec }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @principal_establec = PrincipalEstablec.new(params[:principal_establec])\n\n respond_to do |format|\n if @principal_establec.save\n format.html { redirect_to @principal_establec, notice: 'Registro creado satisfactoriamente.' }\n format.json { render json: @principal_establec, ... | [
"0.7169801",
"0.6647806",
"0.6558073",
"0.6476157",
"0.6390883",
"0.6379562",
"0.6320748",
"0.62947965",
"0.6281423",
"0.62744516",
"0.625537",
"0.625238",
"0.62340295",
"0.6227621",
"0.62196976",
"0.6212629",
"0.62100494",
"0.6202174",
"0.6197757",
"0.61742055",
"0.61696005"... | 0.7668875 | 0 |
POST /principal_establecs POST /principal_establecs.json | def create
@principal_establec = PrincipalEstablec.new(params[:principal_establec])
respond_to do |format|
if @principal_establec.save
format.html { redirect_to @principal_establec, notice: 'Registro creado satisfactoriamente.' }
format.json { render json: @principal_establec, status: :cr... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @principal_establec = PrincipalEstablec.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @principal_establec }\n end\n end",
"def create\n @employee = Employee.new(employee_params)\n @employee.user_created_id = current_user.id\n @empl... | [
"0.580639",
"0.5567125",
"0.55025566",
"0.5423747",
"0.54208523",
"0.5352708",
"0.5235911",
"0.5227482",
"0.5182025",
"0.5147265",
"0.5127183",
"0.51191145",
"0.510934",
"0.50643814",
"0.50571424",
"0.5054124",
"0.5034288",
"0.50313413",
"0.5007421",
"0.500588",
"0.5005122",
... | 0.6686834 | 0 |
PUT /principal_establecs/1 PUT /principal_establecs/1.json | def update
@principal_establec = PrincipalEstablec.find(params[:id])
respond_to do |format|
if @principal_establec.update_attributes(params[:principal_establec])
format.html { redirect_to @principal_establec, notice: 'Registro editado satisfactoriamente.' }
format.json { head :no_content ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save\n send(\"principals=\", client_principal.to_abbreviated)\n client.put(api_path, to_json, headers)\n true\n end",
"def create\n @principal_establec = PrincipalEstablec.new(params[:principal_establec])\n\n respond_to do |format|\n if @principal_establec.save\n format.ht... | [
"0.60064065",
"0.5844642",
"0.57739645",
"0.56477374",
"0.56174105",
"0.56026363",
"0.55793464",
"0.5578456",
"0.54674494",
"0.5463115",
"0.53614503",
"0.5341211",
"0.53187567",
"0.5277541",
"0.5269895",
"0.5243638",
"0.52420896",
"0.5210307",
"0.5192401",
"0.5192401",
"0.519... | 0.6827952 | 0 |
DELETE /principal_establecs/1 DELETE /principal_establecs/1.json | def destroy
@principal_establec = PrincipalEstablec.find(params[:id])
@principal_establec.destroy
respond_to do |format|
format.html { redirect_to principal_establecs_url, notice: 'Registro eliminado satisfactoriamente.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_tenant_circle(args = {}) \n delete(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend",
"def test_set3_04c_delete_principal()\n user = \"test_user\"\n @test_acl.create_principal(user)\n id = @test_acl.create_ace(user, \"allow\", \"SELECT\", \"test\", \"/db/temporary/testsource\")\n \n ... | [
"0.7025236",
"0.68755084",
"0.6595089",
"0.65756476",
"0.6481361",
"0.64799505",
"0.64579874",
"0.6456819",
"0.6456782",
"0.6449694",
"0.64460903",
"0.64247763",
"0.64207405",
"0.64193845",
"0.6413468",
"0.6408376",
"0.6406644",
"0.64042044",
"0.6392073",
"0.63788736",
"0.637... | 0.73490435 | 0 |
returns an array of userIds of the opponents of a bet | def get_bet_opponents(bet_id)
opps = []
Bet.find(bet_id).invites.each do |i|
opps.push i.invitee if i.status == "accepted"
end
return opps
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_opponents(game)\n opponents = []\n game.get_players.each do |player|\n if player.get_team(game) != self.get_team(game)\n opponents.push player\n end\n end\n opponents\n end",
"def get_past_teammate_user_ids(participant)\n past_team_associations = TeamsUser.find_all_by_use... | [
"0.67178816",
"0.66381216",
"0.6622362",
"0.6554963",
"0.65111244",
"0.65111244",
"0.65111244",
"0.64689744",
"0.6463699",
"0.6420505",
"0.638433",
"0.6377357",
"0.6377357",
"0.6317945",
"0.6317588",
"0.6302741",
"0.6298207",
"0.6297267",
"0.62927014",
"0.6287805",
"0.6216919... | 0.76749367 | 0 |
DELETE /clubs/1 DELETE /clubs/1.json | def destroy
@club = Club.find(params[:id])
@club.destroy
respond_to do |format|
format.html { redirect_to root_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @club = Club.find(params[:id])\n @club.destroy\n\n respond_to do |format|\n format.html { redirect_to clubs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @club = Club.find(params[:id])\n @club.destroy\n\n respond_to do |format|\n format.h... | [
"0.8125921",
"0.8125921",
"0.80589193",
"0.80589193",
"0.80283463",
"0.7990399",
"0.7949108",
"0.79312074",
"0.78865546",
"0.78865546",
"0.78865546",
"0.78705937",
"0.78516614",
"0.77526957",
"0.771957",
"0.7699575",
"0.7623334",
"0.7608901",
"0.7604228",
"0.7587584",
"0.7587... | 0.81467396 | 0 |
Array of all builds for the given project that have the status `pending` | def pending_builds(project: nil)
not_implemented(__method__)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def active_projects\n self.projects.where(:is_canceled => false, :is_finished => false )\n end",
"def pending_refund_payments_projects\n pending_refund_payments.map(&:project)\n end",
"def pending_start_projects\n self.projects.where(:is_canceled => false, :is_started => false ).order(\"shoot_date A... | [
"0.627299",
"0.6206553",
"0.6092597",
"0.6052416",
"0.6046888",
"0.59889466",
"0.5978075",
"0.5974735",
"0.5951394",
"0.59363586",
"0.5922746",
"0.5915245",
"0.5884338",
"0.58668303",
"0.5845658",
"0.58387434",
"0.5796712",
"0.57959735",
"0.579127",
"0.5772402",
"0.5771239",
... | 0.681905 | 0 |
Add or update a build | def add_build!(project: nil, build: nil)
not_implemented(__method__)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bumpBuild()\n\t\t\t\t@build += 1\n\t\t\tend",
"def save!\n client.put_build(app_id: app_id, build_id: id, build: self)\n end",
"def build\n if phase.has_key?('build')\n execute(\"build\", phase['build'])\n end\n end",
"def update_buildfile\n buildfile = change_version { |vers... | [
"0.64575064",
"0.6409246",
"0.6197418",
"0.6129657",
"0.60455304",
"0.60054934",
"0.59535253",
"0.5953092",
"0.5916657",
"0.5863953",
"0.585549",
"0.585549",
"0.5829684",
"0.5796988",
"0.5760256",
"0.5744043",
"0.5732501",
"0.57074934",
"0.57074934",
"0.57074934",
"0.57074934... | 0.64793015 | 0 |
returns how many courts of the sport passed as parameter the club has if no parameter is sent it passes all quantities | def court_quantity sport=nil
if @sports.blank?
@sports = self.courts.includes(:sport).map {|c| c.sport.name }
end
qty_hash = Hash.new 0
@sports.each do |sp|
qty_hash[sp.downcase] += 1
end
return qty_hash[sport.downcase] unless sport.blank?
qty_hash
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def goals_against(club)\n if finished?\n if club == local\n return guest_goals\n end\n\n if club == guest\n return local_goals\n end\n end\n\n 0\n end",
"def create_courts\n futbol = Sport.where(:name => 'futbol').first\n tenis = Sport.where(:name => 'tenis'... | [
"0.5965146",
"0.5913507",
"0.5863452",
"0.5840749",
"0.5828044",
"0.58008087",
"0.57821935",
"0.57807285",
"0.56624246",
"0.56365997",
"0.5624656",
"0.5619406",
"0.5609873",
"0.5599306",
"0.5599264",
"0.5598247",
"0.5598211",
"0.5577597",
"0.5572854",
"0.5563775",
"0.55564755... | 0.7287886 | 0 |
Creates or destroy courts to match the quantity indicated by the user Can be refactored | def create_courts
futbol = Sport.where(:name => 'futbol').first
tenis = Sport.where(:name => 'tenis').first
paddle = Sport.where(:name => 'paddle').first
# court_quantity '*' indicates how many courts already has
# @*_quantity indicates how many tha user wants
### Futbol Courts
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n \n params[:cour][:ecole_id] = ecole.id if ecole?\n\n #Ajout de la classe en groupe\n params[:cour][:classe_room_id].unshift(params[:cour][:first_classe_room_id])\n\n @creneau = params[:cour][:creneau_debut].to_i \n @nombre_heure = params[:cour][:creneau_fin].to_i - params[:co... | [
"0.5989571",
"0.5884454",
"0.58791196",
"0.5794289",
"0.5767527",
"0.5712051",
"0.56974554",
"0.56931835",
"0.56616664",
"0.5661304",
"0.56434244",
"0.5617602",
"0.56034285",
"0.56002253",
"0.5598648",
"0.55969226",
"0.55898094",
"0.5588776",
"0.5566006",
"0.5565932",
"0.5561... | 0.7393915 | 0 |
Sets the value of the property If status is not supplied, the status will default to 200 for nonnull properties, and 404 for null properties. | def set(property_name, value, status = nil)
status = value.nil? ? 404 : 200 if status.nil?
result[property_name] = [status, value]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_status_code\n if self.status_code.nil?\n self.status_code = \"200\"\n end\n end",
"def set_status(val)\n self.status = val\n self\n end",
"def status=(status)\n @_status = status\n end",
"def status=(status)\n @_status = status\n end",
"def status=(s... | [
"0.70338356",
"0.6806251",
"0.6752961",
"0.6752961",
"0.673785",
"0.663394",
"0.66199183",
"0.653434",
"0.650992",
"0.6508947",
"0.6508947",
"0.6508947",
"0.6508947",
"0.6508947",
"0.6508947",
"0.6508947",
"0.6508947",
"0.6508947",
"0.6508947",
"0.6508947",
"0.6508947",
"0.... | 0.79299617 | 0 |
Returns the current status code for a property name. If the property does not appear in the list of requested properties, null will be returned. | def status(property_name)
result.key?(property_name) ? result[property_name][0] : 404
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_property( propname )\n resp = conn.get('/users/'+name+'/props/'+propname+'/')\n \n case resp.code.to_i\n when 200\n return JSON.parse( resp.body )\n when 404\n case resp.header['resource-type']\n when 'user'\n raise RestAuthUserNotFound.new( resp )\n when 'property... | [
"0.6135004",
"0.5816986",
"0.5801187",
"0.5748053",
"0.56408185",
"0.56390136",
"0.56014687",
"0.5557331",
"0.5550417",
"0.5525974",
"0.5520257",
"0.5497238",
"0.5403703",
"0.53703415",
"0.53535676",
"0.5329288",
"0.5230734",
"0.52157766",
"0.52098304",
"0.51871276",
"0.51759... | 0.77607304 | 0 |
Returns all propertynames that have a 404 status, and thus don't have a value yet. | def get404_properties
result = []
self.result.each do |property_name, stuff|
result << property_name if stuff[0] == 404
end
# If there's nothing in this list, we're adding one fictional item.
result << '{http://sabredav.org/ns}idk' if result.empty?
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list_invalid_properties\n invalid_properties = Array.new\n if @status.nil?\n invalid_properties.push('invalid value for \"status\", status cannot be nil.')\n end\n\n invalid_properties\n end",
"def list_invalid_properties\n invalid_properties = Array.new\n if @name.nil... | [
"0.6622768",
"0.64270794",
"0.64013624",
"0.64013624",
"0.64013624",
"0.64013624",
"0.64013624",
"0.64013624",
"0.6388563",
"0.63862526",
"0.63862526",
"0.63862526",
"0.63862526",
"0.63862526",
"0.63862526",
"0.63862526",
"0.63862526",
"0.63862526",
"0.63862526",
"0.63862526",
... | 0.78250164 | 0 |
GET /c_videos/1 GET /c_videos/1.json | def show
@c_video = CVideo.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @c_video }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def videos options={}\n response = client.get(\"/#{id}/videos\", options)\n end",
"def list\n @videos = Video.all\n\n respond_to do |format|\n format.html # list.html.erb\n format.json { render json: @videos }\n end\n end",
"def index\n @videos = Video.all\n render json: @vide... | [
"0.76379496",
"0.7344656",
"0.7323692",
"0.7167795",
"0.716704",
"0.716704",
"0.716704",
"0.716704",
"0.71265334",
"0.71194375",
"0.7093038",
"0.7083882",
"0.7078058",
"0.7075357",
"0.7067187",
"0.7053308",
"0.7053308",
"0.70165056",
"0.70165056",
"0.70165056",
"0.70165056",
... | 0.7482724 | 1 |
DELETE /c_videos/1 DELETE /c_videos/1.json | def destroy
@c_video = CVideo.find(params[:id])
@c_video.destroy
respond_to do |format|
format.html { redirect_to c_videos_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n s3 = $S3\n bucket = s3.buckets['tubeyou.video']\n bucket.objects[@video.name].delete\n\n @video.destroy\n respond_to do |format|\n format.html { redirect_to videos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @video.destroy\n render json: ... | [
"0.74720913",
"0.73984087",
"0.73090214",
"0.73090214",
"0.72935194",
"0.7292421",
"0.7292421",
"0.7292421",
"0.7292421",
"0.7292421",
"0.7292421",
"0.7292421",
"0.7292421",
"0.7292421",
"0.7292421",
"0.7292421",
"0.7292421",
"0.7289624",
"0.72776693",
"0.72776693",
"0.727766... | 0.7571032 | 0 |
Return the file list content as JSON for rendering in the list container The actual metadata returned varies based on the view_type requested, in order to speed up large directories | def content
setup_download_list
except_list = case view_type
when 'icons'
%i[file_metadata last_process_name_run updated_at created_at user_id file_hash
content_type nfs_store_stored_file_id]
else
%... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list_files\n source_dir = Path.new(params[:source_dir])\n if params.has_key?(:show_catalogues)\n show_catalogues = params[:show_catalogues]\n else\n show_catalogues = false\n end\n if params[:ext].present?\n file_type = params[:ext]\n else\n file_type = nil\n end\n r... | [
"0.6995037",
"0.6731227",
"0.6723786",
"0.66914433",
"0.65439194",
"0.65369254",
"0.6516771",
"0.6492961",
"0.6372714",
"0.63477516",
"0.63052166",
"0.6275796",
"0.62591004",
"0.62393045",
"0.61822623",
"0.61689866",
"0.6135253",
"0.61291194",
"0.61150324",
"0.61150324",
"0.6... | 0.7120745 | 0 |
Setup the list of download file items, handling item flags if needed. | def setup_download_list
return unless @container.readable?
# Check if we should show flags for classifications on each of the types of container file
@allow_show_flags = {}
%i[stored_file archived_file].each do |rt|
full_name = "nfs_store__manage__#{rt}"
show_flag = !!Classifica... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setup_items(selected_items, for_action)\n # Retrieve each file's details. The container_id will be passed if this is a\n # multi container download, otherwise it will be ignored\n selected_items.each do |s|\n container = self.container || Browse.open_container(id: s[:container_id], user: ... | [
"0.7192753",
"0.5699413",
"0.5591785",
"0.5428122",
"0.53840667",
"0.53437716",
"0.53226024",
"0.5298365",
"0.5285891",
"0.52695596",
"0.52055764",
"0.5192494",
"0.5182384",
"0.5180816",
"0.5177297",
"0.517034",
"0.51582044",
"0.51190865",
"0.510657",
"0.50914764",
"0.5091476... | 0.73778343 | 0 |
GET /spents GET /spents.json | def index
@spents = Spent.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @points_spents = PointsSpent.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @points_spents }\n end\n end",
"def show\n @stundent = Stundent.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n form... | [
"0.66863346",
"0.6218785",
"0.6188353",
"0.6137427",
"0.6125209",
"0.6122911",
"0.6090993",
"0.59377146",
"0.59064674",
"0.58739614",
"0.586759",
"0.58445305",
"0.58069",
"0.5785005",
"0.5776749",
"0.576828",
"0.5742789",
"0.5697812",
"0.56844914",
"0.5678075",
"0.56020933",
... | 0.7046632 | 0 |
POST /spents POST /spents.json | def create
@spent = Spent.new(spent_params)
respond_to do |format|
if @spent.save
format.html { redirect_to @spent, notice: 'Spent was successfully created.' }
format.json { render :show, status: :created, location: @spent }
else
format.html { render :new }
format.js... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def post_spoonacular\n # %encode ingredients to url\n encoded_ingr = URI.escape(@translated_recipe[:ingredients_list])\n # post call block :\n url = URI(\"https://spoonacular-recipe-food-nutrition-v1.p.rapidapi.com/recipes/parseIngredients?includeNutrition=true\")\n http = Net::HTTP.new(url.host, ur... | [
"0.5915685",
"0.5810478",
"0.5743416",
"0.561621",
"0.5596164",
"0.5568079",
"0.5501657",
"0.54477894",
"0.5420697",
"0.5381398",
"0.5340402",
"0.5324662",
"0.5305585",
"0.5295365",
"0.52871805",
"0.52682865",
"0.5263237",
"0.5242624",
"0.52214664",
"0.5216364",
"0.5207321",
... | 0.58148843 | 1 |
=== Description Your application should override this method. Implement the main entry point. === Parameters argv:: (Array) of positional arguments Basically left over after processing command line options starting with dash(s) as defined in get_options. === Returns (Integer) exit code | def main(argv)
# override this; no default action in main
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run(argv = ARGV)\n #p [:argv, argv]\n begin\n # cheating\n if argv.include?('-h') or argv.include?('--help')\n puts help_text\n else\n app = from_argv(argv)\n app.run\n end\n rescue Exception => e\n if exit_statu... | [
"0.7565795",
"0.69048387",
"0.68647856",
"0.68382984",
"0.67724186",
"0.6733345",
"0.6711474",
"0.66102684",
"0.65572083",
"0.6534257",
"0.65159637",
"0.6473957",
"0.6469824",
"0.6443771",
"0.6437997",
"0.64216685",
"0.64182794",
"0.64128083",
"0.64062244",
"0.6402456",
"0.63... | 0.7791449 | 0 |
=== Description Parse options, and run the main method === Returns (Integer) exit code | def run
code = 0
opt = OptionParser.new
define_options(opt)
default_options(opt)
define_exit_codes(opt)
argv = opt.parse!
if @help
puts_msg(opt.help)
else
begin
main(argv)
rescue Exception => e
arr = @@exit_code_map[e.class]
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run\n if !options_parsed?() || !options_valid?()\n @stderr.puts(\"\")\n output_usage(@stderr)\n return 1\n end\n return run_real()\nend",
"def parse!\n begin\n @opts = OptionParser.new(&method(:set_opts))\n @opts.parse!(@args)\n @options\n rescue Exception => e\n ... | [
"0.767985",
"0.74173754",
"0.71463656",
"0.7116004",
"0.705908",
"0.70411134",
"0.7036456",
"0.6995846",
"0.6971928",
"0.69436526",
"0.6931246",
"0.6906994",
"0.6893284",
"0.6886774",
"0.6882564",
"0.68564314",
"0.6835208",
"0.68287444",
"0.6809437",
"0.6796433",
"0.6790949",... | 0.8654356 | 0 |
=== Description Print out msg to STDERR in red color | def puts_err(msg)
STDERR.puts(msg.to_s.red)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def print_stderr(msg)\n puts \" #{color(msg, 31)}\"\n end",
"def error_message( msg, details='' )\n\t\t\t$stderr.puts colorize( 'bold', 'white', 'on_red' ) { msg } + details\n\t\tend",
"def error_message( msg, details='' )\n\t\t$stderr.puts colorize( 'bold', 'white', 'on_red' ) { msg } + ' ' + de... | [
"0.87337965",
"0.82728803",
"0.8242551",
"0.82000345",
"0.8098276",
"0.8080287",
"0.78530663",
"0.780545",
"0.7705156",
"0.76129603",
"0.7535064",
"0.741853",
"0.73221236",
"0.7239498",
"0.7171502",
"0.71554863",
"0.71274287",
"0.7108954",
"0.70611954",
"0.7034199",
"0.701279... | 0.8678974 | 1 |
Updates all stations from BOM website. | def update_stations
State.all.each do |s|
fetch_stations(s)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def updateStation()\n uri=URI.parse(ViaggiatrenoURLs.STATION_INFO)\n response = Net::HTTP.post_form(uri,{\"stazione\" => @stationFrom, \"lang\" => \"IT\"})\n doc = Nokogiri::HTML(response.body)\n\n doc.xpath(XPathMatchInfo.XPATH_STATION).each do |x|\n \n StringUtils.remove_newlines_tabs_and_s... | [
"0.698828",
"0.6278264",
"0.5869688",
"0.58676517",
"0.5729337",
"0.56947315",
"0.5577968",
"0.5575948",
"0.55673766",
"0.55408454",
"0.55315363",
"0.55167544",
"0.54987544",
"0.54011744",
"0.5377886",
"0.5368271",
"0.53562886",
"0.53431135",
"0.5324092",
"0.5319878",
"0.5318... | 0.72969127 | 0 |
Retrieves a list of the URLS for each weather station given a State. Each url is then passed to the extract_station method. | def fetch_stations(state)
scraper_logger.info("Fetching stations for #{state.name}")
doc = Nokogiri::HTML(open(state.url))
doc.css('a').each do |s|
Global::OBSERVATION_PRODUCT_CODE.each do |c|
if s.attr('href').include?(c) and s.attr('href').include?(state.product_group)
extract_s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def extract_station(url, state)\n\n id, json_url = nil\n\n doc = Nokogiri::HTML(open(\"#{Global::BOM_BASE_URL}#{url}\"))\n doc.css('a').each do |l|\n\n if l.attr('href').include?('json')\n json_url = l.attr('href')\n id = l.attr('href').split('.')\n id = id[1]\n end\n\n e... | [
"0.6223554",
"0.5820403",
"0.57375234",
"0.56964236",
"0.56822276",
"0.56321967",
"0.5613308",
"0.5611582",
"0.56078744",
"0.5523439",
"0.5521253",
"0.55070436",
"0.5458414",
"0.5438868",
"0.5430657",
"0.53995764",
"0.5375218",
"0.5367982",
"0.5304522",
"0.5283608",
"0.526027... | 0.73837906 | 0 |
Creates a new, or updates an existing, Station given it's URL and the State to which it belongs. | def extract_station(url, state)
id, json_url = nil
doc = Nokogiri::HTML(open("#{Global::BOM_BASE_URL}#{url}"))
doc.css('a').each do |l|
if l.attr('href').include?('json')
json_url = l.attr('href')
id = l.attr('href').split('.')
id = id[1]
end
end
begin
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @station = Station.new(station_params)\n\n if @station.save\n render json: @station, status: :created, location: @station\n else\n render json: @station.errors, status: :unprocessable_entity\n end\n end",
"def create_station!(name)\n station = Station.new(name... | [
"0.6124878",
"0.5908352",
"0.5855723",
"0.5855723",
"0.5790763",
"0.5772726",
"0.5731229",
"0.5681185",
"0.5606074",
"0.5506624",
"0.54587865",
"0.5431429",
"0.5410876",
"0.53667563",
"0.5360192",
"0.5360192",
"0.5360192",
"0.5357474",
"0.5355892",
"0.5342366",
"0.5306843",
... | 0.6925179 | 0 |
Will retrieve all new observations given a Station. | def fetch_observations(station)
scraper_logger.info("Fetching latest weather observations for #{station.id} - #{station.name}")
new = 0
json = extract_observations(station.json_url)
json['observations']['data'].each do |o|
Time.zone = 'UTC'
recording_time = Time.zone.parse("#{o['aifstime... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_stations\n\n State.all.each do |s|\n fetch_stations(s)\n end\n\n end",
"def index\n @stations = Station.all\n end",
"def index\n @stations = Station.all\n end",
"def index\n @station_infos = StationInfo.all\n end",
"def gather!\n @observations = get_datas!\n ... | [
"0.60627115",
"0.60454845",
"0.60211325",
"0.60140836",
"0.60013545",
"0.599155",
"0.5933164",
"0.58868164",
"0.58325136",
"0.57831836",
"0.5751916",
"0.57026345",
"0.56444305",
"0.55942184",
"0.5555724",
"0.55298007",
"0.54736036",
"0.54655385",
"0.5448267",
"0.5442694",
"0.... | 0.7462373 | 0 |
Given a JSON feed containing a group of BOM observations, along with an Observation, this method will create all necessary Reading records based on ReadingType records. | def parse_readings(json, observation)
ReadingType.all.each do |r|
reading = Reading.new
reading.observation = observation
reading.reading_type = r
unless json[r.bom_field_name].nil?
if r.numeric
reading.numeric_value = json[r.bom_field_name].to_d unless json[r.bom_field_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @readings = []\n lines = Base64.decode64 params[:file].sub('data:text/csv;base64,','')\n solar_readings = lines.split(\"\\n\").reverse\n solar_readings.each do |reading|\n reading = reading.split(\";\")\n begin\n date = DateTime.strptime(reading[0], '%d/%m/%Y')\n @r... | [
"0.5236031",
"0.50617695",
"0.50402725",
"0.4994088",
"0.48664123",
"0.48345155",
"0.47930834",
"0.47810516",
"0.47340125",
"0.47205272",
"0.46971118",
"0.46683747",
"0.4653783",
"0.4649695",
"0.46401024",
"0.4635319",
"0.4583495",
"0.4558224",
"0.45501173",
"0.45426437",
"0.... | 0.73365414 | 0 |
Welcome_email is a eMail sent to the Channel Admin, after setting up the channel and contains the Sec_Hash | def welcome_email(channel)
@channel = channel
@url = 'http://example.com/login'
mail(to: @channel.email, subject: 'Welcome to your Constructeev Channel')
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def welcome_email\n # User welcome email sent.\n end",
"def welcome_email(user, currenthost)\n\t @user = user\n\t @currenthost = currenthost\n\n\t mail(to: @user.email, subject: 'Welcome to Changefindr').deliver()\n\tend",
"def welcome_email\n UserMailer.welcome_email\n end",
"def welcome_em... | [
"0.7122097",
"0.7005587",
"0.69214004",
"0.69214004",
"0.68974185",
"0.6884443",
"0.68843615",
"0.68599933",
"0.6839519",
"0.6827258",
"0.6815871",
"0.68025696",
"0.6710657",
"0.66929525",
"0.66835964",
"0.6652146",
"0.66480637",
"0.66356033",
"0.66262025",
"0.6588923",
"0.65... | 0.78109956 | 0 |
GET /forum_cat_l1s/1 GET /forum_cat_l1s/1.xml | def show
@forum_cat_l1 = ForumCatL1.find(params[:id])
@forum_cat_l2s = ForumCatL2.find(:all, :conditions => ["forum_cat_l1_id = ?", params[:id]])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @forum_cat_l1 }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @forum_cat_l1 = ForumCatL1.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @forum_cat_l1 }\n end\n end",
"def get_categories\n body = build_request(2935, 1501, \"ACTIVEHEADINGS\")\n response = send_to_localeze(body)\n xml_d... | [
"0.6666921",
"0.657437",
"0.6237197",
"0.6066407",
"0.6056434",
"0.60168463",
"0.5993059",
"0.59686416",
"0.5965243",
"0.58546954",
"0.5843813",
"0.5819074",
"0.58076763",
"0.5786881",
"0.57772726",
"0.5771613",
"0.57529575",
"0.5740423",
"0.57294387",
"0.57013685",
"0.570136... | 0.67749006 | 0 |
GET /forum_cat_l1s/new GET /forum_cat_l1s/new.xml | def new
@forum_cat_l1 = ForumCatL1.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @forum_cat_l1 }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @forum_cat_l1 = ForumCatL1.new(params[:forum_cat_l1])\n\n respond_to do |format|\n if @forum_cat_l1.save\n flash[:notice] = t(:category1_created)\n format.html { redirect_to(@forum_cat_l1) }\n format.xml { render :xml => @forum_cat_l1, :status => :created, :location =>... | [
"0.7542703",
"0.7050673",
"0.7031274",
"0.7031274",
"0.68963134",
"0.6877075",
"0.68483984",
"0.6834801",
"0.68277633",
"0.68277633",
"0.68277633",
"0.68277633",
"0.680393",
"0.6793724",
"0.6777852",
"0.67618775",
"0.67491084",
"0.67463917",
"0.6737806",
"0.6737038",
"0.67322... | 0.7759111 | 0 |
POST /forum_cat_l1s POST /forum_cat_l1s.xml | def create
@forum_cat_l1 = ForumCatL1.new(params[:forum_cat_l1])
respond_to do |format|
if @forum_cat_l1.save
flash[:notice] = t(:category1_created)
format.html { redirect_to(@forum_cat_l1) }
format.xml { render :xml => @forum_cat_l1, :status => :created, :location => @forum_cat_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @forum_cat_l1 = ForumCatL1.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @forum_cat_l1 }\n end\n end",
"def update\n @forum_cat_l1 = ForumCatL1.find(params[:id])\n\n respond_to do |format|\n if @forum_cat_l1.update_attr... | [
"0.61182815",
"0.5838544",
"0.57440066",
"0.56360775",
"0.5618319",
"0.561795",
"0.55866885",
"0.5584254",
"0.5566893",
"0.5534312",
"0.55145437",
"0.5512915",
"0.54744476",
"0.54412353",
"0.5435567",
"0.5377139",
"0.537596",
"0.53596586",
"0.53553075",
"0.53281456",
"0.52806... | 0.72710294 | 0 |
PUT /forum_cat_l1s/1 PUT /forum_cat_l1s/1.xml | def update
@forum_cat_l1 = ForumCatL1.find(params[:id])
respond_to do |format|
if @forum_cat_l1.update_attributes(params[:forum_cat_l1])
flash[:notice] = t(:category_updated)
format.html { redirect_to(@forum_cat_l1) }
format.xml { head :ok }
else
format.html { rende... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @cat = Cat.find(params[:id])\n\n respond_to do |format|\n if @cat.update_attributes(params[:cat])\n _update_topics \n format.html { redirect_to action: \"edit\", notice: 'Cat was successfully updated.' }\n format.json { head :no_content }\n else\n format.htm... | [
"0.61464083",
"0.61202496",
"0.6073736",
"0.6055222",
"0.60029536",
"0.5998899",
"0.59769785",
"0.5892616",
"0.58444476",
"0.58378303",
"0.58305293",
"0.5809139",
"0.5806455",
"0.5758757",
"0.57459974",
"0.57392335",
"0.57291216",
"0.571252",
"0.5706334",
"0.569899",
"0.56981... | 0.7152804 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.