query stringlengths 7 9.55k | document stringlengths 10 363k | metadata dict | negatives listlengths 0 101 | negative_scores listlengths 0 101 | document_score stringlengths 3 10 | document_rank stringclasses 102
values |
|---|---|---|---|---|---|---|
Delete file (recursive/force) ==== Options +path+:: Path to delete | def rm_rf(path)
run_via "rm -rf #{path}"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_file(path)\n path = File.join('/', path)\n raise ArgumentError if path == '/'\n self.class.delete(path, request_options)\n end",
"def file_delete(path)\n params = {\n \"root\" => @root,\n \"path\" => format_path(path, false),\n }\n r... | [
"0.81161565",
"0.7969207",
"0.76214314",
"0.752448",
"0.73158216",
"0.73158216",
"0.7306531",
"0.7178963",
"0.7162978",
"0.7143399",
"0.71231925",
"0.7102016",
"0.70914054",
"0.70842975",
"0.7054071",
"0.7040268",
"0.70382375",
"0.7026214",
"0.7025417",
"0.699993",
"0.6997250... | 0.68171066 | 33 |
Load template and install it. Removes temporary files during transfer and ensures desination directory is created before install. See template plugin for where template paths are loaded from. ==== Options +template_path+:: Path to template +destination+:: Remote path to evaluated template +options+:: Options (see Install template options) ==== Install template options +user+:: User to install (o). Defaults to root. +mode+:: Mode to install file (m) ==== Example utils.install_template("monit/memcached.monitrc.erb", "/etc/monit/memcached.monitrc", :user => "root", :mode => "600") | def install_template(template_path, destination, options = {})
# Truncate extension
tmp_file_path = template_path.gsub("/", "_").gsub(/.erb$/, "")
tmp_path = "/tmp/#{tmp_file_path}"
options[:user] ||= "root"
install_options = []
install_options << "-o #{options[:user]}"
install_options << "-m #{options[:mode]}" if options.has_key?(:mode)
put template.load(template_path), tmp_path
# TOOD: Ensure directory exists? mkdir -p #{File.dirname(destination)}
run_via "install #{install_options.join(" ")} #{tmp_path} #{destination} && rm -f #{tmp_path}"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def install_template(path)\n puts \"Installing project template to #{path} ...\"\n template_dir = File.expand_path('../template', __FILE__)\n FileUtils.cp_r(\"#{template_dir}/.\", path)\n end",
"def template(target, options={})\n template_name = options[:source] || File.basename(target)\n locals = op... | [
"0.7118178",
"0.7028229",
"0.6262468",
"0.6239971",
"0.5836827",
"0.57992494",
"0.5749228",
"0.564967",
"0.56440383",
"0.5638322",
"0.55855095",
"0.552526",
"0.55077505",
"0.5486212",
"0.54749334",
"0.5378448",
"0.5371758",
"0.5335664",
"0.53325105",
"0.5305625",
"0.5277993",... | 0.86968935 | 0 |
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 |
Check if file exists. ==== Options +path+:: Path to file | def exist?(path)
found = true
run_via "head -1 #{path} >/dev/null 2>&1 || 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 check_file_exist(path)\n raise \"Cannot find: #{path}\" unless File.exist?(path)\n end",
"def file_exists?(path)\n parse_boolean(transport.execute(\"Test-Path #{escape(path)}\", :read_only => true).stdout)\n end",
"def check_file(path)\n raise Error, \"The path '#{path}' does not e... | [
"0.82054025",
"0.8067295",
"0.77563083",
"0.77016383",
"0.76747197",
"0.7668749",
"0.7635254",
"0.7626826",
"0.76249313",
"0.760843",
"0.76075596",
"0.75958204",
"0.75824624",
"0.7555375",
"0.7511181",
"0.74788857",
"0.74575865",
"0.7443056",
"0.7394763",
"0.73857033",
"0.738... | 0.6882429 | 55 |
Get the hostname of the remote server ==== Example utils.hostname => "localhost.localdomain" | def hostname
hostname = nil
run "hostname" do |channel, stream, data|
hostname = data.chomp
end
hostname
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_server_hostname\n (`hostname`).strip\n end",
"def hostname\n Socket.gethostname\n end",
"def hostname\n Socket.gethostname\n end",
"def hostname\n Socket.gethostname.split('.').first.strip\n end",
"def hostname\n @hostname ||= `hostname`.chomp\n end",
"def ... | [
"0.84309983",
"0.83373976",
"0.83373976",
"0.83363235",
"0.8276696",
"0.8187103",
"0.81652224",
"0.8154142",
"0.812036",
"0.8043678",
"0.79622984",
"0.78744024",
"0.7870252",
"0.7869312",
"0.7801229",
"0.77977604",
"0.7745484",
"0.7702154",
"0.76578045",
"0.7657553",
"0.76383... | 0.8037145 | 10 |
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+:: If true (default), raise error if file does not 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?(path)
data.split("\n").each do |line|
line = line.gsub(/^\s+/, "") if left_strip
run_via "echo '#{line}' >> #{path}"
end
end | {
"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 |
Method returns the state of an object at given time point | def state_at(time_string)
return {} if time_string.blank?
changes = state_changes.where('changed_at <= ?', DateTime.parse(time_string)).pluck(:changed_values)
changes.inject({}) { |c, state| c.merge(state) }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def state(object)\n tracker.fetch(object)\n end",
"def state_at(t)\n\n if @time_span.include?(t)\n \n leg_percent = (t - @launch_time) / @flight_time\n dist = leg_percent * @distance\n dist_rad = leg_percent * @distance_rad\n\n alt_track = @alt1 + @v_init * (t ... | [
"0.64406633",
"0.63835573",
"0.6351832",
"0.6287118",
"0.6150739",
"0.6089149",
"0.6011625",
"0.59686357",
"0.5946129",
"0.59131664",
"0.5797158",
"0.5792409",
"0.5792409",
"0.57847303",
"0.57585275",
"0.5749631",
"0.57465136",
"0.57293934",
"0.57126606",
"0.56720215",
"0.567... | 0.55703676 | 30 |
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
# Add location data to the current active station list
stations.each { |crs, data| data.merge!(locations[crs]) if locations[crs] }
write_yaml(stations)
log('Your station list has been updated')
end | {
"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 Name']
end
log('DONE')
results
end | {
"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(&:text)
crs = row.xpath('./td').first.xpath('./a').first['name'].upcase rescue nil
unless [crs, cols[6], cols[7]].include?(nil) || [crs, cols[6], cols[7]].include?('')
results[crs] = { latitude: cols[7].to_f, longitude: cols[6].to_f }
end
end
sleep(1) # be nice to railwaycodes.org.uk
end
log('DONE')
results
end | {
"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 |
Returns the response body for a GET request | def get_response(url)
uri = URI(url)
Net::HTTP.start(uri.host, uri.port, use_ssl: uri.scheme == 'https') do |http|
request = Net::HTTP::Get.new uri
return http.request(request).body
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get\n response = Net::HTTP.get_response(endpoint_uri)\n case response\n when Net::HTTPSuccess, Net::HTTPRedirection\n return response.body\n else \n raise response.body\n end\n end",
"def get\n url = prefix + \"get\"\n return response(url)\n end",
"def... | [
"0.77841413",
"0.77799475",
"0.77799475",
"0.77258235",
"0.77258235",
"0.7521605",
"0.74256873",
"0.7364632",
"0.7308463",
"0.72702736",
"0.7257912",
"0.72103703",
"0.7190221",
"0.71405685",
"0.7136288",
"0.7098193",
"0.7094688",
"0.70913947",
"0.69861037",
"0.6973668",
"0.69... | 0.0 | -1 |
Puts without a linebreak | def log(str, newline = true)
return puts(str) if newline
print str.ljust(60, ' ')
STDOUT.flush
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def put_a_line\n puts \"\\n\"\n puts \"/\\\\\" * 40\n puts \"\\n\"\n end",
"def empty_line\r\n puts \"\\n\"\r\n end",
"def blank_line\n output \"\"\n end",
"def render_spacer\n puts \"\\n\"\n end",
"def lineBreak \n \"lineBreak\" \n end",
"def line_feed\n writ... | [
"0.7111479",
"0.7045081",
"0.69562393",
"0.69230783",
"0.67122835",
"0.6678514",
"0.6643383",
"0.6600773",
"0.6599524",
"0.6577277",
"0.65621376",
"0.65601504",
"0.6470468",
"0.6459504",
"0.64575213",
"0.6451263",
"0.64300156",
"0.64070874",
"0.6396748",
"0.63712376",
"0.6349... | 0.0 | -1 |
there is no cli updatejob command | def action_update
if job_exists
post_job(job_url)
else
post_job(new_job_url)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update!(**args)\n @job = args[:job] if args.key?(:job)\n end",
"def update!(**args)\n @job = args[:job] if args.key?(:job)\n end",
"def update!(**args)\n @failed_jobs = args[:failed_jobs] if args.key?(:failed_jobs)\n @job = args[:job] if args.key?(:job)\n ... | [
"0.75874716",
"0.75874716",
"0.7297529",
"0.7289962",
"0.7039567",
"0.69346386",
"0.68443626",
"0.6808775",
"0.6788607",
"0.67065394",
"0.66502607",
"0.6609347",
"0.6609347",
"0.66064775",
"0.66060036",
"0.6543909",
"0.6506621",
"0.6504699",
"0.649269",
"0.6491358",
"0.649097... | 0.65943944 | 15 |
POST /tasks POST /tasks.json | def create
task = Task.create(task_params)
@artist = Artist.find_by_id(task_params[:artist_id])
task.artist = @artist
task.save!
render json: task
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n #@task = Task.new(task_params)\n task = @task_list.tasks.create!(task_params)\n render json: task\n end",
"def create\n @task = Task.new(task_params)\n\n if @task.save\n render json: @task, status: :created\n else\n render json: @task.errors, status: :unprocessable_entit... | [
"0.7529737",
"0.74976224",
"0.7411092",
"0.7389878",
"0.7261207",
"0.72587913",
"0.7183996",
"0.7147952",
"0.71120256",
"0.70759165",
"0.70639485",
"0.70576006",
"0.70560944",
"0.70294535",
"0.7016957",
"0.7012058",
"0.70110804",
"0.7009976",
"0.6993863",
"0.69896185",
"0.698... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def task_params
params.require(:task).permit(:title, :start, :end, :allDay,:genre,:note,:controller,:action,:artist_id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",... | 0.0 | -1 |
def inc_vote_count increment! :vote_count planet.inc_vote_count, self end def dec_vote_count decrement! :vote_count planet.dec_vote_count, self end | def add_vote_from_user(user)
votes.create(user: user)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def decrease_vote_count\n \tcount = voteable.votes_count\n \tcount = count - 1\n \tvoteable.update_attributes(votes_count: count)\n end",
"def add_vote\n self.increment!(:votes, 1)\n end",
"def increase_vote_count\n \tcount = voteable.votes_count\n \tcount = count + 1\n \tvoteable.update_attributes(... | [
"0.77159476",
"0.768117",
"0.7681033",
"0.7553056",
"0.7552907",
"0.75069547",
"0.74648917",
"0.74441564",
"0.73987687",
"0.7398378",
"0.72785795",
"0.72116786",
"0.7199402",
"0.717111",
"0.71554273",
"0.7087474",
"0.70762724",
"0.7048536",
"0.7002394",
"0.699287",
"0.6902745... | 0.0 | -1 |
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 => 'GET',
:parser => Fog::Parsers::AWS::Storage::GetBucketTagging.new,
:query => {'tagging' => nil}
})
end | {
"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 |
Rails 3.1 adds update_column. Rails > 3.2.6 deprecates update_attribute, gone in Rails 4. | def update_attribute_or_column(*args)
respond_to?(:update_attribute) ? update_attribute(*args) : update_column(*args)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_attribute_or_column(*args)\n respond_to?(:update_column) ? update_column(*args) : update_attribute(*args)\n end",
"def update_attribute_or_column(*args)\n respond_to?(:update_column) ? update_column(*args) : update_attribute(*args)\n end",
"def update_mark_only_attribute_or_column(*args)\n ... | [
"0.7466455",
"0.7466455",
"0.69622284",
"0.6838364",
"0.6625082",
"0.6625082",
"0.6625082",
"0.6522453",
"0.64334697",
"0.61733955",
"0.6120923",
"0.6120923",
"0.6120923",
"0.6120923",
"0.6120923",
"0.6120923",
"0.6120923",
"0.6120923",
"0.6120923",
"0.6120923",
"0.6120923",
... | 0.7391719 | 2 |
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 |
event type http method URI path (without host or query params) session id props props[nid] network id (e.g. IP address) props[cid] customer ID props[ua] User Agent props[ref] HTTP referrer | def add_request meth, uri
props = {
MrBelvedere::Fields::HTTP_METHOD => meth.to_s.downcase,
MrBelvedere::Fields::REQUEST_URI => uri.to_s,
MrBelvedere::Fields::CURRENT_TIME => Familia.now
}.merge @props
requests.unshift props # add to the end so we can read in reverse-chronological
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def url_for_event type, opts={}\n p = HashWithIndifferentAccess.new\n parent_controller.request.parameters.each do |k,v|\n if k.end_with? \"_id\" or k == \"id\"\n p[k] = v\n end\n end\n\n super type, p.merge(opts)\n end",
"def url_for_event(type, options)\n options.reverse_... | [
"0.61553514",
"0.5900639",
"0.5629537",
"0.5620052",
"0.5591432",
"0.5470911",
"0.5437945",
"0.5300553",
"0.52429897",
"0.52094793",
"0.5208593",
"0.51889414",
"0.51594347",
"0.5091299",
"0.50741374",
"0.50623083",
"0.50455517",
"0.5042859",
"0.5028692",
"0.5010657",
"0.50098... | 0.5269339 | 8 |
Dispatch all missing methods to lookup calls in rpm spec metadata | def method_missing(method, *args, &block)
# proxy to metadata
if @metadata.has_key?(method)
@metadata[method]
else
super(method, *args, &block)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def method_missing(method_sym, *arguments, &block)\n method = method_sym.to_s\n\n #puts \"%s %s %s\" % [\"---- \", method, \" ----\"]\n #\n if method =~ /^[A-Z]\\d{2}(_\\d{2})?/\n Array(parse(get_spec(method))).join(', ') rescue ''\n elsif respond_to?((/(\\w+)/.match(method))[0])\n ... | [
"0.60486746",
"0.59565043",
"0.59190047",
"0.5854085",
"0.58464044",
"0.57831836",
"0.57711804",
"0.5768847",
"0.5748913",
"0.5738888",
"0.57321435",
"0.57310337",
"0.57282126",
"0.57282126",
"0.5708268",
"0.57005626",
"0.5696965",
"0.56742144",
"0.5672293",
"0.56656915",
"0.... | 0.54340214 | 55 |
Return gem corresponding to spec name/version | def upstream_gem
@gem ||= Polisher::Gem.from_rubygems gem_name, version
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_gem(name, version)\n spec = source_index.find_name(name, version).last\n unless spec and (spec.installation_path rescue nil)\n alert_error \"Could not find gem #{name} (#{version})\"\n raise Gem::GemNotFoundException, \"Could not find gem #{name}, (#{version})\"\n end\n\n return spec... | [
"0.76734984",
"0.7653313",
"0.7438747",
"0.7420011",
"0.7316799",
"0.72767353",
"0.721771",
"0.7059389",
"0.69686896",
"0.695689",
"0.6954675",
"0.6928784",
"0.6902401",
"0.68513376",
"0.682668",
"0.6819575",
"0.67788416",
"0.6767745",
"0.67621356",
"0.67400044",
"0.6722517",... | 0.0 | -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.expand_requirement([greq.split]).all? { |ereq|
tereq = Requirement.new :name => "#{requirement_prefix}(#{gem_dep.name})",
:condition => ereq.first,
:version => ereq.last.to_s
reqs.any? { |req| req.matches?(tereq)}
}
}
end | {
"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 dependencies for which we have no corresponding requirements | def missing_deps_for(gem)
# Comparison by name here assuming if it is in existing spec,
# spec author will have ensured versions are correct for their purposes
gem.deps.select { |dep| requirements_for_gem(dep.name).empty? }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def non_gem_requirements\n @metadata[:requires].nil? ? [] :\n @metadata[:requires].select { |r| !r.gem? }\n end",
"def non_gem_build_requirements\n @metadata[:build_requires].nil? ? [] :\n @metadata[:build_requires].select { |r| !r.gem? }\n end",
"def missing_d... | [
"0.82321525",
"0.79578096",
"0.75243646",
"0.7459049",
"0.7419925",
"0.738641",
"0.7368803",
"0.7304903",
"0.7197358",
"0.71410406",
"0.7112839",
"0.7101651",
"0.7094307",
"0.707949",
"0.7051075",
"0.70484984",
"0.70274633",
"0.6980552",
"0.69775367",
"0.6974392",
"0.69534767... | 0.7832764 | 2 |
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 |
Return all gem requirements _not_ in the specified gem | def extra_gem_requirements(gem)
gem_reqs = gem.deps.collect { |d| requirements_for_gem(d.name) }.flatten
gem_requirements - gem_reqs
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def non_gem_requirements\n @metadata[:requires].nil? ? [] :\n @metadata[:requires].select { |r| !r.gem? }\n end",
"def non_gem_build_requirements\n @metadata[:build_requires].nil? ? [] :\n @metadata[:build_requires].select { |r| !r.gem? }\n end",
"def missing_d... | [
"0.8257661",
"0.7702284",
"0.7477817",
"0.72195125",
"0.721228",
"0.721228",
"0.7163211",
"0.6948373",
"0.69211704",
"0.683421",
"0.675336",
"0.6680801",
"0.6593968",
"0.6494068",
"0.6431585",
"0.64080715",
"0.63658845",
"0.63550377",
"0.6280481",
"0.6278009",
"0.6274777",
... | 0.76191086 | 3 |
Return all gem build requirements _not_ in the specified gem | def extra_gem_build_requirements(gem)
gem_reqs = gem.deps.collect { |d| requirements_for_gem(d.name) }.flatten
gem_build_requirements - gem_reqs
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def non_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... | [
"0.84699225",
"0.80746263",
"0.76144695",
"0.76144695",
"0.75614834",
"0.7425938",
"0.74050725",
"0.73347414",
"0.71328056",
"0.7018714",
"0.68172044",
"0.6742799",
"0.6715131",
"0.6695451",
"0.65683407",
"0.6537445",
"0.65205663",
"0.6455978",
"0.6425074",
"0.6421394",
"0.64... | 0.7995794 | 3 |
Update RPM::Spec metadata to new gem | def update_to(new_source)
update_deps_from(new_source)
update_files_from(new_source)
update_metadata_from(new_source)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_rpm_spec\n puts 'creating rpm.spec'\n File.unlink('rpm.spec') if File.exist?('rpm.spec')\n f = File.open('rpm.spec', 'w')\n f.puts <<EOF\n# DO NOT EDIT -- automatically generated by ./configure\nName: #{@project.id}\nSummary: #{@project.summary}\nVersion: #{@project.version}\nRelea... | [
"0.6417202",
"0.62516254",
"0.61467826",
"0.6140482",
"0.6007314",
"0.60041386",
"0.5968705",
"0.59681314",
"0.5943131",
"0.5902928",
"0.58752054",
"0.5868755",
"0.58646154",
"0.5838072",
"0.5838072",
"0.5820617",
"0.5806395",
"0.5795123",
"0.5768061",
"0.5758052",
"0.5736488... | 0.0 | -1 |
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[:build_requires] =
non_gem_build_requirements +
extra_gem_build_requirements(new_source) +
new_source.dev_deps.select { |r| !excludes_dev_dep?(r.name) }
.collect { |r| RPM::Requirement.from_gem_dep(r, true) }.flatten
end | {
"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 = spec_files.any? { |sf|
gem_file.gsub(sf,'') != gem_file
}
to_add.delete(gem_file)
to_add << gem_file.rpmize if !has_file &&
!Gem.ignorable_file?(gem_file)
}
}
@metadata[:new_files] = to_add.select { |f| !Gem.doc_file?(f) }
@metadata[:new_docs] = to_add - @metadata[:new_files]
end | {
"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[:version]}-1
- Update to version #{new_source.version}
EOS
@metadata[:changelog_entries] ||= []
@metadata[:changelog_entries].unshift changelog_entry.rstrip
end | {
"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 |
Return properly formatted rpmspec as string | def to_string
contents = @metadata[:contents]
# replace version / release
contents.gsub!(SPEC_VERSION_MATCHER, "Version: #{@metadata[:version]}")
contents.gsub!(SPEC_RELEASE_MATCHER, "Release: #{@metadata[:release]}")
# add changelog entry
cp = contents.index SPEC_CHANGELOG_MATCHER
cpn = contents.index "\n", cp
contents = contents[0...cpn+1] +
@metadata[:changelog_entries].join("\n\n")
# update requires/build requires
rp = contents.index SPEC_REQUIRES_MATCHER
brp = contents.index SPEC_BUILD_REQUIRES_MATCHER
tp = rp < brp ? rp : brp
pp = contents.index SPEC_SUBPACKAGE_MATCHER
pp = -1 if pp.nil?
lrp = contents.rindex SPEC_REQUIRES_MATCHER, pp
lbrp = contents.rindex SPEC_BUILD_REQUIRES_MATCHER, pp
ltp = lrp > lbrp ? lrp : lbrp
ltpn = contents.index "\n", ltp
contents.slice!(tp...ltpn)
contents.insert tp,
(@metadata[:requires].collect { |r| "Requires: #{r.str}" } +
@metadata[:build_requires].collect { |r| "BuildRequires: #{r.str}" }).join("\n")
# add new files
fp = contents.index SPEC_FILES_MATCHER
lfp = contents.index SPEC_SUBPKG_FILES_MATCHER, fp + 1
lfp = contents.index SPEC_CHANGELOG_MATCHER if lfp.nil?
contents.insert lfp - 1, @metadata[:new_files].join("\n") + "\n"
# add new doc files
fp = contents.index SPEC_DOC_FILES_MATCHER
fp = contents.index SPEC_FILES_MATCHER if fp.nil?
lfp = contents.index SPEC_SUBPKG_FILES_MATCHER, fp + 1
lfp = contents.index SPEC_CHANGELOG_MATCHER if lfp.nil?
contents.insert lfp - 1, @metadata[:new_docs].join("\n") + "\n"
# return new contents
contents
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_s\n out = []\n\n groups = spec_groups\n\n add_PATH out, groups.delete(Gem::Resolver::VendorSpecification) { [] }\n\n add_GIT out, groups.delete(Gem::Resolver::GitSpecification) { [] }\n\n add_GEM out, groups\n\n add_PLATFORMS out\n\n add_DEPENDENCIES out\n\n out.join \"\\n\"\n end",... | [
"0.7081652",
"0.6540041",
"0.6072871",
"0.60563105",
"0.59601367",
"0.59242296",
"0.5898537",
"0.5874785",
"0.5853572",
"0.5834908",
"0.57602286",
"0.5704995",
"0.5698129",
"0.56877786",
"0.56440413",
"0.56112725",
"0.55656993",
"0.55377674",
"0.55309975",
"0.55268234",
"0.55... | 0.5880006 | 7 |
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 that differ and their respective differences | 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?
diff[d.name] = {:spec => nil,
:upstream => d.requirement.to_s}
elsif !spec_reqs.any? { |req| req.matches?(d) } ||
!self.has_all_requirements_for?(d)
diff[d.name] = {:spec => spec_reqs_specifier,
:upstream => d.requirement.to_s}
elsif !diff.has_key?(d.name)
same[d.name] = {:spec => spec_reqs_specifier,
:upstream => d.requirement.to_s }
end
end
@metadata[:requires].each do |req|
next unless req.gem?
upstream_dep = upstream_source.deps.find { |d| d.name == req.gem_name }
if upstream_dep.nil?
diff[req.gem_name] = {:spec => req.specifier,
:upstream => nil}
elsif !req.matches?(upstream_dep)
diff[req.gem_name] = {:spec => req.specifier,
:upstream => upstream_dep.requirement.to_s }
elsif !diff.has_key?(req.gem_name)
same[req.gem_name] = {:spec => req.specifier,
:upstream => upstream_dep.requirement.to_s }
end
end unless @metadata[:requires].nil?
{:same => same, :diff => diff}
end | {
"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 |
Strips out all embedded information from the image | def strip
manipulate! do |img|
img.strip
img = yield(img) if block_given?
img
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strip\n write_opts[:strip] = true\n get_image\n end",
"def strip_exif_metadata\r\n manipulate! do |img|\r\n img.strip\r\n img = yield(img) if block_given?\r\n img\r\n end\r\n end",
"def strip\n manipulate! do |image|\n @_strip = true\n image\n end\... | [
"0.69986516",
"0.6768036",
"0.67400396",
"0.647024",
"0.644995",
"0.61613864",
"0.61322",
"0.6118278",
"0.6118278",
"0.6078184",
"0.6046694",
"0.6046694",
"0.5960892",
"0.5846377",
"0.58142626",
"0.57525516",
"0.5724875",
"0.56473404",
"0.56445885",
"0.5624613",
"0.55714035",... | 0.60906154 | 10 |
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 |
set the Interlace of the image plane/basic | def interlace(type)
manipulate! do |img|
img.interlace(type.to_s)
img = yield(img) if block_given?
img
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def interlace\n manipulate! do |img|\n img.strip\n img.combine_options do |c|\n c.quality \"80\"\n c.depth \"8\"\n c.interlace \"plane\"\n end\n img\n end\n end",
"def interlaced=(bool)\n ::GD2::GD2FFI.send(:gdImageInterlace, image_ptr, bool ? 1 : 0)\n end"... | [
"0.6643877",
"0.6283325",
"0.5662474",
"0.56427205",
"0.5585171",
"0.55764073",
"0.5445031",
"0.5386039",
"0.52994514",
"0.52922416",
"0.5249821",
"0.51744294",
"0.51572925",
"0.5083133",
"0.4996964",
"0.49648672",
"0.4926651",
"0.49249166",
"0.49149182",
"0.4905604",
"0.4899... | 0.48901814 | 24 |
Tiny gaussian blur to optimize the size | def gaussian_blur(radius)
manipulate! do |img|
img.gaussian_blur(radius.to_s)
img = yield(img) if block_given?
img
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gaussian_blur(*args)\n output = self.apply_filter(CIFilter.gaussian_blur(*args))\n return UIImage.imageWithCIImage(output, scale:self.scale, orientation:self.imageOrientation)\n end",
"def gaussian_blur(params = {})\n params[:name] ||= @pictureName.gsub('.png', 'Gauss.png')\n params[:save] ||= @... | [
"0.751358",
"0.7302044",
"0.72393376",
"0.6892252",
"0.64835423",
"0.6427895",
"0.63179076",
"0.63013244",
"0.61639744",
"0.6075544",
"0.6041545",
"0.59765434",
"0.5965929",
"0.5853831",
"0.5837533",
"0.5770856",
"0.5758252",
"0.5753721",
"0.5753721",
"0.5745598",
"0.5712398"... | 0.7168541 | 3 |
Is just ownerreceiver comunication, so the receiver is who is not the caller (current_owner). | def receivers_for(wui)
if wui.user == current_owner
wui.users.map(&:id)
else
[wui.user_id]
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def opposite_member(user)\n user == sender ? receiver : sender\n end",
"def owner\n class << receiver; self; end\n end",
"def not_current_person(message)\n message.sender == current_person ? message.recipient : message.sender\n end",
"def owned?\n @owner == caller\n end",
"def r... | [
"0.70374143",
"0.69292724",
"0.6893946",
"0.67730814",
"0.6766993",
"0.6723414",
"0.66597974",
"0.6653652",
"0.6572377",
"0.6539664",
"0.64949304",
"0.6439924",
"0.64100397",
"0.63993806",
"0.6394945",
"0.639408",
"0.6339574",
"0.6314801",
"0.6305856",
"0.6284311",
"0.6283933... | 0.0 | -1 |
Download the data from DEHEMS API | def index
@message = "success"
if Competition.has_started?
time_now = Time.new
#time_now = Time.parse("2011-02-14 00:01:00")
#Download the weekly data and calculate points at the end of 7 day period.
date_now = Date.parse(time_now.strftime('%Y/%m/%d'))
competition_days = (date_now - Competition.get_start_date);
week = competition_days/7
pointDataTest = MemberPoint.find(:first, :order => "week DESC")
pointDataTestFlag = (pointDataTest == nil or (time_now.day != pointDataTest.created_at.day and time_now > pointDataTest.created_at))
if competition_days % 7 == 0 and pointDataTestFlag and week < 13
#Get all users.
members = Member.find(:all)
#Download data daily data for each user from yesterday if not yet downloaded.
for member in members
timestamp = Time.new.to_i
#Download the stream id if not done yet.
if member.stream_id == nil or member.stream_id == ""
hashCode = generateHashCode(timestamp,member.mac)
params = {
:ap => DEHEMS::API_ID,
:ts => timestamp,
:householdId => member.mac,
:dataStreamType => "AggregateElectricity",
:hashCode => hashCode
}
res = Net::HTTP.post_form(URI.parse("#{DEHEMS::API_SERVER_ADDRESS}getDataStreamListJSON"),params)
result = JSON.parse(res.body)
member.stream_id = result["DataStreamList"][0]["StreamId"]
member.save
end
#Download the data for the last 7 days.
hashCode = generateHashCode(timestamp,member.stream_id)
params = {
:ap => DEHEMS::API_ID,
:ts => timestamp,
:streamId => member.stream_id,
:resolution => "Day",
:numberOfPoints => "7",
:cum => "true",
:endTime => time_now.to_i,
:includeCurrentPeriod => "false",
:hashCode => hashCode
}
res = Net::HTTP.post_form(URI.parse("#{DEHEMS::API_SERVER_ADDRESS}getDataStreamJSON"),params)
result = JSON.parse(res.body)
saving_day = 7
for kwhs in result["DataStream"]
data = DailyData.new
data.member_id = member.id
data.total_kwh = kwhs.to_f
data.sample_time = (time_now - saving_day.day)
begin
data.save
end
saving_day-=1
end
end
#Calculate and save points.
teams = Team.find(:all)
team_totals = {}
for team in teams
member_totals = {}
members = Member.find(:all, :conditions => "team_id=#{team.id}")
for member in members
#Check that we have no zero readings the last 7 days.
zeroReading = DailyData.find(:all, :conditions => "member_id=#{member.id} and total_kwh<0.1 and sample_time<='#{(date_now - 1.day)}' and sample_time>='#{(date_now - 7.day)}'", :order => "sample_time DESC")
if zeroReading and zeroReading.size > 3
point = MemberPoint.new
point.week = week
point.member_id = member.id
point.points = 0
begin
point.save
end
else
#Calculate total usage and save in the hash for week 1 and saving after that.
if week == 1
weekly_average = DailyData.average("total_kwh", :conditions => "member_id=#{member.id} and total_kwh>0.1 and sample_time<='#{(date_now - 1.day)}' and sample_time>='#{(date_now - 7.day)}'")
member_totals[member.id] = weekly_average.to_f
else
preZeroReading = DailyData.find(:all, :conditions => "member_id=#{member.id} and total_kwh<0.1 and sample_time<='#{(date_now - 8.day)}' and sample_time>='#{(date_now - 15.day)}'", :order => "sample_time DESC")
if preZeroReading and preZeroReading.size > 3
point = MemberPoint.new
point.week = week
point.member_id = member.id
point.points = 0
begin
point.save
end
else
weekly_average = DailyData.average("total_kwh", :conditions => "member_id=#{member.id} and total_kwh>0.1 and sample_time<='#{(date_now - 1.day)}' and sample_time>='#{(date_now - 7.day)}'")
previous_weekly_average = DailyData.average("total_kwh", :conditions => "member_id=#{member.id} and total_kwh>0.1 and sample_time<='#{(date_now - 8.day)}' and sample_time>='#{(date_now - 15.day)}'")
difference = previous_weekly_average.to_f-weekly_average.to_f
if difference == 0 and previous_weekly_average.to_f-weekly_average.to_f == 0
member_totals[member.id] = 0
else
member_totals[member.id] = difference/previous_weekly_average.to_f
end
end
end
end
end
member_totals_sorted = member_totals.sort {|a,b| a[1]<=>b[1]}
if week > 1
member_totals_sorted = member_totals_sorted.reverse
end
member_count = 0
team_total = 0
points = CT::POINT_POOL_SIZE
for value in member_totals_sorted
#Write here the functionality to save the member points.
point = MemberPoint.new
point.week = week
point.member_id = value[0]
point.points = points
begin
point.save
end
points-=1
#Add to the team total.
member_count+=1
team_total+=value[1]
end
#Calculate the team average and add into the hash.
if member_count > 0
team_totals[team.id] = team_total/member_count
else
team_totals[team.id] = 100000
end
end
#Do not save team points from week 1 since there is not yet a comparison week data.
if week > 1
team_totals_sorted = team_totals.sort {|a,b| a[1]<=>b[1]}
team_totals_sorted = team_totals_sorted.reverse
points = CT::TEAM_POINT_POOL_SIZE
for value in team_totals_sorted
point = TeamPoint.new
point.week = week
point.team_id = value[0]
point.points = points
begin
point.save
end
points-=1
end
end
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def download\n @data = HeyDan::Helper.get_data_from_url(HeyDan.cdn + '/' + dataset_file_name)\n end",
"def download\n api_url = build_url\n RestClient::Request.execute(method: 'GET', url: api_url, open_timeout: 20)\n end",
"def download_data\n # Custom downloader functionality impleme... | [
"0.71139914",
"0.7076209",
"0.68539864",
"0.6693679",
"0.6669677",
"0.66208494",
"0.64121443",
"0.6406143",
"0.6350602",
"0.6311593",
"0.6275959",
"0.62386346",
"0.61998117",
"0.619286",
"0.6176183",
"0.61671025",
"0.60972893",
"0.609324",
"0.60910213",
"0.6090702",
"0.606786... | 0.0 | -1 |
Time stamp for file task. | def timestamp
if File.exist?(name)
File.mtime(name.to_s)
else
Rake::EARLY
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def file_datetime\n @file_datetime\n end",
"def timestamp\n @file_mtime ||\n if _exist?(name)\n @file_mtime = _mtime(name.to_s)\n else\n Rake::LATE\n end\n end",
"def timestamp\n begin\n File.mtime(name)\n rescue Errno::ENOENT\n ... | [
"0.7291897",
"0.72891366",
"0.71487504",
"0.6965426",
"0.6796802",
"0.6770877",
"0.6770877",
"0.67685777",
"0.6755231",
"0.67250377",
"0.67080355",
"0.6660463",
"0.66385156",
"0.6636782",
"0.66118956",
"0.66118956",
"0.66098726",
"0.6599067",
"0.6599067",
"0.65975577",
"0.658... | 0.7024237 | 3 |
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 |
Time stamp for file creation task. This time stamp is earlier than any other time stamp. | def timestamp
Rake::EARLY
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def record_creation_timestamp(path, timestamp)\n # Hook method: Linux filesystems doesn't store creation datetime\n end",
"def creation_date\n stat.ctime\n end",
"def timestamp\n @file_mtime ||\n if _exist?(name)\n @file_mtime = _mtime(name.to_s)\n else\n ... | [
"0.7410935",
"0.7193143",
"0.71311677",
"0.712116",
"0.70939165",
"0.70426285",
"0.7032256",
"0.6988432",
"0.6909367",
"0.6891203",
"0.68147093",
"0.6778458",
"0.676435",
"0.6633516",
"0.65573084",
"0.655106",
"0.6550536",
"0.65398204",
"0.65398204",
"0.65373725",
"0.65351015... | 0.0 | -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 |
method for user staus | def user_status(activated_date)
if activated_date.blank?
return "Inactive"
else
return "Active"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def user; end",
"def user; end",
"def set_user; end",
"def user_stray\n if !logged_in? || @user == nil\n flash[:alert] = \"You have been logged out of your session. Please log back in to continue.\"\n redirect \"/\"\n elsif @user.id != current_user.id\n flash[:alert] = \"You do not have ... | [
"0.6703043",
"0.6703043",
"0.65389574",
"0.64703035",
"0.6433849",
"0.6419475",
"0.64149183",
"0.6406766",
"0.63905185",
"0.63445514",
"0.61950576",
"0.6053031",
"0.60096693",
"0.59791124",
"0.5974468",
"0.5974468",
"0.5971042",
"0.59633005",
"0.59569865",
"0.59547067",
"0.59... | 0.0 | -1 |
Payload format per rubocop:disable Metrics/MethodLength | def build_payload(issuer, push_notification_url, uuid)
iat = Time.zone.now.to_i
{
iss: Rails.application.routes.url_helpers.root_url,
iat: iat,
exp: iat + 12.hours.to_i,
jti: jti(iat),
aud: push_notification_url,
events: {
EVENT_TYPE_URI => {
subject: {
subject_type: 'iss-sub',
iss: issuer,
sub: uuid,
},
},
},
}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def payload_data\n case @config.format\n when :json\n @payload.to_json\n when :yaml\n @payload.to_yaml\n else\n @payload.to_hash\n end\n end",
"def payload; end",
"def payload; end",
"def payload_format\n @header.payload_format\n end",
"def format_re... | [
"0.71444917",
"0.7028675",
"0.7028675",
"0.6853001",
"0.6826508",
"0.6826508",
"0.65368205",
"0.6445601",
"0.6445601",
"0.6422024",
"0.640341",
"0.63744766",
"0.6327484",
"0.6321915",
"0.63196987",
"0.6318331",
"0.63133407",
"0.62974715",
"0.62884766",
"0.6277859",
"0.6273106... | 0.5537014 | 99 |
Optionally pass in a different :col_sep as an optional hash param. The default :col_sep is tab. | def initialize(filepath, col_sep: "\t")
@filepath = filepath
@col_sep = col_sep
@file_handle = File.open(filepath)
@headers = @file_handle.gets.chomp!.split(col_sep, -1).map(&:downcase).map(&:to_sym)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def csvColSepChar()\n c = getConf(:csvColSep)\n case(c)\n when :comma, nil ; return \",\" ;\n when :tab ; return \"\\t\" ;\n when :space ; return \" \" ;\n else\n if(c.is_a?(String)) then\n return c ;\n else\n raise \"unknown CSV column separator: '#{c}'\" ;\n end\n ... | [
"0.6970018",
"0.6388686",
"0.62479013",
"0.6184085",
"0.6139423",
"0.5829134",
"0.5769928",
"0.5621162",
"0.55923843",
"0.55665153",
"0.5524647",
"0.5524647",
"0.5511199",
"0.54739165",
"0.5443303",
"0.5441824",
"0.5419624",
"0.5381819",
"0.5347192",
"0.5283784",
"0.5271689",... | 0.52619666 | 21 |
Yield a row hash to the block with downcased, symbolized keys. | def each(&block)
file_handle.each do |line|
yield headers.zip(line.chomp!.split(col_sep, -1)).to_h
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def symbolize_row_keys(row)\n out = {} # move to a real hash!\n row.each do |key, value|\n out[key.to_sym] = value.respond_to?(:wrapper) ? value.wrapper : value\n end\n out\n end",
"def transform_keys(&block); end",
"def transform_keys!(&block); end",
"def original_k... | [
"0.6754146",
"0.6410834",
"0.6283506",
"0.59390783",
"0.586868",
"0.57941985",
"0.5742961",
"0.5698274",
"0.5687866",
"0.5680889",
"0.5680785",
"0.5652306",
"0.56265527",
"0.5626004",
"0.5620631",
"0.5613742",
"0.5602242",
"0.55947286",
"0.5590994",
"0.5589195",
"0.5585393",
... | 0.0 | -1 |
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 |
Rewind the file handle to line 2 (skipping the header row). | def rewind
file_handle.rewind
file_handle.gets # skip past header
nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def almost_rewind(f)\n f.seek(2)\nend",
"def rewind_line(file, line)\n until file_at_starting_position?(file, line)\n line_rewind_one_char(file, line) do |rewound_line|\n return line if newline?(rewound_line)\n line = rewound_line\n end\n end\n\n line\n end",
"def rewind(f)\n... | [
"0.7122194",
"0.6772347",
"0.674095",
"0.6737939",
"0.6722515",
"0.6718901",
"0.648401",
"0.64477986",
"0.636384",
"0.6309385",
"0.62845004",
"0.62845004",
"0.62845004",
"0.62845004",
"0.6274965",
"0.6274689",
"0.6261443",
"0.6228416",
"0.6228416",
"0.6186934",
"0.6186934",
... | 0.67569107 | 2 |
prepends a new node of data: value | def prepend(value)
new_node = Node.new(value)
new_node.next = @node
@node = new_node
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def value=(value)\n self.remove_children :value\n if value\n self << (v = XMPPNode.new(:value))\n v.namespace = self.namespace\n v << value\n end\n end",
"def prepend(value)\n\t\t@head.next_node = Node.new(value, @head.next_node)\n\tend",
"def ... | [
"0.63338304",
"0.6309103",
"0.6272431",
"0.62654305",
"0.62636596",
"0.6235239",
"0.6182171",
"0.6177406",
"0.61503357",
"0.61281246",
"0.6119337",
"0.607562",
"0.60684526",
"0.6062957",
"0.60415804",
"0.6036181",
"0.60329086",
"0.6027658",
"0.6014026",
"0.5995853",
"0.599445... | 0.61406547 | 9 |
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 |
these methods are basically for testing purpose | def size
count = 1
node = @node
while node.next
count += 1
node = node.next
end
count
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def private; end",
"def spec; end",
"def spec; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def testing\n # ...\n end",
"def probers; end",
"def weber; end",
"def who_we_are\r\n end",
"def schubert; end",
"def setup; end",
"def setup; end... | [
"0.72640234",
"0.68645316",
"0.68645316",
"0.6856354",
"0.6856354",
"0.6856354",
"0.6856354",
"0.6707263",
"0.6458941",
"0.63931346",
"0.63524604",
"0.63050556",
"0.6278484",
"0.6278484",
"0.6278484",
"0.6278484",
"0.6278484",
"0.6278484",
"0.6278484",
"0.6278484",
"0.6278484... | 0.0 | -1 |
Execute access_denied unless current_user.admin == true | def admin_in!
access_denied! unless current_user.admin?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def admin_access_required\n access_denied unless admin?\n end",
"def admin_access_required\n access_denied unless admin?\n end",
"def admin_access_required\n access_denied unless admin?\n end",
"def must_be_admin!\n access_denied! unless current_admin?\n end",
"def admin_req... | [
"0.88222015",
"0.88222015",
"0.88222015",
"0.866782",
"0.8549728",
"0.8394882",
"0.83055407",
"0.8254307",
"0.82259953",
"0.8211217",
"0.81752133",
"0.81743896",
"0.81421274",
"0.812611",
"0.80598855",
"0.8031546",
"0.80249685",
"0.8015841",
"0.80073714",
"0.797562",
"0.79746... | 0.8367653 | 6 |
Create callback with class error messages | def write_errors(obj, scope: false)
obj.errors.map { |e| "#{t_field(e.attribute, scope || obj.class.table_name.singularize)} #{e.message}" }.join(', ')
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def error(callback)\n\t\t@error_callback = callback\n\t\treturn self\n\tend",
"def on_error(msg)\n end",
"def on_error(&callback)\n @on_error = callback\n end",
"def on_error(&callback)\n @err_cb, @err_cb_overridden = callback, true\n end",
"def on_error(&callback)\n @err_cb, @err_c... | [
"0.6899007",
"0.6537324",
"0.6487436",
"0.6447234",
"0.64094627",
"0.62947094",
"0.6255419",
"0.62044114",
"0.61081165",
"0.6088684",
"0.6060702",
"0.6060702",
"0.6060702",
"0.6060702",
"0.6060702",
"0.6060702",
"0.6060702",
"0.6060429",
"0.6024313",
"0.5989172",
"0.59728223"... | 0.0 | -1 |
Set locale from `params[:locale]`. If params[:locale] is unset or is not available, the method set the default locale | def set_locale
I18n.locale = params[:locale] || I18n.default_locale
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_locale\n I18n.locale = params[:locale] unless params[:locale].blank?\n end",
"def set_locale\n I18n.locale = params[:locale] unless params[:locale].blank?\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\n I18n.locale = pa... | [
"0.90261346",
"0.8853055",
"0.88080835",
"0.88080835",
"0.88080835",
"0.88080835",
"0.8760363",
"0.8751386",
"0.87031233",
"0.87031233",
"0.8619787",
"0.8600404",
"0.8600404",
"0.857675",
"0.8511656",
"0.84921473",
"0.8465301",
"0.84501964",
"0.8448386",
"0.84357655",
"0.8408... | 0.86990297 | 22 |
Render 404 page and stop the work | def record_not_found!
render partial: 'errors/404', status: 404 && return
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def render_404\n render 'web/404', status: 404\n end",
"def render_404 \n render :file => \"/public/404.html\", :status => 404,:layout => false\n end",
"def render_404 \n render :file => \"/public/404.html\", :status => 404,:layout => false\n end",
"def render_404 \n rend... | [
"0.82812035",
"0.8150975",
"0.8150975",
"0.8150975",
"0.8150975",
"0.8150975",
"0.8150975",
"0.81476694",
"0.81383455",
"0.8133152",
"0.81013256",
"0.80521107",
"0.80484396",
"0.80484396",
"0.80455464",
"0.8045193",
"0.80438125",
"0.80413413",
"0.8030803",
"0.80255365",
"0.79... | 0.7904308 | 32 |
Select the layout name based on request type: xhr request or other | def set_layout
request.xhr? ? 'empty' : 'application'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def determine_layout\n request.xhr? ? 'ajax' : 'application'\n end",
"def determine_layout\n request.xhr? ? 'ajax' : common_layout\n end",
"def choose_layout\n request.xhr? ? 'modal' : 'front'\n end",
"def choose_layout\n request.xhr? ? 'modal' : 'front'\n end",
"def default_layout_for_... | [
"0.7827571",
"0.78203046",
"0.76132405",
"0.76132405",
"0.72335607",
"0.7197372",
"0.70573777",
"0.701215",
"0.6979882",
"0.69146526",
"0.6912901",
"0.68894225",
"0.6831117",
"0.6817096",
"0.6805872",
"0.6720451",
"0.6703917",
"0.6666527",
"0.66252035",
"0.65542567",
"0.65403... | 0.6972863 | 9 |
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 |
Render message and stop the work | def destroy_restricted!
flash.now[:error] = "Non è possibile cancellare questo record poichè è collegato ad altre informazioni!"
respond_to do |format|
format.html { render partial: 'errors/401', status: 401 && return }
format.turbo_stream {
render turbo_stream: [ turbo_stream.replace(:flashes, partial: "flashes") ]
}
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def terminate_message\n self.active = false\n self.pause = false\n @contents_showing = false\n $game_temp.message_proc&.call\n reset_game_temp_message_info\n dispose_sub_elements\n reset_overwrites\n @auto_skip = false\n end",
"def hide_message\n # todo - mark the me... | [
"0.68938565",
"0.66594577",
"0.61872447",
"0.61101776",
"0.6047031",
"0.59801894",
"0.59251016",
"0.58857423",
"0.5863943",
"0.5844966",
"0.5827079",
"0.5778582",
"0.5774425",
"0.5768372",
"0.5759928",
"0.57547563",
"0.5747987",
"0.5745459",
"0.57321507",
"0.5707474",
"0.5707... | 0.0 | -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_label).try(:capitalize)
else
I18n.t(field_label, default: field_label).try(:capitalize)
end
end | {
"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 |
GET /staff_workers GET /staff_workers.json | def index
@q = StaffWorker.eager_load(:subdivision => :company).ransack(params[:q])
@staff_workers = @q.result(distinct: true)
# @staff_workers = StaffWorker.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @worker = Worker.find(params[:id])\n\n render json: @worker\n end",
"def index\n @workers = Worker.all\n end",
"def index\n @workers = Worker.all\n end",
"def index\n @workers = Worker.all\n end",
"def index\n @workers = Worker.all\n end",
"def workers_all\n @... | [
"0.6781652",
"0.6774574",
"0.6774574",
"0.6774574",
"0.6774574",
"0.6637402",
"0.6595079",
"0.6564263",
"0.63247156",
"0.6271591",
"0.6258578",
"0.62555206",
"0.61848223",
"0.61721224",
"0.61568123",
"0.6123516",
"0.6018543",
"0.60161734",
"0.6005567",
"0.59264517",
"0.590898... | 0.60945374 | 16 |
GET /staff_workers/1 GET /staff_workers/1.json | def show
@noise_indicators = NoiseIndicator.where(staff_worker_id: @staff_worker.id)
@total_vibration_indicators = TotalVibrationIndicator.where(staff_worker_id: @staff_worker.id)
@local_vib_f_indicators = LocalVibFIndicator.where(staff_worker_id: @staff_worker.id)
@local_vib_s_indicators = LocalVibSIndicator.where(staff_worker_id: @staff_worker.id)
@working_operations = WorkingOperation.where(staff_worker_id: @staff_worker.id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @worker = Worker.find(params[:id])\n\n render json: @worker\n end",
"def show\n @worker = Worker.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @worker }\n end\n end",
"def show\n\tLogger.log current_user\n ... | [
"0.7242521",
"0.70501035",
"0.7044874",
"0.6651676",
"0.6651676",
"0.6651676",
"0.6651676",
"0.6484898",
"0.6458341",
"0.63316524",
"0.6321517",
"0.6203339",
"0.61982495",
"0.6193231",
"0.6171642",
"0.616136",
"0.61609364",
"0.6154037",
"0.61500394",
"0.6123838",
"0.6112934",... | 0.0 | -1 |
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 { render :new }
format.json { render json: @staff_worker.errors, status: :unprocessable_entity }
end
end
end | {
"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 json: @staff_worker.errors, status: :unprocessable_entity }
end
end
end | {
"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 |
Use callbacks to share common setup or constraints between actions. | def set_staff_worker
@staff_worker = StaffWorker.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576"... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def staff_worker_params
params.require(:staff_worker).permit(:name, :surname, :patronymic, :number_id, :subdivision_id, :birthday, :position, :duration_work, :labor_activity_type, :labor_activity_category, :duration_one_shift, :workplace_id, :work_in_workplace, :description_operation,:additional_workplace_id, :additional_work_in_workplace, :additional_description_operation)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.6980629",
"0.67819995",
"0.67467666",
"0.67419875",
"0.67347664",
"0.65928614",
"0.6504013",
"0.6498014",
"0.64819515",
"0.64797956",
"0.64562726",
"0.64400834",
"0.6380117",
"0.6377456",
"0.63656694",
"0.6320543",
"0.63002014",
"0.62997127",
"0.629425",
"0.6293866",
"0.62... | 0.0 | -1 |
=begin For the self manymany referential =end | def base_item
if self.is_base_item == true
return self
elsif self.is_base_item == false
return Item.find_by_id self.base_item_id
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def child_relation; end",
"def each_ancestor # :nodoc:\n end",
"def _parent; end",
"def referenced; end",
"def parentage\n get_parents unless @already_fetched_parents\n @already_fetched_parents = true\n super\n end",
"def references; end",
"def references; end",
"def parents; end",
"def ... | [
"0.6533092",
"0.61359286",
"0.61267114",
"0.6065107",
"0.604436",
"0.60283834",
"0.60283834",
"0.5982057",
"0.5966937",
"0.5935516",
"0.5900984",
"0.58974105",
"0.5852385",
"0.5823984",
"0.5809252",
"0.57752043",
"0.5755206",
"0.57387555",
"0.5735133",
"0.5729505",
"0.5719465... | 0.0 | -1 |
=begin Create item on behalf of supplier =end | def embed_property_value_list( property_value_list )
count = 1
property_value_list.each do |property_value_pair|
PropertyValue.create(:item_id => self.id,
:property_id => property_value_pair[:property_id],
:value_id => property_value_pair[:value_id],
:position => count)
count += 1
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def giveItem\n toLocation = Company.where(name: params[:recepCompany]).first.locations.where(address: params[:recepLocation]).first\n location = current_company.locations.where(id: params[:locationId]).first\n if(location.is_supplier === true)\n updatedItem = location.items.where(name: params[:name])... | [
"0.66638094",
"0.66368604",
"0.66206837",
"0.66116977",
"0.66075104",
"0.65427965",
"0.6456529",
"0.64012474",
"0.63829136",
"0.6358813",
"0.6341278",
"0.63310146",
"0.6327429",
"0.6304913",
"0.62924355",
"0.6240238",
"0.6231806",
"0.62075824",
"0.61774576",
"0.6152931",
"0.6... | 0.0 | -1 |
=begin Create VariantItem on behalf of supplier =end | def has_similar_property_value_list?( property_value_list )
property_value_list.each do |property_value_pair|
if self.property_values.where(:property_id => property_value_pair[:property_id],
:value_id => property_value_pair[:value_id]).count == 0
next
else
return true
end
end
return false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_product_for(line_item)\n default_tax_category = TaxCategory.find_by_name(\"default\")\n product = Product.create(:name => line_item.title, \n :master_price => line_item.price, \n :description => line_item.title,\n ... | [
"0.6767069",
"0.6526714",
"0.62981725",
"0.62915397",
"0.621764",
"0.6182462",
"0.6056527",
"0.60560554",
"0.60164213",
"0.6016307",
"0.59834594",
"0.59641135",
"0.59497684",
"0.5941127",
"0.5935022",
"0.5932891",
"0.59122676",
"0.59089243",
"0.5899165",
"0.5873545",
"0.58707... | 0.0 | -1 |
GET /positives GET /positives.json | def index
@positives = Positive.all
@positives_json= Positive.all.map(&:lonlat).as_json
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @objectives = @goal.objectives.all \n render json: @objectives \n end",
"def index\n @pledges = Pledge.where('user_id = ?', current_user.id)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @pledges }\n end\n end",
"... | [
"0.61698145",
"0.60967976",
"0.6082163",
"0.6053662",
"0.60219127",
"0.60008067",
"0.5986967",
"0.59649324",
"0.5929165",
"0.5915321",
"0.58977175",
"0.58969665",
"0.5872008",
"0.5845244",
"0.58355683",
"0.5829753",
"0.5821015",
"0.5807743",
"0.5800085",
"0.57996845",
"0.5785... | 0.58157367 | 17 |
GET /positives/1 GET /positives/1.json | def show
positive = Positive.find(params[:id])
@longlat = positive.lonlat
@latlong= positive.lonlat
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @goal = Goal.find(params[:id])\n render json: @goal\n end",
"def index\n @objectives = @goal.objectives.all \n render json: @objectives \n end",
"def show\n @possess = Possess.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n ... | [
"0.60460806",
"0.6027194",
"0.59960485",
"0.5854903",
"0.5793259",
"0.5793259",
"0.5793259",
"0.5793259",
"0.57712674",
"0.57702506",
"0.5767592",
"0.5766159",
"0.57611954",
"0.575028",
"0.5738527",
"0.57329327",
"0.57209355",
"0.5709881",
"0.569061",
"0.56850094",
"0.5677817... | 0.0 | -1 |
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 :new }
format.json { render json: @positive.errors, status: :unprocessable_entity }
end
end
end | {
"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 |
PATCH/PUT /positives/1 PATCH/PUT /positives/1.json | def update
respond_to do |format|
if @positive.update(positive_params)
format.html { redirect_to @positive, notice: 'Positive was successfully updated.' }
format.json { render :show, status: :ok, location: @positive }
else
format.html { render :edit }
format.json { render json: @positive.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def patch\n headers = {\"If-Match\" => @version}\n response = @context.request :patch, \"#{@path}/#{@id}\", @data.to_json, headers\n @version += 1\n response\n # 'X-HTTP-Method-Override' => 'PATCH'\n end",
"def update!(params)\n res = @client.put(path, nil, params, \"Content-T... | [
"0.6472094",
"0.6395662",
"0.63436735",
"0.6304185",
"0.6289524",
"0.6208121",
"0.61920184",
"0.6176594",
"0.6126691",
"0.6112557",
"0.6079626",
"0.6057717",
"0.6056401",
"0.6056401",
"0.6046886",
"0.6027701",
"0.6007427",
"0.60069764",
"0.59972394",
"0.598905",
"0.59439665",... | 0.6262073 | 5 |
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 |
Use callbacks to share common setup or constraints between actions. | def set_positive
@positive = Positive.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163927",
"0.6046165",
"0.59465253",
"0.59167755",
"0.58904207",
"0.58346355",
"0.577713",
"0.5703502",
"0.5703502",
"0.56531286",
"0.56215113",
"0.54224145",
"0.5410795",
"0.5410795",
"0.5410795",
"0.53924775",
"0.5379919",
"0.53580743",
"0.53401667",
"0.53397506",
"0.533... | 0.0 | -1 |
Only allow a list of trusted parameters through. | def positive_params
params.require(:positive).permit(:name, :lat, :long, :lonlat)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allowed_params\n ALLOWED_PARAMS\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def parameters_list_params\n params.require(:parameters_list).permit(:name, :description, :is_user_specific)\n end",
"def param_whitelist\n [:role, :title]\... | [
"0.69497335",
"0.6812623",
"0.6803639",
"0.6795365",
"0.67448795",
"0.67399913",
"0.6526815",
"0.6518771",
"0.64931697",
"0.6430388",
"0.6430388",
"0.6430388",
"0.63983387",
"0.6356042",
"0.63535863",
"0.63464934",
"0.63444513",
"0.6337208",
"0.6326454",
"0.6326454",
"0.63264... | 0.0 | -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 |
For level 2 returns 25 | def max_number_of_a_level(level)
4 * level * level + 4 * level + 1
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def value\n return 15*level\n end",
"def value\n return 3*level\n end",
"def desired_xp\n return (200 * level * (level + 1)).to_i\n end",
"def get_xp\n return 3 * level\n end",
"def total_exp_level\n lvl = self.lvl\n return (100 * (1 - @@exp_mul ** (lvl - 1)) / (1 - @@exp_mul))\n en... | [
"0.7379375",
"0.7275367",
"0.7140974",
"0.69484395",
"0.6873776",
"0.6851417",
"0.6796145",
"0.6791162",
"0.6757891",
"0.67053723",
"0.6662311",
"0.6504203",
"0.637975",
"0.63385004",
"0.63343567",
"0.63098335",
"0.62953097",
"0.6253162",
"0.6253162",
"0.6253162",
"0.6253162"... | 0.6952524 | 3 |
For level 2 returns 10 | def min_number_of_a_level(level)
max_number_of_a_level(level - 1) + 1
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def value\n return 3*level\n end",
"def level(xp)\n xp / 10\n end",
"def value\n return 15*level\n end",
"def desired_xp\n return (200 * level * (level + 1)).to_i\n end",
"def get_xp\n return 3 * level\n end",
"def return_10\n\t\treturn 10\n\tend",
"def max_number_of_a_level(level)... | [
"0.696101",
"0.6956378",
"0.67394006",
"0.66480833",
"0.65388536",
"0.63859224",
"0.63619447",
"0.6301407",
"0.62684315",
"0.6243405",
"0.6233843",
"0.6192817",
"0.6155028",
"0.61303926",
"0.6093857",
"0.60903376",
"0.60903376",
"0.60903376",
"0.60903376",
"0.60903376",
"0.60... | 0.6357107 | 7 |
Every side of the matrix has the same pattern of manhattan distances This method returns the starting manhattan distance | def initial_manhattan_distance(level)
2 * (level - 1) + 1
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def manhattan_distance(start_row, start_col, end_row, end_col)\n (end_row - start_row).abs + (end_col - start_col).abs\n end",
"def manhattan_distance\n @position.map(&:abs).sum\n end",
"def manhattan_distance(x1, y1, row_index, column_index)\n\t\t(x1 - row_index).abs + (y1 - column_index).abs\n\tend",... | [
"0.779156",
"0.7598629",
"0.7412143",
"0.7281424",
"0.71843666",
"0.7012088",
"0.6862326",
"0.6808818",
"0.63497883",
"0.61440355",
"0.611938",
"0.611938",
"0.611938",
"0.59789044",
"0.5950214",
"0.5782146",
"0.5776471",
"0.5775573",
"0.5755672",
"0.5618482",
"0.56021917",
... | 0.71164644 | 5 |
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 |
Default method, subclasses must override this | def run
super
lookup_string = _get_entity_name.upcase
begin
search_doc = Nokogiri::XML(http_get_body("http://whois.arin.net/rest/orgs;name=#{URI.escape(lookup_string)}*"));nil
orgs = search_doc.xpath("//xmlns:orgRef")
# For each netblock, create an entity
orgs.children.each do |org|
_log_good "Working on #{org.text}"
net_list_doc = Nokogiri::XML(http_get_body("#{org.text}/nets"))
begin
nets = net_list_doc.xpath("//xmlns:netRef")
nets.children.each do |net_uri|
_log_good "[!] Net: #{net_uri}" if net_uri
#page = "https://whois.arin.net/rest/net/NET-64-41-230-0-1.xml"
page = "#{net_uri}.xml"
net_doc = Nokogiri::XML(http_get_body(page));nil
net_blocks = net_doc.xpath("//xmlns:netBlocks");nil
net_blocks.children.each do |n|
start_address = n.css("startAddress").text
end_address = n.css("endAddress").text
description = n.css("description").text
cidr_length = n.css("cidrLength").text
type = n.css("type").text
# Do a lookup - important that we get this so we can verify
# if the block actually belongs to the expected party (via whois_full_text)
# see discovery strategy for more info
begin
whois = ::Whois::Client.new(:timeout => 20)
answer = whois.lookup(start_address)
parser = answer.parser
whois_full_text = answer.content if answer
rescue ::Whois::ResponseIsThrottled => e
_log "Unable to query whois: #{e}"
end
#===================================
_log_good "Creating net block: #{start_address}/#{cidr_length}"
entity = _create_entity "NetBlock", {
"name" => "#{start_address}/#{cidr_length}",
"start_address" => "#{start_address}",
"end_address" => "#{end_address}",
"cidr" => "#{cidr_length}",
"description" => "#{description}",
"block_type" => "#{type}",
"whois_full_text" => "#{whois_full_text}"
}
end # end netblocks.children
end # end nets.children
rescue Nokogiri::XML::XPath::SyntaxError => e
_log_error " [x] No nets for #{org.text}"
end
end # end orgs.children
rescue Nokogiri::XML::XPath::SyntaxError => e
_log_error " [x] No orgs!"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def overrides; end",
"def custom; end",
"def custom; end",
"def default; end",
"def default; end",
"def private; end",
"def special\n override\n end",
"def defaults\n super\n end",
"def implementation; end",
"def implementation; end",
"def default\n end",
"def defaults; end",
... | [
"0.7415348",
"0.73554313",
"0.73554313",
"0.6991004",
"0.6991004",
"0.69613177",
"0.69572926",
"0.6824949",
"0.6801543",
"0.6801543",
"0.67361915",
"0.66934764",
"0.66934764",
"0.66934764",
"0.66934764",
"0.66934764",
"0.66934764",
"0.66934764",
"0.66934764",
"0.66934764",
"0... | 0.0 | -1 |
Otherwise responsive? will whine about our thread being dead after forking | def boot_with_clear_server_thread
boot_without_clear_server_thread.tap do
@server_thread = nil
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fork # :nodoc\n @cant_fork = true\n nil # important due #work\n end",
"def handle_fork\n LOCK.synchronize do\n if @me != Process.pid\n trace \"process forked; recovering\"\n # Update the current process ID\n @me = Process.pid\n\n ... | [
"0.74092436",
"0.6957325",
"0.6929032",
"0.6923432",
"0.69168776",
"0.67488897",
"0.6735366",
"0.671311",
"0.6659065",
"0.6566278",
"0.65374434",
"0.6480036",
"0.64702904",
"0.6450535",
"0.6447646",
"0.6419505",
"0.6346915",
"0.6344478",
"0.6329496",
"0.6317789",
"0.63148737"... | 0.0 | -1 |
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 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.