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 |
|---|---|---|---|---|---|---|
returns readable format of url | def match_url
self.first_team.name + " vs " + self.opponent_team.name + " " + self.time.strftime("%b %d")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_s; @url; end",
"def to_s\n\t\turl.to_s\n\tend",
"def to_s\n url\n end",
"def to_s\n url\n end",
"def to_s\n @url\n end",
"def to_s\n \"#{self.class}#url: #{url}\"\n end",
"def to_url\n to_uri.to_s\n end",
"def formatted_url\n if @request.scheme == \... | [
"0.7897969",
"0.7881052",
"0.7872611",
"0.77984565",
"0.75610226",
"0.7403899",
"0.7348915",
"0.7307873",
"0.72806734",
"0.7280404",
"0.7256037",
"0.72057945",
"0.71519417",
"0.7110262",
"0.7107447",
"0.7094374",
"0.70882714",
"0.70017475",
"0.6976109",
"0.6931619",
"0.690872... | 0.0 | -1 |
don't uncomment the below two lines since the validations would fire up in other forms validates :trump_card, presence: true, numericality: true validates :man_of_the_match, presence: true, numericality: true To retrieve the report associated with a match | def report
Report.where(match_id: self.id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate_payer_and_its_related_attributes\r\n result = true\r\n error_message = nil\r\n if !params[:payer].blank?\r\n payer_address_fields = {\r\n :address_one => params[:payer][:pay_address_one].to_s.strip,\r\n :city => params[:payer][:payer_city].to_s.strip,\r\n :state => p... | [
"0.59683824",
"0.5922367",
"0.58200073",
"0.5792871",
"0.5770225",
"0.57056004",
"0.5696723",
"0.5681521",
"0.56627476",
"0.56427026",
"0.5641026",
"0.5608694",
"0.55578494",
"0.5552775",
"0.5520626",
"0.55204153",
"0.55189735",
"0.54924047",
"0.5473087",
"0.5460619",
"0.5455... | 0.0 | -1 |
Retriving the teams of a particular match | def first_team
Team.find(self.team1_id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def matches()\n sql = \"SELECT matches.* FROM matches WHERE away_team_id = #{@id} OR home_team_id = #{@id};\"\n matches = SqlRunner.run( sql )\n result = matches.map { |match| Match.new(match) }\n return result\n end",
"def index\n @match_teams = MatchTeam.all\n end",
"def team_names\n teams ... | [
"0.76005",
"0.7254201",
"0.6984696",
"0.6942787",
"0.6933688",
"0.69253576",
"0.6878712",
"0.679852",
"0.67982435",
"0.67745686",
"0.6755028",
"0.6734041",
"0.67245907",
"0.6717566",
"0.6701943",
"0.6696826",
"0.66710687",
"0.66704345",
"0.66538686",
"0.6640086",
"0.6633386",... | 0.0 | -1 |
Get a new instance of the pagination class. | def initialize(pagination_data={})
@page = pagination_data.fetch(:page, 1)
@per_page = pagination_data.fetch(:per_page, 1000)
@total_pages = pagination_data.fetch(:total_pages, 1)
@total_records = pagination_data.fetch(:total_records, -1)
@page_first_index = pagination_data.fetch(:page_first_index, -1)
@page_last_index = pagination_data.fetch(:page_last_index, -1)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pagination\n Pagination.new( total_items, search_args)\n end",
"def paginator\n @paginator ||= paginator_klass.new(page_params)\n end",
"def pagination\n @pagination ||= WscSdk::Pagination.new()\n end",
"def _pagination\n return @_pagination if @_pagination\n\n ... | [
"0.7697483",
"0.75647837",
"0.70053935",
"0.6688033",
"0.64986855",
"0.64846814",
"0.6397242",
"0.62770694",
"0.6262143",
"0.62375706",
"0.61696625",
"0.6164305",
"0.6163294",
"0.6157658",
"0.6114019",
"0.6050789",
"0.6027177",
"0.6017273",
"0.6005382",
"0.5999874",
"0.599914... | 0.6573896 | 4 |
Determine if the current page is the first page | def first_page?
return true if total_pages < 1
return (page == 1)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def first_page?\n current_page == 0\n end",
"def first_page?\n current_page == 1\n end",
"def first_page?\n current_page == 1\n end",
"def first_page?\n current_page == 1\n end",
"def first_page?\n current_page == 1\n end",
"def first_page?\n current_page ==... | [
"0.90105736",
"0.89566576",
"0.89566576",
"0.89566576",
"0.89566576",
"0.893676",
"0.893676",
"0.8881099",
"0.86916375",
"0.85574275",
"0.8484011",
"0.83494854",
"0.7860644",
"0.776965",
"0.74527365",
"0.7385089",
"0.72712874",
"0.7150359",
"0.7122814",
"0.7064156",
"0.706355... | 0.85057265 | 10 |
Get the number of the first page | def first_page
return nil if total_pages < 1
return 1
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def first_page_number\n 1\n end",
"def first_in_page\n ((current_page - 1) * per_page) + 1\n end",
"def page_number\n\t\t\t\treturn 0 if @total_results == 0\n\t\t\t\t@offset + 1\n\t\t\tend",
"def page_count\n 1\n end",
"def first_page_id\n # Some PageTurners use i... | [
"0.8905115",
"0.81301874",
"0.80464077",
"0.7864718",
"0.781302",
"0.7756753",
"0.7694482",
"0.7666719",
"0.7613564",
"0.7612567",
"0.7604157",
"0.75154024",
"0.7463716",
"0.74601597",
"0.74446386",
"0.74364036",
"0.7358745",
"0.7304519",
"0.72953725",
"0.729347",
"0.7265896"... | 0.8599595 | 1 |
Get the number of the next page. | def next_page
return nil if total_pages == -1
return nil if page == total_pages
return page + 1
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def next_page_number\n last_page? ? nil : current_page_number + 1\n end",
"def next_page_number\n self.pages.count + 1\n end",
"def next_page\n num = current_page + 1\n num if total_pages >= num\n end",
"def calculate_next\n n = @current_page + 1\n n > @to... | [
"0.84943134",
"0.8395219",
"0.83164877",
"0.82673985",
"0.82381743",
"0.8162492",
"0.8140912",
"0.8140912",
"0.81252086",
"0.81132",
"0.80976605",
"0.8076976",
"0.8045452",
"0.7988601",
"0.7988601",
"0.7985155",
"0.7982464",
"0.7980017",
"0.79583675",
"0.79583675",
"0.7938759... | 0.82747096 | 3 |
Get the number of the previous page. | def previous_page
return nil if total_pages < 1
return nil if page == 1
return page - 1
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def prev_page\n num = current_page - 1\n num if num.positive?\n end",
"def previous_page\n @current_page - 1 if has_previous_page?\n end",
"def previous_page\n return if page == 1\n page - 1\n end",
"def previous\n return @page - 1\n end",
"... | [
"0.89942604",
"0.8917843",
"0.87252766",
"0.87074316",
"0.8625349",
"0.8625144",
"0.8625144",
"0.8624552",
"0.86136943",
"0.861183",
"0.861183",
"0.86043966",
"0.8598865",
"0.8598865",
"0.8598865",
"0.8598865",
"0.8598865",
"0.856775",
"0.85591143",
"0.85056764",
"0.8457178",... | 0.8767968 | 2 |
Get the number of the last page | def last_page
return nil if total_pages < 1
return total_pages
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def last_page_number\n number_of_pages\n end",
"def last_page_index\n num_pages() - 1\n end",
"def page_count\n pages.last\n end",
"def last_page_number\n Hash(last_page_params).fetch('page', {}).fetch('number', nil)\n end",
"def last_page\n @links['last']\n end",
... | [
"0.90305996",
"0.89022326",
"0.8540922",
"0.8290644",
"0.82683843",
"0.8230177",
"0.80691963",
"0.80633175",
"0.8061384",
"0.80437",
"0.8027918",
"0.7911048",
"0.7911048",
"0.7695525",
"0.7648143",
"0.7633505",
"0.76181173",
"0.7593437",
"0.7427577",
"0.74214524",
"0.74214524... | 0.87408537 | 2 |
Determine if the current page is the last page | def last_page?
return true if total_pages < 1
return (page == total_pages)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def last_page?\n current_page == pages.end\n end",
"def last_page?\n current_page == total_pages - 1\n end",
"def current_is_last_page?\n @current_page.next_page == 0\n end",
"def last_page?\n current_page >= num_pages\n end",
"def last_page?\n current_page >= n... | [
"0.8953896",
"0.8898739",
"0.8803112",
"0.87891525",
"0.87814164",
"0.87814164",
"0.8772956",
"0.8772245",
"0.87184757",
"0.8687979",
"0.86188257",
"0.85856855",
"0.8469546",
"0.8449506",
"0.8446135",
"0.84240204",
"0.8213985",
"0.8041934",
"0.8041934",
"0.79776263",
"0.76760... | 0.85193026 | 12 |
Customs Resumen de promociones tomadas por un cliente | def processed_promos
respond_to do |format|
@taken_promos = TakenPromo.get_taken_promos_for_user current_user
format.html { }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def naturalista_observaciones_service(proveedor)\n puts \"\\t\\tGenerando las observaicones de NaturaLista\"\n # Para las nuevas observaciones\n proveedor.kml_naturalista\n return unless proveedor.naturalista_kml.present?\n proveedor.kmz_naturalista\n puts \"\\t\\tCon KMZ naturalista\"\n end",
... | [
"0.5590337",
"0.5526469",
"0.5471445",
"0.54526126",
"0.5371096",
"0.53540635",
"0.53215545",
"0.5310255",
"0.5283335",
"0.5282856",
"0.52776885",
"0.5268421",
"0.5267786",
"0.5267122",
"0.5263374",
"0.52621585",
"0.5258568",
"0.52563864",
"0.5251068",
"0.52500194",
"0.520618... | 0.5374582 | 4 |
Las promociones tomadas, que no ha tenido una respuesta del local. | def taken_promos
respond_to do |format|
@promos = Promo.get_taken_promos_for_user current_user
format.html { render "promos/content" }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pending_promotions\n @pending_promotions ||= []\n end",
"def pending_promotions?\n !pending_promotions.empty?\n end",
"def members_not_responding\n memb = sent_messages.map { |sm| (sm.msg_status || -1) < MessagesHelper::MsgDelivered ? sm.member : nil }.compact\n end",
"def no_solutions\n\t\t#... | [
"0.5915297",
"0.5852731",
"0.55865836",
"0.549639",
"0.54922223",
"0.5453878",
"0.5443812",
"0.5405119",
"0.5397088",
"0.5377169",
"0.5357745",
"0.532282",
"0.53073996",
"0.5294275",
"0.5272003",
"0.52577996",
"0.52577996",
"0.52577996",
"0.52577996",
"0.52577996",
"0.5250459... | 0.48170552 | 98 |
Use callbacks to share common setup or constraints between actions. | def set_promo
@promo = @place.promos.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.6165422",
"0.60457647",
"0.5946384",
"0.5916027",
"0.58905005",
"0.583495",
"0.5777223",
"0.56995213",
"0.56995213",
"0.56532377",
"0.5621348",
"0.5422839",
"0.54118705",
"0.54118705",
"0.54118705",
"0.53935355",
"0.5379617",
"0.53577393",
"0.53407264",
"0.53398263",
"0.53... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def promo_params
params.require(:promo).permit(:name, :description, :extra_description, :place_id, :published, :start_at, :end_at, :role_id, :place_id, :banner, :star_number, :category_id, :subcategory1_id, :subcategory2_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 |
Returns the month options information for the step 3 for signup page. | def months_information
(1).upto(12).collect{|i| "<option>#{"%02d" % i}</option>"}.join('').html_safe
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def work_months_options(user=@curr_user, include_all=false)\n min_year, min_year_month, max_year, max_year_month = WorkEntry.min_max_dates_for_user(user)\n months = if min_year == 0 && max_year == 0\n []\n else\n (year_and_month_to_int(min_year, min_year_month) .. year... | [
"0.56753224",
"0.5668433",
"0.5544216",
"0.54704297",
"0.5448189",
"0.536976",
"0.53280413",
"0.53056777",
"0.5283682",
"0.5267643",
"0.5161663",
"0.51283425",
"0.5116807",
"0.5112113",
"0.50811946",
"0.50689065",
"0.50509685",
"0.50509685",
"0.50486255",
"0.5020428",
"0.5003... | 0.6186032 | 0 |
Returns the month options information for the step 3 for signup page. | def card_types_information
["Visa","Mastercard","American Express"].collect{|i| "<option>#{i}</option>"}.join('').html_safe
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def months_information\n (1).upto(12).collect{|i| \"<option>#{\"%02d\" % i}</option>\"}.join('').html_safe\n end",
"def work_months_options(user=@curr_user, include_all=false)\n min_year, min_year_month, max_year, max_year_month = WorkEntry.min_max_dates_for_user(user)\n months = if min_year == 0 && ma... | [
"0.61892825",
"0.5677293",
"0.567349",
"0.55460495",
"0.5470828",
"0.5448826",
"0.53743076",
"0.5324194",
"0.53095317",
"0.52878886",
"0.52686626",
"0.5166129",
"0.51329184",
"0.51216906",
"0.5110636",
"0.507862",
"0.5069668",
"0.50553447",
"0.50553447",
"0.5049741",
"0.50253... | 0.0 | -1 |
Create a new Xattr instance with path. Use :no_follow => true in options to work on symlink itself instead of following it. | def initialize(path, options = {})
@path =
if path.respond_to?(:to_path)
path.to_path
elsif path.respond_to?(:to_str)
path.to_str
else
path
end
raise Errno::ENOENT, @path unless File.exist?(@path)
@no_follow = !!options[:no_follow]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mkpath(*args)\n args[0] = {} unless args[0]\n args[0] = args[0].merge(mode: 0700) unless args[0][:mode]\n FileUtils.mkpath(self.to_s, *args)\n end",
"def create_symlink(dest_path); end",
"def create_symlink(source = nil, dest = nil)\n end",
"def open(p_attr = 'r')\n @@log.d(... | [
"0.5561766",
"0.5488251",
"0.52903765",
"0.5209366",
"0.52069795",
"0.5170588",
"0.5103818",
"0.5090493",
"0.499547",
"0.4891479",
"0.4882146",
"0.48714545",
"0.4851653",
"0.48451298",
"0.48382947",
"0.48193347",
"0.48128554",
"0.4812025",
"0.48101076",
"0.47921306",
"0.47453... | 0.573661 | 0 |
List extended attribute names | def list
Lib.list @path, @no_follow
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def derived_attribute_names\n Module.nesting.first.public_instance_methods - [:derived_attribute_names]\n end",
"def attribute_names\n @attributes.map(&:name)\n end",
"def attribute_names\n self.class.attributes.map { |a| a[:name] }\n end",
"def attribute_names\n @attributes.keys... | [
"0.73201066",
"0.7079669",
"0.7050815",
"0.70092815",
"0.70092815",
"0.70092815",
"0.70092815",
"0.6977614",
"0.6974679",
"0.6970274",
"0.69284105",
"0.6877631",
"0.68614876",
"0.68478215",
"0.68478215",
"0.68176854",
"0.6815006",
"0.68070054",
"0.6783074",
"0.6783074",
"0.67... | 0.0 | -1 |
Get an extended attribute value | def get(key)
Lib.get @path, @no_follow, key.to_s
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ext_attr\n attribute_prop(10)\n end",
"def get_attr_value_from_ext_attr( m_name, args )\n \n if self.new_record?\n \n value = nil\n \n self.extended_attributes.each do |extended_attr|\n value = ( extended_attr.value.blank? ? nil : extended_attr.value ) i... | [
"0.78420585",
"0.751319",
"0.74562615",
"0.74562615",
"0.70675",
"0.70504534",
"0.70008314",
"0.69821537",
"0.6910565",
"0.686844",
"0.6843464",
"0.68301386",
"0.6812185",
"0.6764515",
"0.6756714",
"0.67489463",
"0.6742881",
"0.67420155",
"0.66923267",
"0.66634274",
"0.659355... | 0.0 | -1 |
Set an extended attribute value | def set(key, value)
Lib.set @path, @no_follow, key.to_s, value.to_s
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_attribute(name, value); end",
"def set_attr_value( m_name, args )\n \n dup_m_name = m_name.gsub(/=$/, '')\n if( extended_attribute = find_in_extended_attr( dup_m_name ) )\n extended_attribute.update_attributes( :values => args )\n elsif( schema = find_attr_in_schema( dup_m_name... | [
"0.7809601",
"0.7221783",
"0.6939973",
"0.6794692",
"0.6787785",
"0.67766154",
"0.677454",
"0.6765567",
"0.67460245",
"0.6735544",
"0.67330754",
"0.6699214",
"0.6657541",
"0.664818",
"0.6644544",
"0.6592288",
"0.6578587",
"0.65732104",
"0.65489346",
"0.65489346",
"0.65405726"... | 0.0 | -1 |
Remove an extended attribute value | def remove(key)
Lib.remove @path, @no_follow, key.to_s
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_attribute(name); end",
"def remove_attribute(name); end",
"def remove_attribute(name); end",
"def remove_attribute(name); end",
"def remove_attr(name); end",
"def remove_attr(name); end",
"def - (name) remove_attribute name end",
"def delete_attribute(key); end",
"def remove_attribute(n... | [
"0.80115163",
"0.80115163",
"0.80115163",
"0.80115163",
"0.7832887",
"0.7832887",
"0.77811605",
"0.74481887",
"0.7101587",
"0.70290315",
"0.69689393",
"0.6917935",
"0.6901625",
"0.6818359",
"0.68174833",
"0.6790922",
"0.6756584",
"0.6727133",
"0.671033",
"0.6700885",
"0.66809... | 0.0 | -1 |
Iterates over pairs of extended attribute names and values | def each(&blk)
list.each do |key|
yield key, get(key)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def each_attribute_pair(&block)\n @attributes.each_pair do |name, value|\n block.call(name, value)\n end\n end",
"def each # :yields: key, value\n @attrs.each { |k, v| yield(k, v) }\n end",
"def each_attribute # :yields: key\n @attrs.each_key { |k| yield(k) }\n end",... | [
"0.6849896",
"0.67880577",
"0.6779052",
"0.66547066",
"0.6608531",
"0.66048825",
"0.66048825",
"0.66048825",
"0.6506134",
"0.64983773",
"0.64551497",
"0.6385656",
"0.6373156",
"0.634422",
"0.634422",
"0.62761986",
"0.627491",
"0.62512404",
"0.6165687",
"0.61045635",
"0.608711... | 0.0 | -1 |
Returns hash of extended attributes | def to_hash
res = {}
each { |k,v| res[k] = v }
res
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hash\n attributes.hash\n end",
"def hash\n attributes.hash\n end",
"def hash\n attributes.hash\n end",
"def attr_hash\n Digest::MD5.hexdigest(\"#{@name}:#{@ruby_type}\")\n end",
"def hash\n @attrs\n end",
"def attributes_hash(object); end",
"def attributes_ha... | [
"0.73105294",
"0.73105294",
"0.73105294",
"0.72386926",
"0.72325665",
"0.722146",
"0.72133857",
"0.7057894",
"0.7036722",
"0.6978551",
"0.6973841",
"0.6964793",
"0.6930736",
"0.689495",
"0.6862817",
"0.68609494",
"0.6779723",
"0.6755839",
"0.674487",
"0.6730911",
"0.67281616"... | 0.0 | -1 |
Project Euler problem 1 If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. Find the sum of all the multiples of 3 or 5 below 1000 | def solve (input)
output = 0
mult_five = 5
curr_val = 3
while curr_val < input
if curr_val > mult_five
output += mult_five
mult_five += 5
elsif curr_val == mult_five
mult_five += 5
end
output += curr_val
curr_val += 3
end
return output
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_sum_of_multiples_of_3_and_5_below_1000\n answer = 0\n for number in 1...1000\n answer += number if number % 3 == 0 || number % 5 == 0\n end\n answer\nend",
"def euler_1\n number = 1\n sum = 0\n while number < 1000\n if (number % 3 == 0 || number % 5 == 0)\n sum += number \n end\n ... | [
"0.8399307",
"0.8196171",
"0.81143945",
"0.81067187",
"0.7999705",
"0.79389834",
"0.78441846",
"0.78345454",
"0.7810555",
"0.7786339",
"0.77791274",
"0.7775222",
"0.7716939",
"0.76873493",
"0.7660419",
"0.76460534",
"0.76425076",
"0.763904",
"0.76252085",
"0.7584624",
"0.7556... | 0.0 | -1 |
Use callbacks to share common setup or constraints between actions. def set_post | def twat_params
params.require(:twat).permit(:name)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def post\n raise NotImplementedError\n end",
"def post; end",
"def post_task\n end",
"def post\r\n end",
"def _eval_post\n _eval_action('post')\n end",
"def post\n end",
"def post_setup\n end",
"def post\n if phase.has_key?('post')\n execute(\"post\", phase['post'])\n ... | [
"0.6503896",
"0.6447215",
"0.6432301",
"0.6409369",
"0.6402934",
"0.6397673",
"0.6163773",
"0.6107249",
"0.60566974",
"0.60019404",
"0.59683925",
"0.58899283",
"0.58727527",
"0.58463657",
"0.58281803",
"0.5789596",
"0.5755783",
"0.57393867",
"0.5734422",
"0.57180256",
"0.5686... | 0.0 | -1 |
create an entry, filling out all fields | def create_entry
visit new_entry_path :source_id => @source.id
fill_in 'cat_lot_no', with: '123'
# sale_selling_agent should be auto-populated from source, so we skip it
#fill_autocomplete_select_or_create_entity 'sale_seller', with: 'Joe2'
#fill_autocomplete_select_or_create_entity 'sale_buyer', with: 'Joe3'
offset = @source.source_agents.count
find_by_id('add_sale_agent').click
add_name_authority("find_sale_agent_name_authority_#{offset}", 'Joe2')
select 'Seller', from: "sale_agent_role_#{offset}"
find_by_id('add_sale_agent').click
add_name_authority("find_sale_agent_name_authority_#{offset + 1}", 'Joe3')
select 'Buyer', from: "sale_agent_role_#{offset + 1}"
expect(find("#sale_agent_#{offset}")).to have_content('Joe2')
expect(find("#sale_agent_#{offset + 1}")).to have_content('Joe3')
# find_by_id('find_seller_name_authority_0').click
# fill_in 'searchNameAuthority', with: 'Joe2'
# find_by_id('selectNameButton').click
# find_by_id('find_buyer_name_authority_0').click
# fill_in 'searchNameAuthority', with: 'Joe2'
# find_by_id('selectNameButton').click
select 'Yes', from: 'sale_sold'
fill_in 'sale_date', with: '2014-03-03'
fill_in 'sale_price', with: '130000'
select 'USD', from: 'sale_currency'
find_by_id('add_title').trigger('click')
fill_in 'title_0', with: 'Book of Hours'
#find_by_id("add_title_0").click
find_by_id('add_title').trigger('click')
fill_in 'title_1', with: 'Bible'
# fill_autocomplete_select_or_create_entity 'author_0', with: 'Schmoe, Joe'
find_by_id('add_author').trigger('click')
add_name_authority('find_author_name_authority_0', 'Schmoe, Joe')
fill_in 'author_observed_name_0', with: 'Joe Schmoe'
click_certainty_flag('author_certainty_flags_0')
select 'Translator', from: 'author_role_0'
find_by_id('add_date').click
fill_in 'date_observed_date_0', with: 'early 15th century'
# move focus out of observed_date in order to trigger auto-populate of normalized dates
page.execute_script %Q{ $('#date_normalized_start_0').trigger('focus') }
find_by_id('add_artist').click
fill_in 'artist_observed_name_0', with: 'Chuck'
#fill_autocomplete_select_or_create_entity 'artist_0', with: 'Schultz, Charles'
add_name_authority('find_artist_name_authority_0', 'Schultz, Charles')
find_by_id('add_scribe').click
fill_in 'scribe_observed_name_0', with: 'Brother Francisco'
#fill_autocomplete_select_or_create_entity 'scribe_0', with: 'Brother Francis'
add_name_authority('find_scribe_name_authority_0', 'Brother Francis')
find_by_id('add_language').click
#fill_autocomplete_select_or_create_entity 'language_0', with: 'Latin'
add_model_authority('find_language_name_authority_0', 'Latin')
find_by_id('add_material').click
#fill_autocomplete_select_or_create_entity 'material_0', with: 'Parchment'
select('Parchment', :from => 'material_0')
find_by_id('add_place').click
fill_in 'place_observed_name_0', with: 'Somewhere in Italy'
#fill_autocomplete_select_or_create_entity 'place_0', with: 'Italy'
add_model_authority('find_place_name_authority_0', 'Italy')
find_by_id('add_use').click
fill_in 'use_0', with: 'Some mysterious office or other'
fill_in 'folios', with: '123'
fill_in 'num_lines', with: '3'
fill_in 'num_columns', with: '2'
fill_in 'height', with: '200'
fill_in 'width', with: '300'
select 'Folio', from: 'alt_size'
fill_in 'miniatures_fullpage', with: '6'
fill_in 'miniatures_large', with: '7'
fill_in 'miniatures_small', with: '8'
fill_in 'miniatures_unspec_size', with: '9'
fill_in 'initials_historiated', with: '10'
fill_in 'initials_decorated', with: '11'
fill_in 'manuscript_binding', with: 'Velvet'
fill_in 'manuscript_link', with: 'http://something.com'
fill_in 'other_info', with: 'Other stuff'
first('#add_provenance').click
fill_in 'provenance_observed_name_0', with: 'Somebody, Joe'
#fill_autocomplete_select_or_create_entity 'provenance_agent_0', with: 'Somebody, Joseph'
add_name_authority('find_provenance_name_authority_0', 'Somebody, Joseph')
click_certainty_flag('provenance_certainty_flags_0')
#find_by_id('add_provenance_date_0').click
fill_in 'provenance_0_recorded_date_0', with: '1945-06-15'
sleep 0.4
fill_in 'provenance_start_date_0', with: '1945-06-15'
fill_in 'provenance_end_date_0', with: '1965-11-23'
check 'provenance_direct_transfer_0'
first('#add_provenance').click
# fill_autocomplete_select_or_create_entity 'provenance_agent_1', with: "Sotheby's"
add_name_authority('find_provenance_name_authority_1', "Sotheby's")
#find_by_id('add_provenance_date_1').click
fill_in 'provenance_1_recorded_date_0', with: '1965'
fill_in 'provenance_start_date_1', with: '1965-11-23'
fill_in 'provenance_comment_1', with: 'An historic sale'
#select 'For Sale', from: 'provenance_acquisition_method_1'
check 'provenance_direct_transfer_1'
first('#add_provenance').click
fill_in 'provenance_observed_name_2', with: 'Wild Bill Collector'
fill_in 'provenance_comment_2', with: 'This is some unknown dude'
#fill_in 'comment', with: 'This info is correct'
first(".save-button").click
expect(page).to have_content("Warning: This entry has not been approved yet.")
expect(page).to have_content(Entry.last.public_id)
#expect(find(".modal-title", visible: true)).to have_content("Successfully saved")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n create_entry\n end",
"def create(attributes)\n entry = new(attributes)\n entry.save\n entry\n end",
"def create_entry\n system \"clear\"\n puts \"New AddressBloc Entry\"\n print \"Name: \"\n name = gets.chomp\n print \"Ph... | [
"0.7949931",
"0.7144481",
"0.7020344",
"0.6952905",
"0.6905546",
"0.68541205",
"0.6758412",
"0.6754651",
"0.6740487",
"0.6728686",
"0.67183816",
"0.6589681",
"0.65790504",
"0.6559297",
"0.65580827",
"0.6539644",
"0.64181834",
"0.64129895",
"0.63877195",
"0.6364216",
"0.635424... | 0.0 | -1 |
Here we do a long running blocking task in a thread outside the main loop. We assert that the loops spins a timer while waiting for the blocking thread. | def test_fiber_subtask_slow
timer_count = 0
fiber_count = 0
@loop.add_timeout(0.1) { timer_count += 1 }
@loop.add_fiber {
fiber_count += 2
@loop.yield
fiber_count += @loop.yield_from_thread { sleep 3; 11 }
@loop.yield
fiber_count += 5
@loop.add_once { @loop.quit }
}
@loop.run
assert_equal 18, fiber_count
assert(timer_count > 25)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def wait_async(time)\n EM::Synchrony.sleep(time)\nend",
"def blocking_thread\n poller_thread\n end",
"def wait_until_without_failing(timeout=UI_UPDATE_DELAY)\n start = Time.now\n while ((Time.now - start) <= timeout)\n break if yield\n sleep(WaitHelpers::LOOP_DELAY)\n end\nend",
"def br... | [
"0.6624622",
"0.6448387",
"0.64338976",
"0.63238007",
"0.62685144",
"0.6170449",
"0.6164599",
"0.612212",
"0.60982335",
"0.60454947",
"0.6040949",
"0.6033261",
"0.60082585",
"0.5991189",
"0.5985056",
"0.59750736",
"0.5972762",
"0.5925657",
"0.59252524",
"0.5923587",
"0.590352... | 0.63033736 | 4 |
Asserts that fibers can be created from other threads. | def test_off_thread_creation
counter = 0
@loop.add_once {
Thread.new {
@loop.add_fiber {
counter += 3
@loop.yield
counter += 5
counter += @loop.yield { |task| task.done(7) }
counter += @loop.yield_from_thread {
sleep 0.1
@loop.add_once(0.2) { @loop.quit }
11
}
}
}
}
@loop.run
assert_equal 26, counter
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allowing_other_threads; end",
"def test_answer_fibers\n threads = []\n ids = []\n mutex = Mutex.new\n (1..10).each{\n threads << Thread.new{\n post \"/answer\"\n assert last_response.body.include?('action='), 'not found: action'\n assert last_response.body.include?('hi p... | [
"0.61892116",
"0.6009455",
"0.591931",
"0.56384933",
"0.5598758",
"0.55258656",
"0.54591054",
"0.5424195",
"0.5413683",
"0.53754133",
"0.53567165",
"0.53398937",
"0.5337052",
"0.5335663",
"0.5280318",
"0.5278663",
"0.52373976",
"0.52373976",
"0.52373976",
"0.52331936",
"0.518... | 0.56993663 | 3 |
def like if current_user.liked_posts.include? Post.find(params[:post_id]) Like.find_by(user_id: current_user.id, post_id: params[:post_id]).destroy else Like.create(user_id: current_user.id, post_id: params[:post_id]) end redirect_to '/' end | def create
@like = Like.create(user_id: current_user.id,
post_id: params[:post_id])
@post_id = params[:post_id]
respond_to do |format|
format.html {redirect_to :back}
format.js {}
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def like\n @topic = Topic.find(params[:topic_id])\n @post = @topic.posts.find(params[:id])\n if @post.not_liked_already?(current_user)\n @post.likes.create(user: current_user)\n redirect_to [@post.topic, @post]\n else\n @post.likes.where(user: current_user).destroy_all\n redirect_to... | [
"0.86718714",
"0.8356598",
"0.83438605",
"0.8266201",
"0.7970371",
"0.79543936",
"0.79158944",
"0.7888115",
"0.78838885",
"0.78359747",
"0.7783436",
"0.77246606",
"0.76769716",
"0.76353675",
"0.76283854",
"0.7623592",
"0.7610946",
"0.75854015",
"0.7561311",
"0.7560561",
"0.75... | 0.693345 | 72 |
TODO not_expected[]] for solution | def initialize to_check, expected, label=nil, solution=nil, father_cat=nil
@to_check=to_check
@expected = expected
@label = label
@solution=solution
@id = NumerationFactory.create father_cat
@status= -1
@father_cat = father_cat
if father_cat != nil
@display_offset=father_cat.display_offset+1
else
@display_offset=0
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def expecting; [] end",
"def assert_missing_delimitation!\n end",
"def test_check_invalid_prospectors\n assert_equal check_valid([2, 0, 1]), [1, nil, nil, nil]\n end",
"def expected_value; end",
"def expected_value; end",
"def missed?; end",
"def test_parser_handles_unsupported_email_array\n ... | [
"0.7239879",
"0.6302429",
"0.6245249",
"0.61585313",
"0.61585313",
"0.6098944",
"0.60922164",
"0.6056359",
"0.6056359",
"0.6052562",
"0.60391533",
"0.6032838",
"0.6032026",
"0.6011102",
"0.5984031",
"0.5984031",
"0.593063",
"0.5926352",
"0.5922135",
"0.5919289",
"0.5917988",
... | 0.0 | -1 |
Returns an Array of the words played by the player | def plays
return @plays
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plays\n return @array_of_words\n end",
"def plays\n return @words_played\n end",
"def get_my_words\n # Words associated with online harassment\n trigger_words = [\"rape\",\"murder\",\"nigger\",\"slut\",\"whore\",\"bitch\",\"cunt\",\"kill\",\"die\",\"testword\"]\n my_words = Word.where(... | [
"0.8663629",
"0.7732937",
"0.70719016",
"0.6988062",
"0.68674815",
"0.68029356",
"0.66696787",
"0.6667908",
"0.6636058",
"0.6617858",
"0.6569789",
"0.652802",
"0.6521441",
"0.64460266",
"0.63908356",
"0.6373286",
"0.6360226",
"0.63302964",
"0.6320889",
"0.63207453",
"0.631258... | 0.61479956 | 26 |
Returns the total score of words played | def total_score
return @plays.reduce(0) { |memo, word| memo + Scrabble::Scoring.score(word) }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def total_score\n plays.inject(0) { |sum, word| sum + Scoring.score(word) }\n end",
"def total_score\n total_score = 0\n plays.each do |word|\n total_score += Scrabble::Scoring.score(word)\n end\n return total_score\n end",
"def total_score\n sum = 0\n @array_of_words.each d... | [
"0.90067124",
"0.889772",
"0.838062",
"0.828722",
"0.78048086",
"0.75701904",
"0.7451368",
"0.7372018",
"0.7367944",
"0.73662716",
"0.7366048",
"0.7310298",
"0.7308236",
"0.72379065",
"0.7229823",
"0.721209",
"0.7208606",
"0.7208406",
"0.719562",
"0.717723",
"0.71653205",
"... | 0.88724005 | 2 |
If the player has over 100 points, returns `true`, otherwise returns `false` | def won?
return total_score > 100 ? true : false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def over?\n self.player.points == self.board.total_points\n end",
"def make_first_play?(points)\n points > 350\n end",
"def won?\n #won?: If the player has over 100 points, returns true, otherwise returns false\n if total_score > 100\n return true\n else\n return false\n ... | [
"0.7927881",
"0.77324086",
"0.76388204",
"0.743061",
"0.743061",
"0.7385032",
"0.7277263",
"0.72362196",
"0.72341996",
"0.7105229",
"0.702653",
"0.69822717",
"0.6967521",
"0.6967521",
"0.69557613",
"0.6954209",
"0.6941861",
"0.69397306",
"0.6919548",
"0.69133425",
"0.6912246"... | 0.6885032 | 23 |
Returns the highest scoring played word | def highest_scoring_word
return Scrabble::Scoring.highest_score_from(@plays)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def highest_scoring_word\n word = Scrabble::Scoring.highest_score_from(plays)\n return word\n end",
"def highest_scoring_word\n Scoring.highest_score_from(plays)\n end",
"def highest_scoring_word\n \tScoring.highest_score_from(@words_played)\n end",
"def highest_scoring_word\n Scrabble::... | [
"0.91971433",
"0.9194255",
"0.9152793",
"0.9025023",
"0.89502466",
"0.88494295",
"0.876358",
"0.87322664",
"0.86930484",
"0.86675537",
"0.84122556",
"0.82538736",
"0.79345626",
"0.78933835",
"0.786208",
"0.77618396",
"0.7750342",
"0.7620365",
"0.75615025",
"0.7361836",
"0.728... | 0.9153124 | 2 |
Returns the `highest_scoring_word` score | def highest_word_score
return Scrabble::Scoring.score(highest_scoring_word)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def highest_word_score\n Scoring.score(highest_scoring_word)\n end",
"def highest_word_score\n return highest_scoring_value = Scrabble::Scoring.score(highest_scoring_word)\n end",
"def highest_scoring_word\n \tScoring.highest_score_from(@words_played)\n end",
"def highest_scoring_word\n ... | [
"0.9340708",
"0.9336717",
"0.9233129",
"0.9192081",
"0.91740125",
"0.9077189",
"0.90659875",
"0.89347565",
"0.89334625",
"0.8836399",
"0.8344125",
"0.8288687",
"0.7745328",
"0.77110255",
"0.7614806",
"0.7578973",
"0.7525986",
"0.7352878",
"0.7345178",
"0.7336979",
"0.733183",... | 0.92456394 | 2 |
A collection of letters that the player can play (max 7) | def tiles
return @tiles
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def letter_choices(game_data)\n \"USED LETTERS: #{game_data.chosen_letters}\"\n end",
"def letters\n @letters ||= {\n \"2\" => ['a','b','c'],\n \"3\" => ['d','e','f'],\n \"4\" => ['g','h','i'],\n \"5\" => ['j','k','l'],\n \"6\" => ['m','n','o'],\n \"7\" => ['p','q','r','s'],\... | [
"0.69740653",
"0.69699275",
"0.68818516",
"0.6731164",
"0.66974425",
"0.6617501",
"0.65532506",
"0.6532925",
"0.6519151",
"0.64945924",
"0.63764226",
"0.6341461",
"0.63404214",
"0.62857723",
"0.62780774",
"0.62356323",
"0.6209168",
"0.6203663",
"0.6186147",
"0.61749",
"0.6173... | 0.0 | -1 |
Draw 7 tiles from the given tile bag | def draw_tiles(tile_bag)
tile_bag = Scrabble::TileBag.new
@tiles = tile_bag.draw_tiles(7)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def draw_tiles(tile_bag)\n until tiles.length == 7\n tiles.concat(tile_bag.draw_tiles(1)) #because draw_tiles returns an array\n\n end\n end",
"def draw_tiles(tile_bag)\n tiles = []\n tiles << Scrabble::TileBag.draw_tiles(7)\n end",
"def draw_tiles (num)\n tiles_drawn = @b... | [
"0.8751531",
"0.8131604",
"0.7178924",
"0.68224996",
"0.67790127",
"0.67075324",
"0.67029035",
"0.65718585",
"0.6390801",
"0.62422985",
"0.62145",
"0.6183691",
"0.60927767",
"0.6079621",
"0.6062272",
"0.60607505",
"0.60602355",
"0.6041537",
"0.6018071",
"0.60096127",
"0.59389... | 0.83768225 | 1 |
Fortune APIrelated helpers TODO: remove IMO :p | def get_price
return @data['android']['price']
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def apis; end",
"def api; end",
"def api; end",
"def api_only; end",
"def api_only; end",
"def api_only; end",
"def api_error; end",
"def rest_endpoint; end",
"def api_mode; end",
"def api\n @api\n end",
"def api_only=(_); end",
"def preflight; end",
"def from_api?; false end",
"def a... | [
"0.72391725",
"0.71815544",
"0.71815544",
"0.694582",
"0.694582",
"0.694582",
"0.6694701",
"0.6533124",
"0.6515731",
"0.64906543",
"0.64036083",
"0.6399375",
"0.6387586",
"0.6321847",
"0.6321847",
"0.631071",
"0.62340087",
"0.62340087",
"0.62340087",
"0.62340087",
"0.62299013... | 0.0 | -1 |
Trivial wrappers around Open3 the run_ commands here capture all the output | def run_command(*command)
#stdout, stderr, status
return Open3.capture3(*command)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def runOpen3CaptureOutput(*cmd_and_args)\n output = ''\n\n onError 'Empty runOpen3 command' if cmd_and_args.empty?\n\n if !File.exist?(cmd_and_args[0]) || !Pathname.new(cmd_and_args[0]).absolute?\n # check that the command exists if it is not a full path to a file\n requireCMD cmd_and_args[0]\n end\n\n ... | [
"0.7136172",
"0.71069926",
"0.7080279",
"0.69961065",
"0.6876487",
"0.68147373",
"0.67523223",
"0.6748974",
"0.674199",
"0.6704241",
"0.6682099",
"0.66800976",
"0.6677882",
"0.6676005",
"0.66313785",
"0.6592427",
"0.6563667",
"0.65170974",
"0.6514128",
"0.65114164",
"0.649896... | 0.7295667 | 0 |
wrap the output of the command in an enumerator allows to lazily parse the result | def run_lazy(*command)
r=nil
IO.popen(command) do |f|
r=f.each_line.lazy
end
r
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def enumerator ; end",
"def enumerator ; end",
"def enumerator; end",
"def output\n enum = parent.get(@value)\n \n return else_commands.output if enum.blank?\n \n enum = [enum] if enum.is_a?(String) || !enum.is_a?(Enumerable)\n enum.inject_with_index(\"\") do |output... | [
"0.64047927",
"0.64047927",
"0.62065566",
"0.61204475",
"0.6082129",
"0.59907895",
"0.5763495",
"0.5755042",
"0.5731409",
"0.5600958",
"0.5600005",
"0.5600005",
"0.55882937",
"0.5542653",
"0.5473421",
"0.545558",
"0.5406683",
"0.5401401",
"0.53998345",
"0.53786033",
"0.537816... | 0.0 | -1 |
Launching a command handle sudo arguments | def sudo_args(sudoarg)
if sudoarg.respond_to?(:sudo_loop)
sudoarg.sudo_loop
end
return [] unless sudoarg
return sudoarg.shellsplit if sudoarg.is_a?(String)
["sudo"]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run_privileged *args\n args = if args.length > 1\n\t args.unshift \"/usr/bin/sudo\"\n\t else\n\t \"/usr/bin/sudo #{args.first}\"\n\t end\n end",
"def sudo(*args)\r\n if ENV[\"USER\"] != \"root\"\r\n command = \"sudo #{args.join(\" \")}\"\r\n puts \"Please enter your p... | [
"0.7709836",
"0.7676741",
"0.76273125",
"0.75933117",
"0.756167",
"0.756167",
"0.756167",
"0.7511252",
"0.74195564",
"0.7414813",
"0.7364601",
"0.7364601",
"0.7364601",
"0.7234038",
"0.7188771",
"0.7122476",
"0.70784956",
"0.70206404",
"0.6988603",
"0.69788253",
"0.6918162",
... | 0.6839364 | 21 |
get the args, environment and spawning options | def process_command(*args, pre: nil, post: nil, wrap: nil, **opts)
spawn_opts={}
if args.last.kind_of?(Hash)
#we may have no symbol keywords
*args,spawn_opts=*args
end
sudo=opts.delete(:sudo)
env={}
if args.first.kind_of?(Hash)
env,*args=*args
end
env.merge!(opts.delete(:env)||{})
args=args.map.with_index {|arg, i| i == 0 && arg.is_a?(Array) ? arg : arg.to_s} if args.length > 1
spawn_opts.merge!(opts)
if pre
if args.length > 1
args=args.unshift(*pre)
else
args=["#{pre.is_a?(Enumerable) ? pre.shelljoin : pre} #{args.first}"]
end
end
if post
if args.length > 1
args=args.push(*post)
else
args=["#{args.first} #{post.is_a?(Enumerable) ? post.shelljoin : post}"]
end
end
if wrap
args=wrap.call(*args)
end
if sudo
if args.length > 1
args.unshift(*Run.sudo_args(sudo))
else
args=["#{Run.sudo_args(sudo).shelljoin} #{args.first}"]
end
end
return env, args, spawn_opts
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def spawn_args\n result = Array.new\n unless environment.empty?\n result << environment\n end\n result.concat(command_line)\n opts = Hash.new\n opts[:chdir] = directory.to_s unless directory.nil?\n opts[:pgroup] = pgroup unless pgroup.nil?\n opts[:umask] = umask unless umask.nil?\n ... | [
"0.7074211",
"0.64116734",
"0.6215496",
"0.6203648",
"0.61991507",
"0.61701554",
"0.613373",
"0.6133363",
"0.6116852",
"0.6111595",
"0.60980874",
"0.6075218",
"0.6071613",
"0.60379964",
"0.6032503",
"0.5999567",
"0.59917104",
"0.59847397",
"0.5954465",
"0.5940333",
"0.5924663... | 0.0 | -1 |
Run a command by default capture stdout and status callbacks: yield status.success?, out, err, status if block_given? if status.success? => on_success.call(status, out, err) else error_mode.call(status, out, error) rescue ... => fail_mode.call(e) return status, out, error | def run(*args, output: :capture, error: nil, fail_mode: :error, chomp: false, sudo: false, error_mode: nil, expected: nil, on_success: nil, quiet: nil, **opts)
env, args, spawn_opts=Run.process_command(*args, sudo: sudo, **opts)
if args.is_a?(Array)
if args.length > 1
launch=args.shelljoin
else
launch=args.first #assume it has already been escaped
end
else
launch=args.to_s
end
launch+=" 2>/dev/null" if error==:quiet or quiet
launch+=" >/dev/null" if output==:quiet
out=err=nil
begin
if error==:capture
out, err, status=Open3.capture3(env, launch, spawn_opts)
elsif output==:capture
out, status=Open3.capture2(env, launch, spawn_opts)
else
system(env, launch, spawn_opts)
status=$?
end
rescue => e
status=false
case fail_mode
when :error
raise e
when :empty
out=""
when :nil
out=nil
when Proc
fail_mode.call(e)
end
end
status=ProcessStatus.new(status, expected) if expected
status_success=status.success? if status.respond_to? :success?
yield status_success, out, err, status if block_given?
if status_success
# this block is called in case of success
on_success.call(status, out, err) if on_success.is_a?(Proc)
else # the command failed
case error_mode
when :nil
out=nil
when :empty
out=""
when :error
raise RunError.new("Error running command '#{launch}': #{status}")
when Proc
error_mode.call(status, out, err)
end
end
if chomp and out
case chomp
when :line, :lines
#out is now an array
out=out.each_line.map {|l| l.chomp}
else
out.chomp!
end
end
# return out, error, status if error
return status, out, err
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run_simple(*command, **opts, &b)\n\t\t\t# here the block is called in case of error\n\t\t\topts[:error_mode]=b if b\n\t\t\t_status, out, _error = run(*command, **opts)\n\t\t\treturn out\n\t\tend",
"def exec!(command, opts = {}, &block)\n # Options\n stdout = ''\n stderr = ''\n defaults = {\n ... | [
"0.7011632",
"0.6836752",
"0.6826897",
"0.6470505",
"0.6403534",
"0.63592654",
"0.629922",
"0.62245286",
"0.61931956",
"0.6181395",
"0.6172922",
"0.6135545",
"0.61332357",
"0.6131948",
"0.61298037",
"0.61162025",
"0.60504925",
"0.6006173",
"0.6000912",
"0.59675074",
"0.594106... | 0.5854892 | 28 |
a simple wrapper for %x// return the output; the block is called in case of an error eg SH.run_simple("echo foo; false") do p "error" end => returns "foo\n" and prints error | def run_simple(*command, **opts, &b)
# here the block is called in case of error
opts[:error_mode]=b if b
_status, out, _error = run(*command, **opts)
return out
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def shell(command, output: false)\n command += ' > /dev/null 2>&1' if !output\n system(command)\nrescue => e\n lex(e, \"Failed to execute shell command: #{command}\")\nend",
"def run_with_err_output(command)\n %x{ #{command} 2>&1 }\n end",
"def run_with_err_output(command)\n %x{ #{command} 2>&1... | [
"0.64788306",
"0.617657",
"0.617657",
"0.617657",
"0.617657",
"0.6033662",
"0.5891874",
"0.5813835",
"0.5809125",
"0.57780266",
"0.5708842",
"0.57082254",
"0.5693914",
"0.56779873",
"0.56779873",
"0.5641628",
"0.5633858",
"0.5630246",
"0.5630246",
"0.562765",
"0.56149197",
... | 0.6605023 | 0 |
like run, but only returns status.success? | def run_success(*command, **opts, &b)
status, _out, _error = run(*command, **opts, &b)
status.success?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run_succeeded; end",
"def ok?\n run unless ran?\n\n @status.success?\n end",
"def run_and_success?(cmd)\n run(cmd).success?\n end",
"def successful?\n status_code == 0 ? true : false\n end",
"def success?\n status == \"ok\"\n end",
"def success?\n\t\t!!( @status and @stat... | [
"0.740273",
"0.73822653",
"0.7127849",
"0.70720863",
"0.6990886",
"0.69873726",
"0.69872326",
"0.6932423",
"0.6881067",
"0.68778133",
"0.68778133",
"0.6872525",
"0.68579215",
"0.6847107",
"0.68411094",
"0.6831425",
"0.6831425",
"0.682769",
"0.68264055",
"0.6818267",
"0.681826... | 0.7697153 | 0 |
TODO: handle non default options, 'error: :capture' would imply we need to return "", "", false | def run(*command)
if !@interrupted
begin
return Run.run(*command)
rescue Interrupt #interruption
@interrupted=true
return "", false
end
else
return "", false
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def not_valid_message; nil; end",
"def not_valid_message; nil; end",
"def auto_capture?\n true\n end",
"def full_error(attribute_name, options = T.unsafe(nil)); end",
"def error\n return {error: \"\"}\n end",
"def error_message\n # :nocov:\n options.fetch(:messages, :valid)\n # :nocov:\n... | [
"0.5621898",
"0.5621898",
"0.56142014",
"0.55396867",
"0.55315727",
"0.5518866",
"0.549985",
"0.5498677",
"0.5498677",
"0.5498677",
"0.549789",
"0.54764676",
"0.54562706",
"0.54193854",
"0.5405916",
"0.5405916",
"0.5405916",
"0.5405916",
"0.5403348",
"0.5363851",
"0.53442454"... | 0.0 | -1 |
Create the ProcessStatus with the given status. respond to success?,exitstatus,status status:: if this responds to exitstatus, that method is used to extract the exit code. If it's an Int, that is used as the exit code. Otherwise, it's truthiness is used: 0 for truthy, 1 for falsey. expected:: an Int or Array of Int representing the expected exit status, other than zero, that represent "success". Ex usage: stdout,stderr,status = DR::Run.run_command(command,opts) process_status = DR::ProcessStatus.new(status,expected) | def initialize(status,expected=nil)
@status=status
@exitstatus = derive_exitstatus(status)
@success = ([0] + Array(expected)).include?(@exitstatus)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_status\n return status if pid.nil?\n\n pre_status = `#{check_status_command}`\n unless pre_status.nil? || pre_status.empty?\n state = check_process_status(pre_status)\n completed?(state) ? check_completed_status : state\n else\n failed? ? status : check_completed_status\n en... | [
"0.61326844",
"0.6061271",
"0.6034269",
"0.59792274",
"0.5920721",
"0.59199893",
"0.5913715",
"0.591081",
"0.5898751",
"0.58847344",
"0.5833992",
"0.5814524",
"0.57796246",
"0.5766468",
"0.5712678",
"0.5707898",
"0.5656789",
"0.5635441",
"0.5630556",
"0.5616675",
"0.56082857"... | 0.66277504 | 0 |
True if the exit status was a successul (i.e. expected) one. | def success?
@success
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def success?\n exit_status == 0\n end",
"def success?\n exit_code == 0\n end",
"def success?\n\t\t!!( @status and @status.exitstatus == 0 )\n\tend",
"def success?\n # note that Linux ruby returns nil when exitstatus is nil and a termsig\n # value is set instead.\n ret... | [
"0.8943202",
"0.87519526",
"0.86374843",
"0.86226577",
"0.8569052",
"0.8285085",
"0.8118007",
"0.7973803",
"0.7765684",
"0.7758126",
"0.7717605",
"0.7703625",
"0.7703303",
"0.7660031",
"0.7648566",
"0.76404554",
"0.74608326",
"0.7444842",
"0.7443573",
"0.74349487",
"0.7415843... | 0.0 | -1 |
ETA stands for Estimated Time of Arrival. | def fmt_eta
if @current.zero?
"ETA: --:--:--"
else
_elapsed = elapsed
eta = _elapsed * @total / @current - _elapsed
"ETA: #{fmt_interval_for eta}"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def eta\n if @current == 0\n \"ETA: --:--:--\"\n else\n elapsed_time = Time.now - @start_time\n estimated_time = elapsed_time * @total / @current - elapsed_time\n sprintf(\"ETA: %s\", format_time(estimated_time))\n end\n end",
"def eta\n if @current == 0\n ... | [
"0.75593525",
"0.7387451",
"0.73453784",
"0.6678",
"0.6406931",
"0.6378751",
"0.6249584",
"0.6075912",
"0.5718972",
"0.5562073",
"0.53420085",
"0.51398253",
"0.5098228",
"0.5078685",
"0.49513492",
"0.49457565",
"0.4807016",
"0.47731495",
"0.47486722",
"0.4733016",
"0.47292352... | 0.72982085 | 3 |
Compute ETA with running average (better suited to long running tasks) | def fmt_eta_running_average
now = Time.now
# update throughput running average
if @total > 0 && @eta_previous && @eta_previous_time
current_elapsed = @current - @eta_previous
alpha = 0.9 ** current_elapsed
current_progress = 1.0 * current_elapsed
current_throughput = current_progress / (now - @eta_previous_time)
@eta_throughput = (
if @eta_throughput
@eta_throughput * alpha + current_throughput * (1-alpha)
else
current_throughput
end
)
end
@eta_previous = @current
@eta_previous_time = now
if @eta_throughput && @eta_throughput > 0
eta = (@total - @current) / @eta_throughput
"ETA: #{fmt_interval_for eta}"
else
"ETA: --:--:--"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def running_average; end",
"def running_average=(_arg0); end",
"def average\n return @@average_times.inject(:+).to_f / @@average_times.size\n end",
"def average_runtime(days=30)\n latest_executions(days).average(:runtime)&.to_f\n end",
"def average_usage\n\t\treturn 0.0 if @run_count.zero?\n\t\t(@t... | [
"0.7231117",
"0.673263",
"0.67165077",
"0.65913785",
"0.64136523",
"0.6271754",
"0.6222372",
"0.62042624",
"0.6179353",
"0.6071684",
"0.6069927",
"0.6055157",
"0.60510653",
"0.6035105",
"0.60182357",
"0.6016782",
"0.59427184",
"0.59326583",
"0.5920005",
"0.5897052",
"0.587464... | 0.735183 | 0 |
before_action :admin, [:edit, :create, :update, :destroy] | def index
if params[:players]
respond_with PlayersGame.where(:game_id => params[:players])
elsif params[:reserves]
respond_with PlayersGame.where(:game_id => params[:reserves], :reserve => true)
elsif params[:game_id] && params[:user_id]
respond_with PlayersGame.where(:game_id => params[:game_id], :user_id => params[:user_id])
else
respond_with PlayersGame.all
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def before_action \n end",
"def admin\n\n end",
"def admin\n end",
"def admin\n end",
"def admin\n end",
"def admin\n end",
"def admin\n #TODO\n end",
"def admin_tab(*actions)\n self.admin_actions = actions\n end",
"def edit\n #SET_CHEF method will be called form BEFORE_... | [
"0.75283086",
"0.72288364",
"0.7212634",
"0.7212634",
"0.7212634",
"0.7212634",
"0.7082463",
"0.70497525",
"0.6815029",
"0.66006416",
"0.65452814",
"0.6541276",
"0.6534593",
"0.65159726",
"0.65003973",
"0.649691",
"0.6463156",
"0.6439857",
"0.64297444",
"0.6368392",
"0.635693... | 0.0 | -1 |
Initializes the recorder with options of: | def initialize(task, options)
super
@cache = {}
@dir = options[:dir]
if @dir.nil?
@dir = File.join('db', task.full_name.gsub(':', '/'))
end
@dir = File.expand_path(@dir.strip)
@results_path = options[:results_path]
@results_path.strip! unless @results_path.nil?
if Dir.exist?(@dir)
Dir.glob(File.join(@dir, '*.json')).each do |path|
load(path)
end
else
`mkdir -p #{@dir}`
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize()\n @options = { }\n end",
"def init(options={})\n\t\t@song_id = options[:song_id]\n\t @number_lines = options[:number_lines]\n\t \t\n\tend",
"def initialize(options); end",
"def initialize(options); @options = options end",
"def initialize\n @options = {}\n end",
"def initia... | [
"0.6685692",
"0.6680352",
"0.65553725",
"0.65460044",
"0.65077406",
"0.65077406",
"0.65077406",
"0.6487921",
"0.64396167",
"0.64396167",
"0.64157355",
"0.64019614",
"0.640162",
"0.6363801",
"0.6340462",
"0.6331285",
"0.6321398",
"0.62823117",
"0.6256341",
"0.62385726",
"0.623... | 0.0 | -1 |
friendly URL for SEO Ref. pagy fancy routes Ref. | def pagy_url_for(page, pagy)
params = request.query_parameters.merge(:only_path => true, pagy.vars[:page_param] => page )
url_for(params)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def permalink\n return \"#{uri}\"\n end",
"def permalink; end",
"def permalink; end",
"def friendly_url\n uri = URI(url)\n uri.scheme + \"://\" + uri.host\n end",
"def permalink\n link = object.path.gsub(\"::\", \"%2F\")\n link.tr!(\"?\", \"%3F\")\n link.tr!(\"... | [
"0.67383915",
"0.65870506",
"0.65870506",
"0.6519953",
"0.6441486",
"0.6408997",
"0.6406323",
"0.63929844",
"0.6331359",
"0.632834",
"0.63223654",
"0.6308993",
"0.62889504",
"0.6288566",
"0.6288566",
"0.62834185",
"0.62834185",
"0.6260288",
"0.6242293",
"0.62233204",
"0.62178... | 0.0 | -1 |
Stores a dependency on the Pod. | def required_by(dependency, dependent_name)
dependencies_by_requirer_name[dependent_name] ||= []
dependencies_by_requirer_name[dependent_name] << dependency
dependencies << dependency
if acceptable_versions.empty?
message = "Unable to satisfy the following requirements:\n\n"
dependencies_by_requirer_name.each do |name, dependencies|
dependencies.each do |dep|
message << "- `#{dep}` required by `#{name}`\n"
end
end
raise Informative, message
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_dependency\n @dependency = Dependency.find(params[:id])\n end",
"def add_dependency(path, dependency); end",
"def add_dependency(dependency)\n unless has_dependency?(dependency.name, dependency.constraint)\n @dependencies[Graph.key_for(dependency)] = dependency\n en... | [
"0.66058755",
"0.6568266",
"0.651708",
"0.6501206",
"0.6472764",
"0.6385836",
"0.6349778",
"0.6326796",
"0.6326656",
"0.6236215",
"0.6218522",
"0.62161803",
"0.61618227",
"0.6120891",
"0.60600525",
"0.5810226",
"0.57962483",
"0.57240975",
"0.5683624",
"0.56735164",
"0.5671983... | 0.0 | -1 |
Use callbacks to share common setup or constraints between actions. | def set_direction
@direction = Direction.find_by_id(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.6163821",
"0.6045432",
"0.5945441",
"0.5916224",
"0.58894575",
"0.5834073",
"0.57764685",
"0.5702474",
"0.5702474",
"0.5653258",
"0.56211996",
"0.54235053",
"0.5410683",
"0.5410683",
"0.5410683",
"0.53948104",
"0.5378064",
"0.5356684",
"0.53400385",
"0.53399503",
"0.533122... | 0.0 | -1 |
Only allow a trusted parameter "white list" through. | def direction_params
params.require(:direction).permit(:content, :load_id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allowed_params\n ALLOWED_PARAMS\n end",
"def expected_permitted_parameter_names; end",
"def param_whitelist\n [:role, :title]\n end",
"def default_param_whitelist\n [\"mode\"]\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def permitted_params\n []\n end",
... | [
"0.7122899",
"0.7054107",
"0.69478",
"0.6902101",
"0.67359334",
"0.67178756",
"0.66889167",
"0.6677724",
"0.6661157",
"0.6555896",
"0.6527207",
"0.64584696",
"0.64517015",
"0.6450208",
"0.644749",
"0.6435074",
"0.6413329",
"0.6413329",
"0.6391818",
"0.6380081",
"0.6380081",
... | 0.0 | -1 |
Returns a score from 0 to 1, and then the full results | def score(text, stream_id)
return [-1, {}] unless PerspectiveApi.enabled
result = make_request(text, stream_id)
Rails.logger.info("CommentAnalyzer: #{result}")
return handle_error(result) if result["error"]
[result["attributeScores"]["TOXICITY"]["summaryScore"]["value"], result]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def score\n @scores[ result.key ]\n end",
"def score\n @result.to_i\n end",
"def score\n 2 * won + drawn + noresult\n end",
"def score\n end",
"def score; end",
"def score\n @score || calculate_score\n end",
"def score\n calculator.score\n end",
"def score\n @score\n ... | [
"0.7600353",
"0.7571748",
"0.7324065",
"0.72360593",
"0.72146136",
"0.71766394",
"0.715709",
"0.7077893",
"0.7020597",
"0.7002103",
"0.6982921",
"0.6950009",
"0.6912479",
"0.69073015",
"0.68989617",
"0.6890677",
"0.689029",
"0.687526",
"0.68684596",
"0.6847431",
"0.6847431",
... | 0.0 | -1 |
set related object id which could either be a datafile or an intentity object | def setRelatedObject objid
attribute_set(:relatedObjectId, objid)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_object_attachment\n @object_attachment = ObjectAttachment.find(params[:id])\n end",
"def set_object\n @object = Object.find(params[:id])\nend",
"def set_object_owner\n @object_owner = ObjectOwner.find(params[:id])\n end",
"def id\n object.object_id\n end",
"def circle_id=(id)\n... | [
"0.63426656",
"0.632698",
"0.6325517",
"0.6301453",
"0.62489164",
"0.6213287",
"0.6209661",
"0.61967945",
"0.6179507",
"0.61776567",
"0.61416453",
"0.613712",
"0.61264503",
"0.61264503",
"0.61264503",
"0.61264503",
"0.61264503",
"0.61264503",
"0.61264503",
"0.6118311",
"0.611... | 0.8064846 | 0 |
is the person logged in | def is_logged_in?
session[:user_id].present?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def person_logged_in?\n !session[:person_id].nil?\n end",
"def logged_in?\n !current_person.nil?\n end",
"def logged_in?\n !current_person.nil?\n end",
"def logged_in?\n current_user.is_a? Person\n end",
"def logged_in?\n !!logged_user\n end",
"def logged_in?\n ... | [
"0.8537413",
"0.8432195",
"0.8432195",
"0.83820975",
"0.82820946",
"0.82782227",
"0.82782227",
"0.8268333",
"0.82637197",
"0.8262613",
"0.8262613",
"0.8262613",
"0.8262613",
"0.82408094",
"0.82388794",
"0.82181334",
"0.8216473",
"0.8202317",
"0.81914264",
"0.8190501",
"0.8182... | 0.0 | -1 |
check admin login status | def check_admin
@user = find_current_user
unless @user.present? and @user.is_admin?
redirect_to root_path
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def admin?\n if self.login == \"admin\"\n return true\n else\n return false\n end\n end",
"def check_admin_status\n if current_user.nil? || !current_user.admin?\n flash[:alert] = \"Access denied. Please login as an admin user\"\n redirect_to root_url\n end\n end",
... | [
"0.8057303",
"0.79849666",
"0.79849666",
"0.7874759",
"0.7852257",
"0.78293777",
"0.77639043",
"0.773781",
"0.7709763",
"0.7640725",
"0.7605014",
"0.76047254",
"0.7496028",
"0.74899894",
"0.7477872",
"0.7473001",
"0.74697393",
"0.74672234",
"0.74183285",
"0.73983246",
"0.7390... | 0.72507375 | 48 |
Mask the id with the slug value | def id
object.slug
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def slug_base_string\n self.id || sluggify\n end",
"def id\n slug\n end",
"def normalize_friendly_id(slug_str)\n super.gsub(\"-\", \"\")\n end",
"def extra_slug\n extra_slugs[id]\n end",
"def normalize_friendly_id(string)\n if slug.blank?\n super\n else\n super(slug)\n en... | [
"0.7398",
"0.7226304",
"0.72065926",
"0.7161954",
"0.7121236",
"0.7117952",
"0.7053512",
"0.7050174",
"0.7000609",
"0.69890994",
"0.69776046",
"0.69776046",
"0.69776046",
"0.6935429",
"0.6932082",
"0.69167286",
"0.6905052",
"0.6905052",
"0.6896504",
"0.68828905",
"0.68761927"... | 0.67234665 | 34 |
Returns user avatar URL | def avatar_url
avatar_uri(object)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def avatar_url\r\n return @user.avatar_url\r\n end",
"def avatar_url(user)\n if user.avatar_url.present?\n user.avatar_url\n else\n default_url = \"#{root_url}images/guest.png\"\n gravatar_id = Digest::MD5.hexdigest(user.email.downcase)\n \"http://gravatar.com/avatar/#{gravatar_id}.... | [
"0.8668833",
"0.85854214",
"0.85846674",
"0.85189915",
"0.8406629",
"0.8394491",
"0.8376643",
"0.8334783",
"0.83249",
"0.8310429",
"0.83065206",
"0.8138395",
"0.8128213",
"0.812395",
"0.810859",
"0.8093084",
"0.8091594",
"0.80690354",
"0.80690354",
"0.8045902",
"0.8036571",
... | 0.8562967 | 3 |
User contacts TODO: Delegate a separate endpoint to avoid preloading huge data set | def contact_ids
(object.added_contacts + object.mutual_contacts).map{|ct| ct.slug }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n\t@title = \"My Contacts\"\n\t@users = []\n\tcontacteds = Relationship.where(\"accessed_id = ? AND accepted = ?\", current_user.id, true).paginate(:page => params[:page])\n\tcontactors = Relationship.where(\"accessor_id = ? AND accepted = ?\", current_user.id, true).paginate(:page => params[:page])\n\tc... | [
"0.64878315",
"0.645934",
"0.6445647",
"0.6411761",
"0.64110035",
"0.6401088",
"0.6396814",
"0.63257563",
"0.6323248",
"0.6241696",
"0.6213387",
"0.6211114",
"0.6198921",
"0.61836994",
"0.6179891",
"0.6157734",
"0.6153709",
"0.6084515",
"0.6063071",
"0.6050845",
"0.6047824",
... | 0.0 | -1 |
Filters out some keys from other users | def filter(keys)
if !scope.id.eql?(object.id)
keys - %i{conversations summaries contact_ids} -
%i{created_friendships friendships}
else
keys
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def filter_users\n allowed_keys=[\"email\", \"admin\"]\n filtering_keys=allowed_keys & params.keys\n filtering_keys.each {|key| filter_by_key(key)}\n end",
"def filter(keys)\n unless context.can_read?(object, :contact)\n keys.delete(:contact)\n keys.delete(:location)\n end\n ... | [
"0.7269694",
"0.72138286",
"0.71142024",
"0.7010204",
"0.69528776",
"0.6625288",
"0.65363073",
"0.6367329",
"0.6223997",
"0.6193341",
"0.6159",
"0.6159",
"0.6091708",
"0.5955461",
"0.59374106",
"0.59349275",
"0.59043795",
"0.5894461",
"0.58423376",
"0.5814617",
"0.5774575",
... | 0.5905648 | 16 |
rubypostgress RPM installs postgres.so in /usr/lib/site_ruby/1.8/i386linux however on CentOS ruby 'sitearchdir' is /usr/lib/site_ruby/1.8/i386linuxgnu this function tries to load postgres from both places On Suse 'postgres' is installed as ruby gem: loading rubygems explictely enables us to find it. | def load_postgres_driver()
require 'postgres'
rescue LoadError
require 'rubygems'
require 'rbconfig'
sad = Config::CONFIG['sitearchdir']
postgres_dir = sad.chomp('-gnu')
$:.unshift(postgres_dir)
require 'postgres'
rescue LoadError
# On SUSE, FreeBSD the driver is called ruby-postgres and is a gem
require 'ruby-postgres'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def install_postgres\n #sudo_and_log(vm, 'puppet apply -e \"include postgresql::server\"')\n # TODO: implement\n end",
"def binary_path_for(version)\n \"/opt/#{ChefUtils::Dist::Org::LEGACY_CONF_DIR}/embedded/postgresql/#{version}/bin\"\n end",
"def psql_environment\n return {} unless platform... | [
"0.6609672",
"0.6165365",
"0.60466534",
"0.6030732",
"0.5926245",
"0.5904204",
"0.5504074",
"0.53403014",
"0.51705354",
"0.51449794",
"0.51402843",
"0.5136332",
"0.51210386",
"0.5079336",
"0.50777555",
"0.5055557",
"0.504605",
"0.502103",
"0.50206447",
"0.49826682",
"0.496552... | 0.7614672 | 0 |
the mutation method _obj is parent object, which in this case is nil args are the arguments passed _ctx is the GraphQL context (which would be discussed later) | def call(_obj, args, _ctx)
User.create!(
name: args[:name],
email: args[:authProvider][:email][:email],
password: args[:authProvider][:email][:password]
)
rescue ActiveRecord::RecordInvalid => e
GraphQL::ExecutionError.new("Invalid input: #{e.record.errors.full_messages.join(', ')}")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update!(**args)\n @mutation_context = args[:mutation_context] if args.key?(:mutation_context)\n end",
"def update!(**args)\n @mutation_context = args[:mutation_context] if args.key?(:mutation_context)\n end",
"def update!(**args)\n @mutation_context = args[:mutation... | [
"0.6561641",
"0.6561641",
"0.6561641",
"0.5902161",
"0.58604777",
"0.5801928",
"0.56946945",
"0.56938946",
"0.54495525",
"0.5356692",
"0.5351187",
"0.53031605",
"0.52596635",
"0.52241874",
"0.51919806",
"0.51544416",
"0.51544416",
"0.5143973",
"0.5121275",
"0.5087864",
"0.507... | 0.0 | -1 |
Defines a "skip_validation_for" method to use in controllers. | def skip_validation_for(*args)
args.each { |attr| send("skip_#{attr}_validation=", true) }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def skip_validations\n true\n end",
"def perform_validation?\n self.skip_validation == true ? false : true\n end",
"def without_auto_validations\n previous, @disable_auto_validations = @disable_auto_validations, true\n yield\n ensure\n @disable_auto_validations = previous\... | [
"0.725425",
"0.62907225",
"0.62515557",
"0.6226354",
"0.6150103",
"0.5861905",
"0.5778395",
"0.5658505",
"0.5627011",
"0.559869",
"0.5548173",
"0.55381775",
"0.5523242",
"0.5499263",
"0.5465004",
"0.5287236",
"0.5255519",
"0.52336943",
"0.5217416",
"0.51808697",
"0.51808697",... | 0.8053853 | 0 |
Incorporate code for call Google book search API up to 4 times to retrieve book covers using a list of isbn numbers obtained from Solr. Multiple calls to Google are required because the Books Search API returns 0 hits if the request contains more than 3 or 4 isbn numbers. Only for prototyping and usability testing purposes as multiple Google calls per search incurs significance performance issues. | def index
extra_head_content << '<link rel="alternate" type="application/rss+xml" title="RSS for results" href="'+ url_for(params.merge("format" => "rss")) + '">'
extra_head_content << '<link rel="alternate" type="application/atom+xml" title="Atom for results" href="'+ url_for(params.merge("format" => "atom")) + '">'
(@response, @document_list) = get_search_results
@filters = params[:f] || []
if Blacklight.config[:data_augmentation][:enabled] and !(params[:q].blank? and params[:f].blank? and params[:search_field].blank?)
get_gdata_for_result_list
end
respond_to do |format|
format.html { save_current_search_params }
format.mobile { save_current_search_params }
format.rss { render :layout => false }
format.atom { render :layout => false }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_books(books, library, stream)\n @library_branch_location = library\n stream << \"data: status: Finding which books are available...\\n\\n\"\n book_available = false\n\n books.each do |book|\n # get related isbns and limit collection to a maximum of 20 ISBNs\n related_isbns = get_related_isbns(bo... | [
"0.6625029",
"0.6366716",
"0.6361389",
"0.62569714",
"0.6241057",
"0.62154657",
"0.6184521",
"0.615263",
"0.615263",
"0.61069036",
"0.60659707",
"0.6058246",
"0.6042958",
"0.6026087",
"0.6014459",
"0.59877557",
"0.5957169",
"0.5951362",
"0.5941844",
"0.588154",
"0.57968855",
... | 0.0 | -1 |
Blacklight solr_helper method override for a,b,..z alphabetic range faceting navigation, to contruct the appropriate solr_params to retrieve the additional az facets (if) | def solr_facet_params(facet_field, extra_controller_params={})
input = params.deep_merge(extra_controller_params)
solr_params = solr_search_params(extra_controller_params)
# add additional facet.field parameter to retrieve any a-z facets
# e.g. solr_params[:"facet.field"] = [author_facet, "author_first_letter"]
if Blacklight.config[:facet][:a_to_z].has_key? facet_field
solr_params[:"facet.field"] = [facet_field, Blacklight.config[:facet][:a_to_z][facet_field]]
else
solr_params[:"facet.field"] = facet_field
end
solr_params[:"f.#{facet_field}.facet.limit"] =
if solr_params["facet.limit"]
solr_params["facet.limit"] + 1
elsif respond_to?(:facet_list_limit)
facet_list_limit.to_s.to_i + 1
else
20 + 1
end
# use facet.prefix to filter out outliers not corresponding a particular alphabet facet
solr_params['facet.prefix'] = extra_controller_params[:"catalog_facet.prefix"].upcase if extra_controller_params.has_key?("catalog_facet.prefix")
solr_params['facet.offset'] = input[ Blacklight::Solr::FacetPaginator.request_keys[:offset] ].to_i
solr_params['facet.sort'] = input[ Blacklight::Solr::FacetPaginator.request_keys[:sort] ]
solr_params[:rows] = 0
return solr_params
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_facet_pagination(facet_field, extra_controller_params={})\n solr_params = solr_facet_params(facet_field, extra_controller_params)\n response = Blacklight.solr.find(solr_params)\n\n limit = \n if respond_to?(:facet_list_limit)\n facet_list_limit.to_s.to_i\n elsif solr_params[... | [
"0.7011298",
"0.6808116",
"0.6803596",
"0.6780563",
"0.6562484",
"0.64648366",
"0.6315702",
"0.6313941",
"0.6205646",
"0.6196245",
"0.61594087",
"0.61472356",
"0.6124643",
"0.61106324",
"0.61003876",
"0.60886186",
"0.60849065",
"0.605358",
"0.5987499",
"0.59659994",
"0.594879... | 0.6674423 | 4 |
Blacklight solr_helper method override for a,b,..z alphabetic range faceting navigation, to contruct either a facet paginator or a hash consisting two facet paginators (the intended facets + the az facets) | def get_facet_pagination(facet_field, extra_controller_params={})
solr_params = solr_facet_params(facet_field, extra_controller_params)
response = Blacklight.solr.find(solr_params)
limit =
if respond_to?(:facet_list_limit)
facet_list_limit.to_s.to_i
elsif solr_params[:"f.#{facet_field}.facet.limit"]
solr_params[:"f.#{facet_field}.facet.limit"] - 1
else
nil
end
intended_facets = response.facets.select {|facet| facet.name.include?(facet_field)}.first.items
intended_paginator = Blacklight::Solr::FacetPaginator.new(intended_facets,
:prefix => solr_params['facet.prefix'],
:offset => solr_params['facet.offset'],
:limit => limit,
:sort => response["responseHeader"]["params"]["f.#{facet_field}.facet.sort"] || response["responseHeader"]["params"]["facet.sort"]
)
if Blacklight.config[:facet][:a_to_z].has_key? facet_field
extra_controller_params.delete(Blacklight.config[:facet][:a_to_z][facet_field])
prefix = extra_controller_params["catalog_facet.prefix"]
extra_controller_params.delete("catalog_facet.prefix") # in order to retrieve the a-z facet listing
extra_controller_params["catalog_facet.offset"]=0
extra_controller_params["catalog_facet.sort"]= "index"
solr_params = solr_facet_params(facet_field, extra_controller_params)
response = Blacklight.solr.find(solr_params)
a_to_z_facets = response.facets.select {|facet| facet.name.include?(Blacklight.config[:facet][:a_to_z][facet_field])}.first.items
a_to_z_paginator = Blacklight::Solr::FacetPaginator.new(a_to_z_facets,
:prefix => prefix,
:offset => solr_params['facet.offset'],
:limit => limit,
:sort => response["responseHeader"]["params"]["f.#{facet_field}.facet.sort"] || response["responseHeader"]["params"]["facet.sort"]
)
return { facet_field => intended_paginator, Blacklight.config[:facet][:a_to_z][facet_field] => a_to_z_paginator }
else
return intended_paginator
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def facet\n @pagination = get_facet_pagination\n end",
"def facet\n @pagination = get_facet_pagination(params[:id])\n end",
"def get_facet_pagination(facet_field, extra_controller_params={})\n Blacklight::Solr::Facets.paginate solr_facet_params(facet_field, extra_controller_params)\n end",
"def f... | [
"0.7257467",
"0.6730364",
"0.66500604",
"0.6539071",
"0.6509848",
"0.6506878",
"0.6464015",
"0.6452845",
"0.642354",
"0.6411844",
"0.6362951",
"0.6346786",
"0.6326604",
"0.6299715",
"0.6279214",
"0.62653",
"0.6259464",
"0.6224254",
"0.62183046",
"0.62112945",
"0.6196159",
"... | 0.7584771 | 0 |
remember URL params (ordered) in session for URL reconstruction later | def delete_or_assign_orderly_search_session_params
session[:orderly_search_params] = {}
# params_for_ui encodes URL query and faceting parameters)
# in an orderly Dictionary Hash.
params_for_ui.each_pair do |key, value|
session[:orderly_search_params][key] = value
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def handle_remember_params\n remembered = remembered_params\n if params[:returning]\n # restore params\n remember_params.each {|p| params[p] ||= remembered[p] }\n end\n \n # store current params\n remember_params.each do |p| \n remembered[p] = params[p].presence\n... | [
"0.65826714",
"0.6355871",
"0.63032246",
"0.6248558",
"0.6239464",
"0.6158432",
"0.61566913",
"0.6153748",
"0.61374515",
"0.6098446",
"0.60725284",
"0.6070401",
"0.6067357",
"0.6034584",
"0.6034584",
"0.6034584",
"0.6034584",
"0.6034584",
"0.6034584",
"0.6034584",
"0.6034584"... | 0.61913127 | 5 |
DELETE /canvases/1 DELETE /canvases/1.json | def destroy
@collaborator = Collaborator.find(params[:id])
@collaborator.destroy
respond_to do |format|
format.html { redirect_to canvases_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n id = @api_v1_canvas.id\n @api_v1_canvas.destroy\n respond_to do |format|\n format.html do\n redirect_to api_v1_canvases_url, notice: 'Canvas was successfully destroyed.'\n end\n\n format.json do\n msg = { id: id }\n broadcast(\"deleted\", msg)\n hea... | [
"0.71891844",
"0.6962282",
"0.6847907",
"0.6692472",
"0.66737187",
"0.65284145",
"0.6497805",
"0.6497805",
"0.6497312",
"0.6495906",
"0.6467484",
"0.6463223",
"0.64537174",
"0.6452918",
"0.6430023",
"0.64264244",
"0.6423847",
"0.6398903",
"0.639681",
"0.639188",
"0.6388746",
... | 0.6440562 | 14 |
Add a bunch of methods that will be used in the model presenters | def related_to(*args)
@relations = args.map(&:to_s)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def methods() end",
"def methods; end",
"def methods; end",
"def methods; end",
"def methods; end",
"def add_method(method)\n @display.print_method method\n end",
"def helper_method(*methods); end",
"def display_method_list\n end",
"def helpers; end",
"def helpers; end",
"def helpers; end"... | [
"0.68333304",
"0.6556234",
"0.6556234",
"0.6556234",
"0.6556234",
"0.6197004",
"0.61139554",
"0.6084226",
"0.60791075",
"0.60791075",
"0.60791075",
"0.6049843",
"0.59745836",
"0.59451437",
"0.5852688",
"0.5838852",
"0.5835494",
"0.58234537",
"0.57935035",
"0.5749821",
"0.5739... | 0.0 | -1 |
Create the actual class method that will be used in the subclasses We use the splash operation '' to get all the arguments passed in an array | def build_with(*args)
@build_attributes = args.map(&:to_s)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def className _args\n \"className _args;\" \n end",
"def public_class_method(arg0, arg1, *rest)\n end",
"def public_class_method(*rest) end",
"def class=(_arg0); end",
"def args(*) end",
"def private_class_method(arg0, arg1, *rest)\n end",
"def create_method_for clazz , method_name , args\n ... | [
"0.68170804",
"0.6733538",
"0.66701037",
"0.64982975",
"0.6124721",
"0.61159164",
"0.61109024",
"0.6083601",
"0.6082062",
"0.59651047",
"0.59427226",
"0.59312123",
"0.5885445",
"0.5872304",
"0.5867006",
"0.584949",
"0.584949",
"0.584077",
"0.5829379",
"0.58088803",
"0.5798143... | 0.0 | -1 |
def get_quarter(years) arr = [] years.each do |y| arr << Date::MONTHNAMES.index(name) end arr end | def get_condition
operator = self.get_operator
format_as = self.format_as
arr = []
if format_as == 'Month'
if (self.comparison_operator == 5 && !self.predefined_range.nil?)
get_predefined_conditions(arr)
elsif(self.comparison_operator == 5 && self.date_range == true)
get_range_condition(arr)
elsif(self.comparison_operator == 5 && self.date_range == false)
get_reference_condition(arr)
else
values = get_months_index(self.get_filter_values)
arr << {"fieldName" => self.field_name, "formatAs" => format_as,"dataType" => "string",
"comparision" => operator, "value" => values}
end
elsif format_as == 'Month Year'
if self.get_filter_values
vals = []
self.get_filter_values.each do |val|
value = val.split(' ')
vals << "#{value[0]} "+("%02d" % Date::ABBR_MONTHNAMES.index(value[1]))
# vals << "#{value[0]} #{Date::ABBR_MONTHNAMES.index(value[1])}"
end
values=vals
end
arr <<
{"fieldName" => self.field_name, "formatAs" => format_as,"dataType" => "string",
"comparision" => self.get_operator,"value" => (values || nil)}
elsif format_as == 'Quarter'
arr <<
{"fieldName" => self.field_name, "formatAs" => format_as,"dataType" => "string",
"comparision" => self.get_operator,"value" => self.get_filter_values}
else
if (self.comparison_operator == 5 && !self.predefined_range.nil?)
get_predefined_conditions(arr)
elsif(self.comparison_operator == 5 && self.date_range == true)
get_range_condition(arr)
elsif(self.comparison_operator == 5 && self.date_range == false)
get_reference_condition(arr)
else
values = self.field_values ? self.get_filter_values : nil
arr << {"fieldName" => self.field_name, "formatAs" => format_as,"dataType" => "string",
"comparision" => operator, "value" => values}
end
end
arr
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def quarter\n case merch_month\n when 7,8,9\n return 1\n when 10,11,12\n return 2\n when 1,2,3\n return 3\n else\n return 4\n end\n end",
"def current_quarter\n \n case self.month\n \n when 1..3 then 1\n when 4..6 then 2\n when ... | [
"0.73370093",
"0.7160121",
"0.7127769",
"0.6980154",
"0.6913199",
"0.68402404",
"0.6754746",
"0.6446262",
"0.6402517",
"0.6331791",
"0.6331275",
"0.62964433",
"0.62322694",
"0.6190273",
"0.6046409",
"0.6005999",
"0.59876335",
"0.59526086",
"0.5937111",
"0.5929253",
"0.5924454... | 0.0 | -1 |
initialize the object with some basic settings | def initialize(file)
@file = file
@original_file = file
@status, @show, @season, @number, @name, @series_name = false, "", "", "", "", ""
@status, show, @season, @number = tv_file File.basename file
@season.gsub!(/^s/i,'')
@season.gsub!(/^0/,'') if @season != "0"
@number.gsub!(/^0/,'') if @number != "0"
@show = show_name_rename show
@series_name = @show
#@number.gsub!(/^/,'0') if @number.to_i < 10 and @number.to_i != 0
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize\n init\n end",
"def initialize\n set_defaults\n end",
"def initialize\n set_defaults\n end",
"def initialize()\n end",
"def initialize\r\n\r\n end",
"def initialize\n end",
"def initialize\n\t\t\n\tend",
"def initialize\n initialize!\n end... | [
"0.8183301",
"0.8124707",
"0.8124707",
"0.80614996",
"0.8010234",
"0.8005034",
"0.79807574",
"0.79709977",
"0.79709977",
"0.796846",
"0.7965883",
"0.7964042",
"0.7934146",
"0.7934146",
"0.79269755",
"0.79269755",
"0.79269755",
"0.7917858",
"0.7917858",
"0.7917858",
"0.7917858... | 0.0 | -1 |
return the status if the episode matches our expected syntax | def is_ep?
@status
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def episode?\n content_type == \"Episode\"\n end",
"def check_status\n @status = parser.parse\n end",
"def parse_condition; end",
"def parse_condition; end",
"def is_movie?\n @status\n end",
"def can_watch_episode?( episode, t = Time.now.utc )\n\t\tepisode.available?( t )\n\tend",
"def ... | [
"0.6165",
"0.572289",
"0.55816215",
"0.55816215",
"0.5570558",
"0.54713714",
"0.54148936",
"0.53806674",
"0.53493124",
"0.53308606",
"0.5304157",
"0.5267582",
"0.52555984",
"0.52293473",
"0.51880443",
"0.5180878",
"0.5177628",
"0.515688",
"0.515688",
"0.51357305",
"0.5131182"... | 0.567013 | 2 |
renames the file name based on tvdb and other local criteria when writing to a filesystem. | def fix_via_tvdb(episodes)
re_cache = true
log("attempting to fix name based on tvdb") if $config["settings"]["log_level"] > 4
@name = episodes[@show][@season][@number] if episodes[@show][@season]
ap episodes[@show] if $config["settings"]["log_level"] > 3
if not @name.nil? and @name != ""
re_cache = false
@name = CGI.unescapeHTML(@name)
@name.gsub!(/\//,'-')
@name.gsub!(/\?/,'')
@name.gsub!(/\:/,' ')
@name.gsub!(/\s+$/,'')
@show.gsub!(/\:/,'')
@number.gsub!(/^/,'0') if @number.to_i < 10 and @number.to_i != 0
@name = "#{@show_on_fs} [#{@season}x#{@number}] #{@name}"
@name.gsub!(/\s\s/,' ')
orig = @original_file
@file = File.dirname(orig) + "/" + @name + File.extname(File.basename(orig))
#FileUtils.mv(orig,@file,$options) if orig.downcase != @file.downcase
if orig != @file and $config["settings"]["fs_case_sensitive"] == true
log "fix_via_tvdb: #{orig} to #{@file}" if $config["settings"]["log_level"] > 1
FileUtils.mv(orig,@file,$options)
@original_file = @file
elsif orig.downcase != @file.downcase
log "fix_via_tvdb: #{orig} to #{@file}" if $config["settings"]["log_level"] > 1
begin
FileUtils.mv(orig,@file,$options) if not File.exist? @file
rescue => e
log("error: problem with target, reason #{e.to_s}")
exit 1
end
@original_file = @file
end
end
re_cache
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def renamed_filename\n @renamed_filename ||= \"CCAZ_WhiteList_#{user.preferred_username}::#{Time.current.to_i}.csv\"\n end",
"def set_file_name\n update(name: (file.filename rescue \"Untitled File\"))\n end",
"def set_file_name\n update(name: (file.filename rescue \"Untitled File\"))\n end",
"def... | [
"0.6303413",
"0.6133699",
"0.6133699",
"0.61063737",
"0.61063737",
"0.6064085",
"0.6014832",
"0.59726626",
"0.58932203",
"0.5891254",
"0.5829175",
"0.5802484",
"0.58004135",
"0.57842875",
"0.57326317",
"0.5724554",
"0.5716864",
"0.5716864",
"0.57102376",
"0.56683874",
"0.5654... | 0.68968874 | 0 |
initialize the object with some basic settings | def initialize(directory)
@directory = directory
@original_directory = directory
@status, @enrich_movie_full, @enrich_status = false, "", false
@title_full = File.basename directory
@status, name = movie_directory File.basename directory
@name = clean_movie_name name
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize\n init\n end",
"def initialize\n set_defaults\n end",
"def initialize\n set_defaults\n end",
"def initialize()\n end",
"def initialize\r\n\r\n end",
"def initialize\n end",
"def initialize\n\t\t\n\tend",
"def initialize\n initialize!\n end... | [
"0.8183057",
"0.8125436",
"0.8125436",
"0.8061613",
"0.80103856",
"0.80056775",
"0.79808706",
"0.7970032",
"0.7970032",
"0.79684615",
"0.7966377",
"0.79638404",
"0.7934081",
"0.7934081",
"0.792634",
"0.792634",
"0.792634",
"0.7918482",
"0.7918482",
"0.7918482",
"0.7918482",
... | 0.0 | -1 |
return the status if the movie matches our expected syntax | def is_movie?
@status
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_movie?\n self.type_of_show.downcase == \"movie\" ? true : false \n end",
"def movie?\n content_type == \"Movie\"\n end",
"def video?\n marc_leader_06_match = record.leader.byteslice(6) == 'g'\n marc_008_33_match = record.fields('008').find do |field|\n %w... | [
"0.6204257",
"0.6039348",
"0.591372",
"0.5834049",
"0.5807873",
"0.5792331",
"0.57593143",
"0.5736626",
"0.56539834",
"0.5641087",
"0.55894583",
"0.5532161",
"0.552683",
"0.55214006",
"0.54822654",
"0.54419595",
"0.54264426",
"0.54104465",
"0.5373185",
"0.5373185",
"0.5351077... | 0.704929 | 0 |
initialize the object with some basic settings | def initialize(file)
@file = file
@original_file = file
@status, @enrich_status = false, false
@status = music_file File.basename file
@name = clean_music_name name
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize\n init\n end",
"def initialize\n set_defaults\n end",
"def initialize\n set_defaults\n end",
"def initialize()\n end",
"def initialize\r\n\r\n end",
"def initialize\n end",
"def initialize\n\t\t\n\tend",
"def initialize\n initialize!\n end... | [
"0.8182397",
"0.8125647",
"0.8125647",
"0.8060451",
"0.8009079",
"0.80038387",
"0.7979805",
"0.7969913",
"0.7969913",
"0.79675996",
"0.7964511",
"0.79631525",
"0.79334503",
"0.79334503",
"0.7926295",
"0.7926295",
"0.7926295",
"0.79166037",
"0.79166037",
"0.79166037",
"0.79166... | 0.0 | -1 |
return the status if the movie matches our expected syntax | def is_music?
@status
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_movie?\n @status\n end",
"def is_movie?\n self.type_of_show.downcase == \"movie\" ? true : false \n end",
"def movie?\n content_type == \"Movie\"\n end",
"def video?\n marc_leader_06_match = record.leader.byteslice(6) == 'g'\n marc_008_33_match = record.fields('... | [
"0.7047551",
"0.6201582",
"0.6037572",
"0.5911912",
"0.5831348",
"0.5807203",
"0.5791853",
"0.57562417",
"0.57338107",
"0.5654857",
"0.56439686",
"0.55898494",
"0.55343324",
"0.5523432",
"0.55199033",
"0.5480751",
"0.5442448",
"0.5423866",
"0.54091877",
"0.5375778",
"0.537577... | 0.52651775 | 26 |
Send 'GET a diff' request | def find(spec, options = {})
get_path(path_to_find(spec), options)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def diff url\n parse_response HTTParty.get \"#{url}.diff\"\n end",
"def diff url\n gitlab_response = HTTParty.get \"#{url}.diff\", query: {\n private_token: @private_token\n }\n handle_response gitlab_response\n end",
"def getPullRequestDiff(id)\n response = getUrl(@url_... | [
"0.753157",
"0.7164328",
"0.7125347",
"0.70321697",
"0.6451615",
"0.6399115",
"0.6307791",
"0.6197576",
"0.6186564",
"0.61755806",
"0.6144918",
"0.6102346",
"0.6044423",
"0.59272546",
"0.5881989",
"0.58816993",
"0.58592325",
"0.58411795",
"0.5817731",
"0.5817731",
"0.5797193"... | 0.0 | -1 |
Send 'GET a patch' request | def find_patch(spec, options = {})
get_path(path_to_patch(spec), options)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def patch!\n request! :patch\n end",
"def patch options\n rest_request({ method: :patch }.merge(options))\n end",
"def patch options\n rest_request({ method: :patch }.merge(options))\n end",
"def patch(url, options = {}, &block)\n request HttpPatch, url, options, &block\n end",
... | [
"0.81451213",
"0.7587725",
"0.7587725",
"0.7584751",
"0.7481489",
"0.7424278",
"0.73476875",
"0.73211",
"0.73211",
"0.726068",
"0.72429246",
"0.7220421",
"0.71337074",
"0.7014439",
"0.70027",
"0.70027",
"0.6950232",
"0.694627",
"0.6933653",
"0.692861",
"0.6887083",
"0.68310... | 0.603519 | 63 |
The Bus should have a route number (e.g. 22) and a destination (e.g. "Ocean Terminal"). The Bus should have a drive method that returns a string (e.g. "Brum brum"). | def test_drive_method_string
assert_equal("Brum brum", @bus.drive())
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bus\n [bus_route, bus_stop].map{|r| r.try(:name)}.compact.join(' / ')\n end",
"def bus_route_name\n bus_route.try(:name)\n end",
"def set_bus_route\n @bus_route = BusRoute.find(params[:id])\n end",
"def drive(destination)\n if destination == \"Hawaii\"\n raise \"You can't driv... | [
"0.7028994",
"0.63944584",
"0.6020261",
"0.591964",
"0.5762425",
"0.57239985",
"0.56179065",
"0.56179065",
"0.5596427",
"0.5555475",
"0.5497448",
"0.53331923",
"0.53212804",
"0.5319101",
"0.5297203",
"0.5287085",
"0.52444535",
"0.52439505",
"0.52355623",
"0.5234828",
"0.52024... | 0.6558151 | 1 |
GET /products GET /products.json | def index
@products = Product.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @products }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_products()\n\tputs \"Getting products\"\n\tresponse = request_get(\"/api/product\")\n\tputs response.body\nend",
"def products\n request :public, :get, :products\n end",
"def index\n @products = Product.all\n render json: @products\n end",
"def index\n begin\n ... | [
"0.79500145",
"0.7929853",
"0.79054135",
"0.77477723",
"0.76619905",
"0.76070404",
"0.75873625",
"0.75828224",
"0.7578298",
"0.75750685",
"0.7565435",
"0.7565435",
"0.7565435",
"0.7565435",
"0.7530454",
"0.7523024",
"0.75097287",
"0.7499573",
"0.7487295",
"0.7482803",
"0.7477... | 0.762195 | 8 |
GET /products/1 GET /products/1.json | def show
@product = Product.where(["id = ?", params[:id].to_i]).first
raise NoProductError if @product.blank?
@providers = @product.providers
@product_contents = @product.contents
@shop = @product.shop
raise NoShopError if @shop.blank?
@reviews = @product.reviews
@review_images = @product.review_images
@main_review = @reviews.first
@main_image = @product.images.try(:first)
@countries = Country.all
add_breadcrumb "#{@shop.name} - #{@product.name} 商品詳細", product_path
respond_to do |format|
format.html # show.html.erb
format.json { render json: @product }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def product(name)\n get(\"/apiproducts/#{name}\")\n end",
"def show\n product = Product.find_by_id(params[:id])\n\n render json: product\n end",
"def show\n @product = Product.find(params[:id])\n\n render json: @product\n end",
"def index\n @api_v1_products = Product.all\n jso... | [
"0.7721997",
"0.7634331",
"0.76328903",
"0.7606679",
"0.7576786",
"0.75520205",
"0.7507598",
"0.7485642",
"0.74563456",
"0.7451232",
"0.7439217",
"0.74224496",
"0.7361879",
"0.73195374",
"0.73193246",
"0.73193246",
"0.73193246",
"0.7316911",
"0.7312487",
"0.731017",
"0.729581... | 0.0 | -1 |
GET /products/new GET /products/new.json | def new
@shop = Shop.where(["id = ?", params[:shop_id]]).first
raise "お探しのお店が見つかりません" unless @shop.present?
@product = Product.new
@provider = Provider.new
@product_types = ProductType.all
@countries = Country.all
respond_to do |format|
format.html # new.html.erb
format.json { render json: @product }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @product = Product.new\n\n render json: @product\n end",
"def new\n @product = Product.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @product }\n end\n end",
"def new\n @product = Product.new\n\n respond_to do |format|\n ... | [
"0.79471034",
"0.794238",
"0.7941842",
"0.7941842",
"0.7941842",
"0.7941842",
"0.7941842",
"0.7941842",
"0.7941842",
"0.7941842",
"0.7941842",
"0.7941842",
"0.7941842",
"0.7941842",
"0.7941842",
"0.7941842",
"0.7941842",
"0.7941842",
"0.7941842",
"0.7941842",
"0.7941842",
"... | 0.0 | -1 |
POST /products POST /products.json | def create
product = Product.new(params[:product])
if params[:product].present? && params[:product][:shop_id].present? && shop = Shop.where(["id = ?", params[:product][:shop_id]])
shop_name = shop.first.name
end
begin
Product.transaction do
product.save!
provider = Provider.new((params[:provider]).merge({:name => shop_name, :product_id => product.id}))
provider.save!
product_content = product.contents.build(params[:product_content])
product_content.save!
end
saved_flg = true
rescue
saved_flg = false
end
respond_to do |format|
if saved_flg
format.html { redirect_to action: :show, id: product.id }
else
format.html { redirect_to :action => :new, :shop_id => params[:product][:shop_id] }
# redirect_to :action => :new, :shop_id => params[:shop_id]
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @product = Product.new(product_args)\n\n if @product.save\n render json: Product.all, status: :created\n else\n render json: @product.errors, status: :unprocessable_entity\n end\n end",
"def create\n if params[:products]\n params[:products].each do |product|\n @... | [
"0.76749116",
"0.7589669",
"0.7560691",
"0.75317895",
"0.75311625",
"0.75078696",
"0.74203724",
"0.7391365",
"0.73747",
"0.73558646",
"0.7323108",
"0.7286924",
"0.71440953",
"0.7050226",
"0.70475376",
"0.7041469",
"0.7037263",
"0.7037263",
"0.7037263",
"0.7032203",
"0.7025534... | 0.0 | -1 |
PUT /products/1 PUT /products/1.json | def update
@product = Product.find(params[:id])
respond_to do |format|
if @product.update_attributes(params[:product])
format.html { redirect_to @product, notice: 'Product was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @product.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n begin\n @api_v1_product.update!(api_v1_product_params)\n head :no_content\n rescue => ex\n json_response({error: ex.message}, :unprocessable_entity)\n end\n end",
"def update\n product = Product.find(params[:id])\n product_details = params.permit(:title, :inventory_cou... | [
"0.7538245",
"0.7183557",
"0.70769256",
"0.6947366",
"0.69350314",
"0.6925342",
"0.69006455",
"0.6837947",
"0.68210983",
"0.6802727",
"0.67538136",
"0.6726058",
"0.66267633",
"0.6581133",
"0.65785664",
"0.6555896",
"0.65461636",
"0.6542114",
"0.6542114",
"0.65418255",
"0.6529... | 0.6491632 | 44 |
DELETE /products/1 DELETE /products/1.json | def destroy
@product = Product.find(params[:id])
@product.destroy
respond_to do |format|
format.html { redirect_to products_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n product = Product.find(params[:id])\n product.destroy\n\n render json: { deleted: params[:id] }\n end",
"def delete_product(name)\n delete(\"/apiproducts/#{name}\")\n end",
"def destroy\n p @product.destroy!\n render json: { result: 'deleted' }, status: :ok\n end",
... | [
"0.77176476",
"0.75932086",
"0.7549532",
"0.75037444",
"0.7502649",
"0.7474458",
"0.7440024",
"0.7418946",
"0.74090594",
"0.737114",
"0.73529583",
"0.7348819",
"0.7336592",
"0.7336592",
"0.7336592",
"0.73317486",
"0.73317486",
"0.73317486",
"0.73317486",
"0.73317486",
"0.7331... | 0.7313942 | 44 |
optionally identify users def mixpanel_distinct_id current_visitor_id end | def mixpanel_name_tag
current_user && current_user.email
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def distinct_value\n id\n end",
"def show\n\n @users_distinct = @tournament.users.distinct(:id)\n\n end",
"def user_id; 1; end",
"def user_id; config[:user_id]; end",
"def unique_visits_count\n # FIXME datampper can't do .count(distinct...) or .count.group_by() ?!\n Visit.count(:user_id, ... | [
"0.6262451",
"0.6031881",
"0.6021392",
"0.58161795",
"0.57813245",
"0.57776326",
"0.57375807",
"0.5685237",
"0.567364",
"0.56341356",
"0.56018895",
"0.557888",
"0.5563637",
"0.5540175",
"0.55316037",
"0.55221087",
"0.55196846",
"0.5506942",
"0.54948336",
"0.5492211",
"0.54904... | 0.5380577 | 35 |
There are three kinds of redirects possible: 1. Absolute URLs: or 2. Relative URLs: /issues/640 3. Internal wiki links: [[foo]] This method returns true if the receiver is an "internal wiki link" redirect. We're interested in this property because we want to know when to display "redirected from" annotations (which we only want for redirections _within_ the wiki) | def wiki_redirect?
!!(self.redirect? && self.redirect =~ LINK_REGEX)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def redirects_to_external?\n desc = self.layout_description\n return false if desc.blank?\n desc[\"redirects_to_external\"]\n end",
"def followed_redirects?\n current_url != @url\n end",
"def http_redirect?\n @get_resp.kind_of?(Net::HTTPRedirection)\n end",
"def http_redirect?\n @get... | [
"0.68883806",
"0.6871988",
"0.67038435",
"0.67038435",
"0.6679049",
"0.6540808",
"0.6526697",
"0.65178734",
"0.6510572",
"0.64242023",
"0.63959444",
"0.63641775",
"0.63641775",
"0.6277301",
"0.62719375",
"0.6217803",
"0.62138486",
"0.6210763",
"0.62046677",
"0.605844",
"0.604... | 0.82202065 | 0 |
TODO(lsmola) with 60s interval, we need also a spec for the fact that there can be 2 samples. Then if we take pod1 using 100 cores only in <12:00:00, 12:00:30) and pod2 using 100 cores only in <12:00:30, 12:01:00). The project avg should be 100 cores, not 200 cores. | def add_metrics_for(resource, range, metric_params: {}, step: 60.seconds)
range.step_value(step).each do |time|
metric_params[:timestamp] = time
metric_params[:resource_id] = resource.id
metric_params[:resource_name] = resource.name
metric_params[:parent_ems_id] = ems.id
metric_params[:derived_vm_numvcpus] = resource.container_node.hardware.cpu_total_cores
if metric_params[:mem_usage_absolute_average].to_i > 0
metric_params[:derived_memory_used] = (metric_params[:mem_usage_absolute_average] / 100.0) * resource.container_node.hardware.memory_mb
metric_params[:derived_memory_available] = resource.container_node.hardware.memory_mb - metric_params[:derived_memory_used]
end
resource.metrics << FactoryBot.create(:metric, metric_params)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_per_cpu(_)\n cpu_per_source = {}\n @client.query(\n '(count(node_cpu{mode=\"system\"})by(instance))'\n ).each do |result|\n source = result['metric']['instance']\n cpu_per_source[source] = result['value'][1]\n end\n\n metrics = ... | [
"0.49409294",
"0.49241117",
"0.48282963",
"0.48227322",
"0.47980824",
"0.47976753",
"0.47646335",
"0.47621787",
"0.4750442",
"0.47341314",
"0.47110596",
"0.47013542",
"0.46950132",
"0.46707204",
"0.4657616",
"0.4657616",
"0.4644385",
"0.46427962",
"0.46192518",
"0.46077347",
... | 0.0 | -1 |
Binds a `Proc` to be invoked when the given `event_name` is triggered. | def bind_event(event_name, cb_proc)
event_callbacks[event_name] << cb_proc
self
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def on_event(event_name=:__default__, &block)\n raise TypeError, 'event_name must be nil or respond to #to_sym' unless event_name.nil? || event_name.respond_to?(:to_sym)\n \n ( callbacks[ event_name.to_sym ] ||= [] ) << block\n \n block\n end",
"def on(event_name, &block)\... | [
"0.7335158",
"0.70987684",
"0.7042246",
"0.6797513",
"0.6418961",
"0.6187266",
"0.617814",
"0.61607546",
"0.6142815",
"0.6065196",
"0.6047703",
"0.6047703",
"0.6031635",
"0.6014416",
"0.59988785",
"0.59931946",
"0.59931946",
"0.5920452",
"0.5904262",
"0.58688533",
"0.58453876... | 0.76029855 | 0 |
Triggers an event by the given name, passing along any additional `args` as parameters to the callback | def trigger_event(event_name, *args)
event_callbacks[event_name].each do |cb|
begin
cb.call(*args)
rescue Exception => ex
warn "[OnStomp/Event] triggering #{event_name} raised an error: #{ex}"
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def trigger(name, *args)\n Events.use(name, *args)\n end",
"def trigger(owner, event, *args); end",
"def trigger(event_name, payload = {})\n handlers.each do |handler|\n next unless handler.respond_to?(:trigger)\n\n handler.trigger(self, event_name, payload)\n end\n end",
"... | [
"0.77251697",
"0.71154463",
"0.6921462",
"0.68923134",
"0.6774297",
"0.6624288",
"0.6584831",
"0.6579008",
"0.65623105",
"0.649794",
"0.6489004",
"0.64354604",
"0.64354604",
"0.6430633",
"0.63911843",
"0.6353077",
"0.6318554",
"0.61324334",
"0.6124062",
"0.61139077",
"0.61084... | 0.7791682 | 0 |
GET /top_menus GET /top_menus.xml | def index
@top_menus = TopMenu.find(:all)
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @top_menus }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @top_menu = TopMenu.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @top_menu }\n end\n end",
"def index\n @menu_items = uhook_find_menu_items\n\n respond_to do |format|\n format.html {} # index.html.erb \n ... | [
"0.7317229",
"0.703047",
"0.69964933",
"0.69964933",
"0.6859671",
"0.68219084",
"0.6766493",
"0.66663796",
"0.6636388",
"0.6622243",
"0.6591548",
"0.65710807",
"0.6559291",
"0.64830905",
"0.64771605",
"0.64771605",
"0.64756346",
"0.6459721",
"0.64547694",
"0.645364",
"0.64307... | 0.7625807 | 0 |
GET /top_menus/1 GET /top_menus/1.xml | def show
@top_menu = TopMenu.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @top_menu }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @top_menus = TopMenu.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @top_menus }\n end\n end",
"def index\n @menus = Menu.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml ... | [
"0.7536285",
"0.7087502",
"0.7087502",
"0.7023182",
"0.70090985",
"0.69238764",
"0.6767856",
"0.6767856",
"0.6761089",
"0.67500705",
"0.66718453",
"0.66430986",
"0.6622779",
"0.6616718",
"0.65220743",
"0.65197545",
"0.651172",
"0.6501334",
"0.64487183",
"0.6431002",
"0.641212... | 0.7411372 | 1 |
GET /top_menus/new GET /top_menus/new.xml | def new
@top_menu = TopMenu.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @top_menu }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @menu = uhook_new_menu\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @menu }\n end\n end",
"def new\n @menu = Menu.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @menu }\n end\n ... | [
"0.8043699",
"0.7612676",
"0.76114076",
"0.7555757",
"0.7532629",
"0.74921644",
"0.73291177",
"0.729729",
"0.72406787",
"0.7221061",
"0.70820916",
"0.7065235",
"0.70230347",
"0.69616944",
"0.6910389",
"0.69092894",
"0.6878209",
"0.68770534",
"0.6849998",
"0.6822339",
"0.67801... | 0.80883354 | 0 |
POST /top_menus POST /top_menus.xml | def create
@top_menu = TopMenu.new(params[:top_menu])
respond_to do |format|
if @top_menu.save
flash[:notice] = 'TopMenu was successfully created.'
format.html { redirect_to(@top_menu) }
format.xml { render :xml => @top_menu, :status => :created, :location => @top_menu }
else
format.html { render :action => "new" }
format.xml { render :xml => @top_menu.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @menu_item = uhook_create_menu_item\n\n respond_to do |format|\n if @menu_item.valid?\n flash[:notice] = t('ubiquo.menus.sitemap_created')\n format.html { redirect_to(ubiquo_menu_items_path) }\n format.xml { render :xml => @menu_item, :status => :created, :location => ... | [
"0.6504721",
"0.63984334",
"0.63899314",
"0.6324701",
"0.6136407",
"0.61331505",
"0.61296666",
"0.6081982",
"0.6064072",
"0.60123616",
"0.60057503",
"0.5964775",
"0.5916666",
"0.589657",
"0.5879485",
"0.5866075",
"0.5858496",
"0.5856033",
"0.5855065",
"0.58414125",
"0.5822462... | 0.6942597 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.