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 |
|---|---|---|---|---|---|---|
Check to see if there is a Sunset header, which contains deprecation date | def sunset_header(headers)
return if headers[:sunset].nil?
DateTime.parse(headers[:sunset])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has_date?\n header.has_date?\n end",
"def sunset_header(headers)\n return if headers[:sunset].nil?\n DateTime.parse(headers[:sunset])\n end",
"def should_override_api_timestamp?\n (@timestamp_header_value == \"posse\")? true : false\n end",
"def has_source_h... | [
"0.63464975",
"0.61777836",
"0.6064769",
"0.57246095",
"0.57124686",
"0.5685866",
"0.56770307",
"0.56172967",
"0.55493355",
"0.5542464",
"0.55098325",
"0.5491204",
"0.54625815",
"0.54618466",
"0.54544634",
"0.54203326",
"0.53898174",
"0.5382764",
"0.5366776",
"0.5359634",
"0.... | 0.6098532 | 3 |
GET /events GET /events.json | def index
if(params[:conf_id])
@events = Event.where(conference_id: params[:conf_id]).by_position
@conference = Conference.find(params[:conf_id])
else
@events = Event.all.by_position
end
@speaker_event_type = EventType.where(speaker_event: true)
@non_speaker_event_type = EventType.where(speaker_event: false)
@speaker_events = @events.where(event_type: @speaker_event_type)
@non_speaker_events = @events.where(event_type: @non_speaker_event_type)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def events\n response = self.class.get('/v1/events.json')\n response.code == 200 ? JSON.parse(response.body) : nil\n end",
"def get_events\n Resources::Event.parse(request(:get, \"Events\"))\n end",
"def get_events()\n @client.make_request(:get, @client.concat_user_path(\"#{CALL_PATH}... | [
"0.8337294",
"0.82393",
"0.7943906",
"0.7928331",
"0.77682066",
"0.77408546",
"0.76701826",
"0.7665501",
"0.76581633",
"0.7642472",
"0.76212007",
"0.7615658",
"0.7615658",
"0.7612881",
"0.75687",
"0.7522498",
"0.7488667",
"0.74813455",
"0.74698067",
"0.7441679",
"0.74408287",... | 0.0 | -1 |
GET /events/1 GET /events/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @event = Event.find(params[:id])\n render json: @event\n end",
"def get(event_id)\n @client.request \"events/#{event_id}\"\n end",
"def show\n event_id = params[:id]\n if event_id.present?\n @event = Com::Nbos::Events::Event.active_events.where(id: event_id, tenant_id: @use... | [
"0.75029767",
"0.74019474",
"0.7361382",
"0.7348975",
"0.73475033",
"0.7338018",
"0.7317425",
"0.72875094",
"0.72813755",
"0.7246173",
"0.72317284",
"0.7219172",
"0.7219172",
"0.7218839",
"0.7218839",
"0.721464",
"0.7204848",
"0.71989256",
"0.7196662",
"0.71925515",
"0.719221... | 0.0 | -1 |
POST /events POST /events.json | def create
@event = Event.new(event_params)
@conference = Conference.find(event_params[:conference_id])
respond_to do |format|
if @event.save
format.html { redirect_to controller: 'admin/events', action: 'index', conf_id: @conference.id }
format.json { render :show, status: :created, location: @event }
else
@event_type = @event.event_type
@speaker_event = @event_type.speaker_event
format.html { render :new }
format.json { render json: @event.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_event event, data={}\n data[:event] = event\n post '/event', data\n end",
"def create\n event = Event.new(event_params)\n event.save!\n render json: event\n end",
"def create\n Rails.logger.debug(\"Received event #{params[:event]}\")\n head :ok\n end",
"def crea... | [
"0.7712453",
"0.76103187",
"0.76023",
"0.754027",
"0.74432945",
"0.731932",
"0.73127836",
"0.7280875",
"0.72503763",
"0.7234792",
"0.7234792",
"0.72143626",
"0.7167559",
"0.7149272",
"0.7125694",
"0.7117843",
"0.71169645",
"0.71154994",
"0.7095357",
"0.7089589",
"0.70818335",... | 0.0 | -1 |
PATCH/PUT /events/1 PATCH/PUT /events/1.json | def update
respond_to do |format|
if @event.update(event_params)
format.html { redirect_to controller: 'admin/events', action: 'index', conf_id: @event.conference_id }
format.json { render :show, status: :ok, location: @event }
else
@event_type = @event.event_type
@speaker_event = @event_type.speaker_event
format.html { render :edit }
format.json { render json: @event.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def patch_event\n user_id = params[\"user_id\"]\n group_id = params[\"group_id\"]\n event_id = params[\"event_id\"]\n\n #TODO Handle 404 if event not found\n event = Event.find(event_id)\n\n json_body = JSON.parse(request.body.read)\n\n @@event_service.patch_event(j... | [
"0.75299805",
"0.7372486",
"0.71766764",
"0.7172103",
"0.7170955",
"0.71424884",
"0.70959055",
"0.7082709",
"0.7082709",
"0.7057662",
"0.70209146",
"0.6989379",
"0.69825095",
"0.69775003",
"0.69601995",
"0.6954494",
"0.6954494",
"0.6951992",
"0.692109",
"0.692109",
"0.692109"... | 0.0 | -1 |
DELETE /events/1 DELETE /events/1.json | def destroy
@event.destroy
respond_to do |format|
format.html { redirect_to controller: 'admin/events', action: 'index', conf_id: @event.conference_id }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @event = Event.using(:shard_one).find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @event.destroy\n respond_to do |format|\n format.json { head :no_... | [
"0.76929694",
"0.7688217",
"0.7688217",
"0.7688217",
"0.7681325",
"0.7585923",
"0.75685203",
"0.7560765",
"0.7541314",
"0.75410026",
"0.75410026",
"0.75410026",
"0.75410026",
"0.75410026",
"0.75410026",
"0.75410026",
"0.75410026",
"0.75410026",
"0.75410026",
"0.75410026",
"0.... | 0.0 | -1 |
Use callbacks to share common setup or constraints between actions. | def set_event
@event = Event.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.61637366",
"0.60446453",
"0.59452957",
"0.591511",
"0.58885515",
"0.5834122",
"0.57761765",
"0.5702554",
"0.5702554",
"0.5652102",
"0.5619581",
"0.5423898",
"0.5409782",
"0.5409782",
"0.5409782",
"0.5394745",
"0.53780794",
"0.5356209",
"0.5338898",
"0.53381324",
"0.5328622... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def event_params
params.require(:event).permit(:published, :title, :description, :event_type_id, :conference_id, :speaker_id, :duration, :position, :responsable, :video, :materials, :materials_link)
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.6981273",
"0.6783789",
"0.67460483",
"0.6742222",
"0.67354137",
"0.65934366",
"0.65028495",
"0.6497783",
"0.64826745",
"0.6479415",
"0.6456823",
"0.6440081",
"0.63800216",
"0.6376521",
"0.636652",
"0.6319898",
"0.6300256",
"0.62994003",
"0.6293621",
"0.6292629",
"0.6291586... | 0.0 | -1 |
Whether or not this LogEntry was an error | def error?
return false if error_text.nil? or error_text.empty?
return true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def error_log?\n @status.exitstatus & (1 << 6) != 0\n end",
"def error_log?\n @status.exitstatus & (1 << 6) != 0\n end",
"def error?\n get_last_error['err'] != nil\n end",
"def error?\n get_last_error['err'] != nil\n end",
"def error?\n @status == ERROR_FLAG\n end",
"d... | [
"0.76077443",
"0.7376135",
"0.73660296",
"0.73660296",
"0.73642373",
"0.72570986",
"0.72305584",
"0.7125339",
"0.69953346",
"0.69953346",
"0.69828457",
"0.69828457",
"0.6974009",
"0.69424915",
"0.6913015",
"0.6900868",
"0.6886072",
"0.6883914",
"0.6883866",
"0.68727005",
"0.6... | 0.622134 | 77 |
turned into a monster again refactor | def play_turn(data)
word_smith = WordSmith.new(data: data, board: board)
word_smith.process_data
create_turn(word_smith.points, word_smith.tiles)
end_game if over?
assign_new_tiles(current_player)
toggle_current_player
rescue WordSmith::InvalidWord
self.error_message = I18n.t("games.error_messages.invalid_word")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def anchored; end",
"def suivre; end",
"def probers; end",
"def schubert; end",
"def private; end",
"def ravel; end",
"def jack_handey; end",
"def malts; end",
"def villian; end",
"def king_richard_iii; end",
"def monster; end",
"def monster; end",
"def superweening_adorningly(counterstand_... | [
"0.6484325",
"0.6391546",
"0.6204299",
"0.6180854",
"0.60765606",
"0.59509224",
"0.59266037",
"0.5901084",
"0.5864783",
"0.58105946",
"0.5779841",
"0.5779841",
"0.57757264",
"0.57631344",
"0.57376826",
"0.56927025",
"0.56906295",
"0.56855416",
"0.56549954",
"0.5578517",
"0.55... | 0.0 | -1 |
color should be Array like [r, g, b]. Float from 0.0 to 1.0. | def initialize(v0, v1, v2, v3, color, transmit = nil)
super(v0, v1, v2, v3)
@color = color
@transmit = transmit
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def color=(array)\n shader.set_float_uniform('color', array)\n return self\n end",
"def rgb_color\n [self.color_red, self.color_green, self.color_blue]\n end",
"def rgb_color; end",
"def to_array\n\t\t\tm_color = self.color.delete(' ')\n\t\t\tm_color.delete!('hsl(')\n\t\t\tm_color.dele... | [
"0.694924",
"0.69114965",
"0.68729544",
"0.67646515",
"0.6721372",
"0.67199606",
"0.6663142",
"0.66272426",
"0.65968627",
"0.6506966",
"0.6506966",
"0.6486075",
"0.6451934",
"0.6450803",
"0.6425849",
"0.6425606",
"0.64147794",
"0.6354385",
"0.6292194",
"0.6277969",
"0.6265991... | 0.0 | -1 |
PUBLIC METHODS Returns number of link_tracking assocations Only used for reporting purposes | def tracking_total_count
link_tracking.count
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def count_links\n @links_count = Link.count\n end",
"def number_of_internal_links_to_page(link)\n @ilps[link]\n end",
"def total_link_count\n @sitemaps_link_count\n end",
"def count_edge\n count = 0\n @f_net.each_with_index do |followees, follower|\n count += followees_of(f... | [
"0.6871865",
"0.64864355",
"0.6403187",
"0.6376514",
"0.6310534",
"0.62912786",
"0.614341",
"0.6124568",
"0.6071571",
"0.60666233",
"0.6051078",
"0.6041124",
"0.60318494",
"0.6031757",
"0.60292643",
"0.5957545",
"0.59478354",
"0.5946964",
"0.59419936",
"0.59167325",
"0.591411... | 0.7829485 | 0 |
Uses Enum method to determine if something is published. Only used in the search params for elasticsearch | def published
self.production?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def published?\n [:public, :private].include?(self.status)\n end",
"def is_published?\n status === 'published'\n end",
"def published?\n status == Status[:published]\n end",
"def published?\n (status == PUBLISHED)\n end",
"def published?\n (status == PUBLISHED)\n end",
"def published?... | [
"0.7309411",
"0.72886",
"0.72466534",
"0.69474137",
"0.69474137",
"0.69474137",
"0.69474137",
"0.69474137",
"0.69281846",
"0.69281846",
"0.68461335",
"0.6837029",
"0.68340266",
"0.6822371",
"0.6817957",
"0.676112",
"0.6760402",
"0.6727401",
"0.67206055",
"0.6714393",
"0.66981... | 0.57838446 | 86 |
Creates keywords for indexing, filtering, search etc. | def keywords
attr = [status, name, title_search, subject_list]
attr.join(' ')
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_keywords\n\n keywords = t(LOCALE_KEYWORDS_KEY, default: SiteMetaInfoDefaults.keywords)\n business_cats = BusinessCategory.pluck(:name).uniq\n\n cats_str = business_cats.empty? ? '' : ', ' + business_cats.join(', ')\n keywords + cats_str\n end",
"def generate_keywords\n all_keyword... | [
"0.7500841",
"0.7032309",
"0.70204914",
"0.70127857",
"0.69941574",
"0.6860696",
"0.68050075",
"0.6763526",
"0.6738273",
"0.6667183",
"0.6640339",
"0.6611523",
"0.66000867",
"0.65977585",
"0.6579472",
"0.6568702",
"0.65630233",
"0.6542726",
"0.6499553",
"0.6499068",
"0.648874... | 0.6759638 | 8 |
Creates comma seperated list of subjects. | def subject_list
list = []
subjects.each { |subject| list << subject.name }
list.to_sentence
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def subjects_column\n list = []\n subjects.each { |subject| list << subject.name }\n list.join(';')\n end",
"def format_final_subject(subjects)\n if subjects.size == 1\n subjects[0]\n elsif subjects.size == 2\n subjects[0] + ' and ' + subjects[1]\n else\n last_subject = subjects... | [
"0.7360715",
"0.7082522",
"0.6774296",
"0.6663561",
"0.649294",
"0.6472248",
"0.6449567",
"0.64210546",
"0.64110374",
"0.6395672",
"0.639089",
"0.6365869",
"0.6358851",
"0.63236743",
"0.62995267",
"0.6240473",
"0.62367433",
"0.6182755",
"0.6158407",
"0.6116354",
"0.60407895",... | 0.8026546 | 0 |
Creates groupings of subjects seprated by semicolons. | def subjects_column
list = []
subjects.each { |subject| list << subject.name }
list.join(';')
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_groups(people)\n number_people = people.length\n if number_people < 3\n group_quantity = 1\n else\n group_quantity = number_people / 3\n end\n group_number = 1\n groups_names = Hash.new(\"\")\n people.each do |name|\n if group_number <= group_quantity\n groups_names[group_number] +=... | [
"0.5797202",
"0.56708646",
"0.54754895",
"0.5387237",
"0.521226",
"0.51765233",
"0.51142335",
"0.5113042",
"0.5083404",
"0.50519574",
"0.50195575",
"0.50177157",
"0.5016444",
"0.50070834",
"0.49938846",
"0.49804804",
"0.4949677",
"0.4927427",
"0.49213883",
"0.49210402",
"0.49... | 0.50835097 | 8 |
Creates groupings of resources seprated by semicolons. | def resources_column
list = []
resources.each { |rss| list << rss.name }
list.join(';')
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_group\n group new_resource.group do\n gid new_resource.gid\n system true\n end\n end",
"def create_groups(people)\n number_people = people.length\n if number_people < 3\n group_quantity = 1\n else\n group_quantity = number_people / 3\n end\n gr... | [
"0.57846665",
"0.55669636",
"0.5462681",
"0.536778",
"0.5353421",
"0.52777594",
"0.5269885",
"0.526505",
"0.526505",
"0.526505",
"0.5262926",
"0.521771",
"0.52125305",
"0.52081764",
"0.5191578",
"0.5180895",
"0.51791143",
"0.51454633",
"0.5092947",
"0.5091832",
"0.5085406",
... | 0.0 | -1 |
Creates comma seperated list of resources. | def resource_list
list = []
resources.each { |rss| list << rss.name }
list.to_sentence
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_resources_list\n resources = YARD::Registry.all(:resource).uniq.sort_by {|resource| resource.name.to_s}\n generate_full_list(resources, 'Resource', 'resources')\nend",
"def list\n puts local_resources.map { |name, resource| name }.join(\" \")\n end",
"def manipulate_resource_list(res... | [
"0.6936104",
"0.6747082",
"0.61592853",
"0.61461926",
"0.60896844",
"0.6058486",
"0.60176593",
"0.5978648",
"0.5978303",
"0.59137356",
"0.59137356",
"0.5774169",
"0.5719946",
"0.57097274",
"0.5532093",
"0.5520681",
"0.5493826",
"0.5463864",
"0.54344106",
"0.54301393",
"0.5415... | 0.71257883 | 0 |
Returns an array of names for search index. | def subject_search_index
subjects.pluck(:name)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def names\n @index.keys\n end",
"def names\n @searches.names\n end",
"def curated_search_index\n curated.pluck(:name)\n end",
"def names\n Array(@name)\n end",
"def index_name\n models.map { |m| m.index_name }\n end",
"def names\n map(&:names).flat... | [
"0.7773075",
"0.7314784",
"0.6765376",
"0.6730985",
"0.6574911",
"0.6524343",
"0.65060306",
"0.64950395",
"0.64950395",
"0.6449853",
"0.6435959",
"0.642979",
"0.64021945",
"0.6386188",
"0.636248",
"0.63411677",
"0.6292613",
"0.6280432",
"0.6272861",
"0.6235423",
"0.6186352",
... | 0.6699449 | 4 |
Returns an array of names for search index. | def rss_search_index
resources.pluck(:name)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def names\n @index.keys\n end",
"def names\n @searches.names\n end",
"def curated_search_index\n curated.pluck(:name)\n end",
"def names\n Array(@name)\n end",
"def subject_search_index\n subjects.pluck(:name)\n end",
"def index_name\n models.map { |m| m... | [
"0.7773802",
"0.73141694",
"0.6764161",
"0.6732825",
"0.6699125",
"0.6574538",
"0.65265703",
"0.6503088",
"0.64921474",
"0.64921474",
"0.6447115",
"0.6438066",
"0.6430039",
"0.64040774",
"0.63642204",
"0.633911",
"0.6291664",
"0.62802523",
"0.6275856",
"0.6235167",
"0.6187753... | 0.63864 | 14 |
Returns an array of names for search index. | def curated_search_index
curated.pluck(:name)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def names\n @index.keys\n end",
"def names\n @searches.names\n end",
"def names\n Array(@name)\n end",
"def subject_search_index\n subjects.pluck(:name)\n end",
"def index_name\n models.map { |m| m.index_name }\n end",
"def names\n map(&:names).fla... | [
"0.77736807",
"0.73146254",
"0.67322487",
"0.66995806",
"0.6575117",
"0.65269005",
"0.6504813",
"0.6493807",
"0.6493807",
"0.6447735",
"0.6436123",
"0.64295536",
"0.64046013",
"0.63852245",
"0.63649106",
"0.63398653",
"0.6290591",
"0.62811536",
"0.62747383",
"0.6235169",
"0.6... | 0.67639464 | 2 |
Calls the association for vendor unless nil, and returns the vendors name. | def vendor_name
vendor&.name
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def vendors\n fetch(@config[:sales_path], 'Sales.getVendors')\n end",
"def denormalize_vendor_name\n self.vendor_name = vendor.try(:name) if vendor_id_changed?\n end",
"def getVendors\n fetch(@config[:sales_path], 'Sales.getVendors')\n end",
"def vendor\n FarMar::Vendor.all.find {|inst... | [
"0.6861759",
"0.67460877",
"0.66345555",
"0.65800905",
"0.65171427",
"0.64869577",
"0.6462256",
"0.6462256",
"0.6458595",
"0.6408482",
"0.6378536",
"0.6343719",
"0.63358545",
"0.6308895",
"0.6294236",
"0.6282399",
"0.625751",
"0.6251122",
"0.62116283",
"0.6205272",
"0.615741"... | 0.7084646 | 0 |
Checks to see if the campus only designation is set | def campus_only?
access == 'Campus Only Access (No Proxy)'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def design_data_filled_in?\n !self.description.blank? && \n !self.platform.blank? && \n !self.product_type.blank? && \n !self.project.blank? &&\n !self.design_directory.blank? &&\n !self.incoming_directory.blank?\n end",
"def is_none_fields\n\t\tunless self.designation!=\"none\" && self.depart... | [
"0.64387053",
"0.6382764",
"0.6297314",
"0.629274",
"0.6036108",
"0.6029512",
"0.5967276",
"0.5959347",
"0.59436333",
"0.5917164",
"0.59119636",
"0.59104216",
"0.5866875",
"0.5866",
"0.58163923",
"0.58155763",
"0.5809384",
"0.57872176",
"0.57797986",
"0.5771028",
"0.57668847"... | 0.71379286 | 0 |
Creates a hash to use in the lib_guides CSV. LibGuides requries the use of these fields vendor name url enable_proxy description more_info enable_new enable_trial types keywords target slug best_bets subjects desc_pos lib_note enable_popular enable_hidden internal_note owner resource_icons thumbnail content_id | def csv_hash
{
vendor: self.vendor_name,
name: self.name,
url: self.url,
enable_proxy: self.access == 2 ? 1 : 0,
description: self.description,
more_info: '',
enable_new: self.new_database.to_i,
enable_trial: self.trial_database.to_i,
types: self.resources.pluck(:name).join(';'),
keywords: '',
target: 0,
slug: '',
best_bets: self.curated.pluck(:name).join(';'),
subjects: self.subjects.pluck(:name).join(';'),
desc_pos: 1,
lib_note: 0,
enable_popular: self.popular.to_i,
enable_hidden: 0,
internal_note: '',
owner: '',
resource_icons: '',
thumbnail: '',
content_id: self.libguides_id
}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hash\n [id, url, external_id, first_name, last_name, middle_name, birth_date, gender, language, phone, allow_phone_contact, email, allow_email_contact, notes, date_created, date_modified, ext_date_created, ext_date_modified, doc_type, doc_issuer_info, doc_series, doc_number, department_code, department_na... | [
"0.58540606",
"0.569996",
"0.569961",
"0.5690804",
"0.5656755",
"0.55939984",
"0.5590626",
"0.55799085",
"0.55768716",
"0.5380645",
"0.53769743",
"0.5376363",
"0.53473294",
"0.52938974",
"0.52769786",
"0.5270105",
"0.52567416",
"0.52555573",
"0.5247419",
"0.524464",
"0.518830... | 0.6994874 | 0 |
Creates a hash to use in the link_tracking CSV. name tracking_count | def link_tracking_csv_hash
{
name: self.name,
count: self.tracking_count
}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def link_tracking_all_csv_hash\n {\n name: self.name,\n count: self.tracking_total_count\n }\n end",
"def tracking_total_count\n link_tracking.count\n end",
"def hash\n [event_count, hour, index_id, index_name, org_name, public_id, retention].hash\n end",
"def hash_with_meta\n ... | [
"0.7942738",
"0.655014",
"0.5951549",
"0.59169096",
"0.56994236",
"0.56967753",
"0.56949496",
"0.56888336",
"0.5644522",
"0.5614125",
"0.55630755",
"0.55587757",
"0.555015",
"0.5527527",
"0.55229855",
"0.55197436",
"0.5477085",
"0.54755986",
"0.5457154",
"0.5448609",
"0.54378... | 0.82694614 | 0 |
Creates a hash to use in the link_tracking CSV. name tracking_count | def link_tracking_all_csv_hash
{
name: self.name,
count: self.tracking_total_count
}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def link_tracking_csv_hash\n {\n name: self.name,\n count: self.tracking_count\n }\n end",
"def tracking_total_count\n link_tracking.count\n end",
"def hash\n [event_count, hour, index_id, index_name, org_name, public_id, retention].hash\n end",
"def hash_with_meta\n to_hash.m... | [
"0.82694614",
"0.655014",
"0.5951549",
"0.59169096",
"0.56994236",
"0.56967753",
"0.56949496",
"0.56888336",
"0.5644522",
"0.5614125",
"0.55630755",
"0.55587757",
"0.555015",
"0.5527527",
"0.55229855",
"0.55197436",
"0.5477085",
"0.54755986",
"0.5457154",
"0.5448609",
"0.5437... | 0.7942738 | 1 |
Elastic search settings using indexed json. | def as_indexed_json(_options)
as_json(
methods: [:vendor_name, :subject_search_index, :rss_search_index, :curated_search_index, :published, :keywords],
only: [:id, :name, :vendor_name, :description, :title_search, :keywords]
)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def configure\n configure_with(elasticsearch: true)\n end",
"def search_setup(index:'', type:'', source:[], query:nil)\n @logger.info('Setup the ES search options: ')\n @logger.info(\"index=#{index} type=#{type} source=#{source} query=#{query}\")\n\n @index = index\n @type = type\n ... | [
"0.7030526",
"0.6747123",
"0.66243625",
"0.6528794",
"0.6452268",
"0.64170325",
"0.632356",
"0.6316072",
"0.6311838",
"0.6299989",
"0.6298615",
"0.6267066",
"0.62336135",
"0.61609465",
"0.61234146",
"0.6109905",
"0.6103727",
"0.6103281",
"0.6085973",
"0.6042748",
"0.600752",
... | 0.64681804 | 4 |
Minting a UUID creates a uuid for the record to use as a stable URL. | def mint_uuid
self.url_uuid ||= Time.now.to_i
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def assign_uuid\n self.id = UUIDTools::UUID.timestamp_create().to_s\n end",
"def olduuid uuid\n\trf = uuid\n\trf.insert(8, \"-\")\n\trf.insert(13, \"-\")\n\trf.insert(18, \"-\")\n\trf.insert(23, \"-\")\n\treturn rf\nend",
"def assign_uuid\n self.uuid ||= SecureRandom.urlsafe_base64(8)\n end",
"def se... | [
"0.7151515",
"0.7116209",
"0.70197177",
"0.6967005",
"0.6967005",
"0.69323456",
"0.69114065",
"0.69034666",
"0.6880051",
"0.6832904",
"0.6822393",
"0.6807721",
"0.6758876",
"0.6692003",
"0.66883385",
"0.6672042",
"0.66676366",
"0.66676366",
"0.66215223",
"0.66215223",
"0.6621... | 0.73970217 | 0 |
Some attributes are mostly going to be the same or provided as default values. These attributes will be set automatically unless the items is set by the user. | def set_defaults
self.help ||= ENV['help_text']
self.help_url ||= ENV['help_url']
self.created_at ||= DateTime.current
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def default_attrs\n @default_attrs\n end",
"def allowed_attributes=(_arg0); end",
"def allowed_attributes=(_arg0); end",
"def set_default_attributes\n self.attributes = default_attributes\n self.attributes.each do |key, value|\n # Scrub the attributes if there's no valu... | [
"0.70964587",
"0.7087375",
"0.7087375",
"0.7031612",
"0.7017653",
"0.68992895",
"0.68605715",
"0.68526745",
"0.67591155",
"0.67345536",
"0.6711007",
"0.670625",
"0.6694168",
"0.6682259",
"0.6671146",
"0.6647209",
"0.66237515",
"0.66184133",
"0.6611895",
"0.66052705",
"0.65327... | 0.0 | -1 |
Sanitize the Description field | def sanitize_description
self.description = Sanitize.fragment(self.description, Sanitize::Config::BASIC)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clean_description\n ActionView::Base.full_sanitizer.sanitize(description)\n end",
"def sanitize_description(description)\n ActionController::Base.helpers.strip_tags(description)\n end",
"def sanitize(str)\n DescriptionSanitizer.new.sanitize(str)\n end",
"def strip_html_from_descripti... | [
"0.86052674",
"0.818869",
"0.79620963",
"0.79508424",
"0.7610957",
"0.7522478",
"0.73051304",
"0.72501075",
"0.7115807",
"0.7115807",
"0.7077657",
"0.7049413",
"0.688072",
"0.6849992",
"0.68337715",
"0.67843926",
"0.67068034",
"0.66686803",
"0.6633985",
"0.6612287",
"0.659806... | 0.85810536 | 1 |
2. From all the built in Ruby methods we've seen in class this week, choose three that you think are particularly helpful and create examples to show how they work. your three built in ruby methods | def add(a, b)
a + b
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def how_it_works\r\n end",
"def who_we_are\r\n end",
"def methods; end",
"def methods; end",
"def methods; end",
"def methods; end",
"def methods() end",
"def romeo_and_juliet; end",
"def herald; end",
"def probers; end",
"def operations; end",
"def operations; end",
"def implementation; ... | [
"0.6660938",
"0.6354154",
"0.6224412",
"0.6224412",
"0.6224412",
"0.6224412",
"0.62087953",
"0.61798763",
"0.61152893",
"0.60634315",
"0.60519683",
"0.60519683",
"0.60419756",
"0.60419756",
"0.60176784",
"0.5984283",
"0.5984283",
"0.5984283",
"0.5979311",
"0.59777045",
"0.597... | 0.0 | -1 |
GET /address_ranges/data.xml def data network_id = params[:id].split[0] site_id = params[:id].split[1] subnet_id = params[:id].split[2] if !subnet_id.nil? then | def dbaction # supporting code for dhtmlx db/grid
#called for all db actions
subnet_id = params[:id].split[2]
first_address = params["c0"]
last_address = params["c1"]
description = params["c2"]
@mode = params["!nativeeditor_status"]
@id = params["gr_id"]
case @mode
when "inserted"
address_range=AddressRange.new
address_range.subnet_id = subnet_id
address_range.first_address = first_address
address_range.last_address = last_address
address_range.description = description
address_range.save!
@tid = address_range.id
when "deleted"
address_range=AddressRange.find(@id)
address_range.destroy
@tid = @id
when "updated"
address_range=AddressRange.find(@id)
address_range.subnet_id = subnet_id
address_range.first_address = first_address
address_range.last_address = last_address
address_range.description = description
address_range.save!
@tid = @id
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def subnet_id\n data[:subnet_id]\n end",
"def addresses\n nodename = params[:node_id]\n @node = nodename == \"admin\" ? Node.admin.where(:available => true).first : Node.find_key(nodename)\n if params[:network]\n @net = Network.find_key(params[:network])\n res = {\n \"node\" =>... | [
"0.60472685",
"0.56632274",
"0.5532753",
"0.5450384",
"0.53905165",
"0.53699905",
"0.53358775",
"0.53016347",
"0.52924716",
"0.52923197",
"0.5280094",
"0.5265751",
"0.52422786",
"0.5239111",
"0.5212064",
"0.52069634",
"0.5182491",
"0.51796633",
"0.51438963",
"0.5118444",
"0.5... | 0.5102735 | 21 |
GET /address_ranges GET /address_ranges.xml | def index
@address_ranges = AddressRange.all
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @address_ranges }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def addresses\n IbmCloudRest.get \"#{@uri}/addresses\"\n end",
"def show\n @address_range = AddressRange.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @address_range }\n end\n end",
"def addresses\n query(:address)\n... | [
"0.71258813",
"0.70020956",
"0.6716909",
"0.6642833",
"0.6642207",
"0.6616891",
"0.6436227",
"0.6320094",
"0.62539095",
"0.6191286",
"0.6138709",
"0.61239856",
"0.6113165",
"0.60821533",
"0.60797316",
"0.6066117",
"0.60290074",
"0.59926397",
"0.59444547",
"0.59332615",
"0.590... | 0.764934 | 0 |
GET /address_ranges/1 GET /address_ranges/1.xml | def show
@address_range = AddressRange.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @address_range }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @address_ranges = AddressRange.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @address_ranges }\n end\n end",
"def addresses\n IbmCloudRest.get \"#{@uri}/addresses\"\n end",
"def addresses\n message = { nodes: { item: reso... | [
"0.7589515",
"0.6680216",
"0.64837545",
"0.6442109",
"0.6379526",
"0.6326249",
"0.6319453",
"0.6297263",
"0.61365956",
"0.6007442",
"0.59893113",
"0.598717",
"0.59617144",
"0.5916575",
"0.5892676",
"0.5883728",
"0.58831286",
"0.5863897",
"0.58419794",
"0.5834285",
"0.5825903"... | 0.7181083 | 1 |
GET /address_ranges/new GET /address_ranges/new.xml | def new
@address_range = AddressRange.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @address_range }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @address_range = AddressRange.new(params[:address_range])\n\n respond_to do |format|\n if @address_range.save\n format.html { redirect_to(@address_range, :notice => 'Address range was successfully created.') }\n format.xml { render :xml => @address_range, :status => :created,... | [
"0.7020179",
"0.6578958",
"0.6534841",
"0.64456725",
"0.636473",
"0.63185894",
"0.6191496",
"0.61611456",
"0.6108384",
"0.6108164",
"0.61023813",
"0.60937256",
"0.60937256",
"0.60937256",
"0.60822916",
"0.60728127",
"0.6062728",
"0.60596687",
"0.60425746",
"0.6027718",
"0.601... | 0.7757886 | 0 |
POST /address_ranges POST /address_ranges.xml | def create
@address_range = AddressRange.new(params[:address_range])
respond_to do |format|
if @address_range.save
format.html { redirect_to(@address_range, :notice => 'Address range was successfully created.') }
format.xml { render :xml => @address_range, :status => :created, :location => @address_range }
else
format.html { render :action => "new" }
format.xml { render :xml => @address_range.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @address_ranges = AddressRange.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @address_ranges }\n end\n end",
"def set_Addresses(value)\n set_input(\"Addresses\", value)\n end",
"def set_Addresses(value)\n set_inpu... | [
"0.618804",
"0.57795507",
"0.57795507",
"0.57795507",
"0.5689063",
"0.56120056",
"0.55950505",
"0.55307364",
"0.54745066",
"0.5470775",
"0.5408936",
"0.5361865",
"0.53574586",
"0.5313097",
"0.5311192",
"0.53001124",
"0.52669245",
"0.52386886",
"0.5228782",
"0.52141345",
"0.51... | 0.676713 | 0 |
PUT /address_ranges/1 PUT /address_ranges/1.xml | def update
@address_range = AddressRange.find(params[:id])
respond_to do |format|
if @address_range.update_attributes(params[:address_range])
format.html { redirect_to(@address_range, :notice => 'Address range was successfully updated.') }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @address_range.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @address_range = AddressRange.find(params[:id])\n @address_range.destroy\n\n respond_to do |format|\n format.html { redirect_to(address_ranges_url) }\n format.xml { head :ok }\n end\n end",
"def create\n @address_range = AddressRange.new(params[:address_range])\n\n res... | [
"0.6048564",
"0.6047081",
"0.5803277",
"0.5617189",
"0.55028325",
"0.5500738",
"0.549334",
"0.549334",
"0.549334",
"0.5490639",
"0.54773134",
"0.5451156",
"0.5450174",
"0.544981",
"0.5437329",
"0.5435551",
"0.5423937",
"0.5389015",
"0.5377304",
"0.5377304",
"0.53731817",
"0... | 0.6945595 | 0 |
DELETE /address_ranges/1 DELETE /address_ranges/1.xml | def destroy
@address_range = AddressRange.find(params[:id])
@address_range.destroy
respond_to do |format|
format.html { redirect_to(address_ranges_url) }
format.xml { head :ok }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n # @address = Address.find(params[:id])\n @address = Address.find_by_permalink!(params[:id])\n @address.destroy\n\n respond_to do |format|\n format.html { redirect_to(addresses_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @addresses = Address.paginate(:... | [
"0.6621146",
"0.6513962",
"0.64668447",
"0.64514786",
"0.64365184",
"0.639238",
"0.6360946",
"0.6347938",
"0.6303641",
"0.6299742",
"0.6296713",
"0.62823236",
"0.6269874",
"0.6232789",
"0.621946",
"0.62039477",
"0.6174779",
"0.61666787",
"0.61666787",
"0.61666787",
"0.6166678... | 0.74123067 | 0 |
Returns INTEGER counting days in current month. | def days_in_current_month
current_month = Time.now.month
current_year = Time.now.year
return Time.days_in_month(current_month, current_year)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def days_in_month\n raw = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][self.month]\n self.month == 2 && leap_year? ? raw + 1 : raw\n end",
"def days_in_month\n Time.send(\"month_days\", self.year, self.month)\n end",
"def days_in_month\n @date_time_value.days_in_month... | [
"0.7958529",
"0.7760566",
"0.77477634",
"0.7633565",
"0.7561991",
"0.7361875",
"0.73452634",
"0.7280365",
"0.72696865",
"0.72352314",
"0.7186616",
"0.71821344",
"0.71554923",
"0.71471286",
"0.69383425",
"0.69253033",
"0.6899651",
"0.6887485",
"0.6853021",
"0.6853021",
"0.6833... | 0.8186216 | 0 |
Returns a BOOLEAN based on slot availability. | def check_slot(day, slot)
events = Event.where(day: day)
used_slots = events.pluck(:slot)
if used_slots.include? slot
return false
else
return true
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def slot_valid? \n\t\tavailable_slots = self.resource.available_time_slot(self.date_of_booking.strftime(\"%Y%m%d\") )\n\t\tavailable_slots.each do | slot |\n\t\t\treturn if slot[1] == self.slot.to_i\n\t\tend\n\t\t\tself.errors[:slot_invalid] << \"=> This slot is invalid\"\n\tend",
"def is_available?\n retur... | [
"0.7627097",
"0.737149",
"0.7333801",
"0.73134935",
"0.72310144",
"0.7158929",
"0.7096491",
"0.7093107",
"0.70566785",
"0.7049002",
"0.702692",
"0.698504",
"0.6945829",
"0.6935982",
"0.6927607",
"0.6905851",
"0.68834406",
"0.6797803",
"0.67975616",
"0.6796499",
"0.6795932",
... | 0.6909431 | 15 |
Moves the current history pointer to the previous element (that is one step further in the past) and returns the newly pointed element. | def prev
@history_idx += 1 if @history_idx < @history.length - 1
current
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def prev(current)\n l = current\n l = l[0,1] if (l.length > 0 and l[0,1] == '\\n')\n l = l[-1,1] if (l.length > 0 and l[-1,1] == '\\n')\n if (@position > 0)\n if (@position == (@history.length - 1))\n @history[@history.length - 1] = l\n ... | [
"0.7648471",
"0.76401293",
"0.7209635",
"0.72022784",
"0.7194428",
"0.7159589",
"0.7047654",
"0.7037475",
"0.6994902",
"0.6948232",
"0.689169",
"0.68300444",
"0.6796553",
"0.67949843",
"0.67706877",
"0.6741709",
"0.67394346",
"0.6704532",
"0.6704532",
"0.670226",
"0.66865456"... | 0.77930534 | 0 |
Moves the current history pointer to the next element (thaat is one step closer to the presetn) and returns the newly pointed element | def next
@history_idx -= 1 if @history_idx > -1
current
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def next_history()\r\n (@history_offset == @history_length) ? nil : @the_history[@history_offset+=1]\r\n end",
"def next_history\n if @history_index && @history_index > 0\n @history_index -= 1\n else\n @history_index = @history.size - 1\n end\n\n self.value = @history[@histo... | [
"0.73704445",
"0.7265829",
"0.7068525",
"0.67087567",
"0.6537481",
"0.6415236",
"0.63090694",
"0.62513655",
"0.6246461",
"0.6246461",
"0.6246461",
"0.6246461",
"0.6246461",
"0.6246461",
"0.6246461",
"0.6246461",
"0.6227113",
"0.6213634",
"0.61494094",
"0.61464626",
"0.6112267... | 0.73061115 | 1 |
Returns the currently pointed element from the history along with it's id | def current
if @history_idx < 0
[ @history_idx, nil ]
else
[ @history_idx, @history[@history_idx] ]
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def current_location\n return @history[-1]\n end",
"def one_history\n history = History.find(@id)\n history\n end",
"def current_history()\r\n return ((@history_offset == @history_length) || @the_history.nil?) ? nil : @the_history[@history_offset]\r\n end",
"def last\n @history.last... | [
"0.65622884",
"0.6502884",
"0.6416421",
"0.6365359",
"0.62487894",
"0.62214184",
"0.62133664",
"0.6163559",
"0.6163559",
"0.60247284",
"0.60121375",
"0.59883136",
"0.59883136",
"0.59878427",
"0.59863865",
"0.5984071",
"0.5968507",
"0.5968024",
"0.5948142",
"0.5945666",
"0.594... | 0.6372182 | 3 |
Resets the history pointer to the buffer element (that is the one before the first stored history element) | def rewind
@history_idx = -1
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def invalidate_history!\n @history = nil\n end",
"def clear_history\n while ! Readline::HISTORY.empty? do\n Readline::HISTORY.pop\n end\n end",
"def reset_buffer(new_buf = '')\n @buf.replace new_buf\n @index = 0\n end",
"def reset_buffer(new_buf = '')\n @... | [
"0.6910569",
"0.6810145",
"0.6697332",
"0.6697332",
"0.6679277",
"0.6674285",
"0.66414785",
"0.6491298",
"0.64660424",
"0.6448663",
"0.641956",
"0.64177734",
"0.6415567",
"0.6381573",
"0.63773525",
"0.63536155",
"0.63415563",
"0.63090706",
"0.6292373",
"0.62809396",
"0.621756... | 0.78869045 | 0 |
Remove the contents of this history object and rereads the contents from the specified file if possible | def reset(filename)
@history = []
@history_idx = -1
unless filename.nil? or !File.exists? filename
@history = File.readlines(filename).map { |l| l.rstrip }.reverse
end
@backend = File.open filename, "a+" unless filename.nil?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def file_history_pop(file)\n file_history = $file_history.to_h\n current_history = file_history.pop\n file_history.each_pair do |index, file_name|\n if file_name == current_history\n $file_history.delete_field(\"#{index}\")\n break\n end\n end\n end",
"def remove_file(file)\n... | [
"0.71817815",
"0.63751286",
"0.6349643",
"0.6238109",
"0.6167352",
"0.6147301",
"0.613519",
"0.60584646",
"0.6045717",
"0.5993199",
"0.5970578",
"0.595704",
"0.5955714",
"0.5949767",
"0.59279424",
"0.59141594",
"0.5882294",
"0.5870342",
"0.5870315",
"0.5845483",
"0.5841303",
... | 0.6485957 | 1 |
finds an executable in a bin/ subdirectory of kit | def find_executable(name)
@project.from_directory do
Find.find("kit") do |path|
next unless path =~ /bin\/#{name}$/
log.debug("found #{name} executable: #{path}")
return path
end
end
log.debug("#{name} executable not found")
nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_executable(name)\n @project.from_directory do\n Find.find(\"kit\") do |path|\n next unless path =~ /bin\\/#{name}$/\n\n log.debug(\"found #{name} executable: #{path}\")\n return path\n end\n end\n\n log.debug(\"#{name} executable not found\")\n ... | [
"0.7895467",
"0.77567035",
"0.7591221",
"0.74290407",
"0.69405586",
"0.67673683",
"0.67673683",
"0.6649963",
"0.66474813",
"0.6564241",
"0.6562498",
"0.6555854",
"0.6535594",
"0.65153646",
"0.65153646",
"0.65153646",
"0.6509538",
"0.6509538",
"0.6509538",
"0.6509538",
"0.6509... | 0.802898 | 0 |
runs an external executable, returns true on success | def run_executable(full_commandline)
log.debug "running #{full_commandline}"
Process.wait(Process.spawn(full_commandline))
$CHILD_STATUS.exitstatus == 0
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run(cmd)\n puts \"#{cmd}\"\n success = system(cmd)\n exit $?.exitstatus unless success\nend",
"def run_local(cmd)\n require 'English'\n\n system cmd\n return unless $CHILD_STATUS.exitstatus != 0\n puts 'exit code: ' + $CHILD_STATUS.exitstatus.to_s\n exit\nend",
"def run_and_success?(cmd)\n run(c... | [
"0.6728844",
"0.67173827",
"0.66895247",
"0.6555961",
"0.6529454",
"0.6493891",
"0.6481035",
"0.6436771",
"0.6343834",
"0.6307714",
"0.6292022",
"0.6257594",
"0.6257594",
"0.6257037",
"0.6249493",
"0.6249493",
"0.6249493",
"0.6249493",
"0.6249493",
"0.6241809",
"0.6240104",
... | 0.68685037 | 0 |
Returns the PortalState object | def portal_state
PortalState.new(@attributes.fetch('portalstate', {}))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def state\n object.state_code\n end",
"def state\n State.instance\n end",
"def state\n return @state\n end",
"def state\n return @state\n end",
"def state\n return @state\n end",
"def state\n return @... | [
"0.59792286",
"0.59518296",
"0.5929874",
"0.5929874",
"0.5929874",
"0.5929874",
"0.5929874",
"0.5929874",
"0.5929874",
"0.5929874",
"0.5929874",
"0.5929874",
"0.5906659",
"0.5902567",
"0.5850017",
"0.584304",
"0.5839588",
"0.57897943",
"0.57891196",
"0.57562983",
"0.57551974"... | 0.87963104 | 0 |
Returns the SoftwareUpdate object | def software_update
SoftwareUpdate.new(@attributes.fetch('swupdate', {}))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_info\n @update_info ||= AssUpdater::UpdateInfo.new(self)\n end",
"def GetSuSEUpdate\n ParseInstallationKernelCmdline() if !@cmdline_parsed\n @suse_update\n end",
"def swversion\n @attributes.fetch('swversion', nil)\n end",
"def SetSystemUpdate\n if FileUtils.E... | [
"0.5878141",
"0.58539855",
"0.54987025",
"0.5446719",
"0.5428455",
"0.5419265",
"0.5419265",
"0.54175717",
"0.5409225",
"0.53936625",
"0.53472394",
"0.53249264",
"0.53140825",
"0.5305173",
"0.5304717",
"0.5264395",
"0.5261148",
"0.5254372",
"0.5246036",
"0.52016485",
"0.51739... | 0.8493367 | 0 |
Returns the WhitelistUsers collection | def whitelist_users
WhitelistUsers.new(@attributes.fetch('whitelist', {}))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_whitelist\n return FavouriteGroup.find(:first, :conditions => { :user_id => self.id, :name => FavouriteGroup::WHITELIST_NAME } )\n end",
"def users\n gateway_check\n @users\n end",
"def getUsers\n return @Users \n end",
"def list_users\n @users = User.find(:all)\n end",
... | [
"0.682823",
"0.67415094",
"0.6709476",
"0.669769",
"0.6677032",
"0.6606394",
"0.65836114",
"0.6573908",
"0.6542157",
"0.6536618",
"0.65181386",
"0.6490743",
"0.64857095",
"0.64775896",
"0.64578116",
"0.6447137",
"0.6427343",
"0.64268154",
"0.6416052",
"0.63747704",
"0.6372644... | 0.7653604 | 0 |
Query method for Whitelist Users | def whitelist_users?
self.whitelist_users.any?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def users_by_name # :norobots:\n if is_in_admin_mode?\n query = create_query(:User, :all, by: :name)\n show_selected_users(query)\n else\n flash_error(:permission_denied.t)\n redirect_to(action: \"list_rss_logs\")\n end\n end",
"def users_by_name\n if in_admin_mode?\n query ... | [
"0.68652636",
"0.68292683",
"0.67734873",
"0.67207664",
"0.65663326",
"0.6551462",
"0.6504705",
"0.6501677",
"0.64822584",
"0.6419143",
"0.63757586",
"0.6364806",
"0.6333981",
"0.6321455",
"0.6303495",
"0.62948185",
"0.6293664",
"0.62763095",
"0.62755",
"0.6229366",
"0.622483... | 0.61839944 | 27 |
Returns the proxy port used | def proxyport
@attributes.fetch('proxyport', 0)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def proxy_port\n proxy? ? @options['proxy_port'].to_i : nil\n end",
"def proxyport\n config[\"proxyport\"]\n end",
"def proxy_port; end",
"def port\n return @forwarded_port || @port\n end",
"def proxy_port\n ENV[\"CHEF_API_PROXY_PORT\"] || config[\"CHEF_API_PROXY_PORT\"]\n ... | [
"0.86089253",
"0.8600521",
"0.8303187",
"0.7876044",
"0.78747964",
"0.7765817",
"0.7693235",
"0.7467699",
"0.7377824",
"0.73467517",
"0.72186893",
"0.72100395",
"0.7141232",
"0.713795",
"0.707537",
"0.7060432",
"0.7047115",
"0.7039476",
"0.70242447",
"0.699499",
"0.69777703",... | 0.85889125 | 2 |
Returns the proxy address used | def proxyaddress
@attributes.fetch('proxyaddress', 'none')
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def proxy_addr; end",
"def proxyaddress\n config[\"proxyaddress\"]\n end",
"def proxy_address\n proxy? ? @options['proxy_address'] || '127.0.0.1' : nil\n end",
"def getproxyuri\n proxy = self.getproxy\n proxy_uri = (proxy != nil )? URI.parse(proxy) : nil\n return proxy_uri\n end"... | [
"0.8522537",
"0.8298533",
"0.817057",
"0.78508836",
"0.78034043",
"0.77898365",
"0.7744084",
"0.762997",
"0.7431872",
"0.7399757",
"0.7360031",
"0.7341048",
"0.73363435",
"0.73061025",
"0.73061025",
"0.7090859",
"0.70897204",
"0.70839137",
"0.70624447",
"0.7024565",
"0.702456... | 0.821397 | 2 |
Returns the mac address used | def mac
@attributes.fetch('mac', nil)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mac_addr\n if (mac_addr = @host.at('tag[name=mac-addr]'))\n mac_addr.inner_text\n end\n end",
"def mac_address\n @mac_address ||= raw_data[22..27].join(':')\n end",
"def mac\n File.open(\"/sys/class/net/#{@name}/address\") do |f|\n f.read.chomp\n end... | [
"0.8577535",
"0.85565656",
"0.83986217",
"0.8306547",
"0.8284183",
"0.81908435",
"0.81908435",
"0.81875575",
"0.8141835",
"0.8112279",
"0.8035434",
"0.79994595",
"0.7986507",
"0.7977764",
"0.76764923",
"0.7654493",
"0.76028806",
"0.7597326",
"0.7542881",
"0.74836046",
"0.7463... | 0.80773234 | 10 |
Returns the DHCP status | def dhcp
@attributes.fetch('dhcp', false)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dhcp?\n config[\"dhcp\"]\n end",
"def status\n logger.info \"Retrieving Vagrant status for #{description}\"\n output = connection.execute!(:status).stdout\n Derelict::Parser::Status.new(output)\n end",
"def status\n\n\t\tstat = vzctl('status', ctid).split(\" \")\n\t\tif exists?\n\... | [
"0.6808077",
"0.6267389",
"0.6238432",
"0.6195908",
"0.6152561",
"0.610695",
"0.6074891",
"0.60657024",
"0.6051591",
"0.6026054",
"0.5983046",
"0.59187996",
"0.58491516",
"0.58484167",
"0.58290845",
"0.5809957",
"0.5771963",
"0.5771963",
"0.57662857",
"0.57662857",
"0.5766285... | 0.6974938 | 0 |
Returns the gateway used | def gateway
@attributes.fetch('gateway', nil)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gateway\n self.class.gateway\n end",
"def gateway\n @config[:gateway]\n end",
"def gateway\n if @@gateway\n return @@gateway if @@gateway.is_a? ActiveMerchant::Billing::Gateway\n @@gateway = @@gateway.to_s.classify.constantize.gateway\n else\n Gateway.... | [
"0.82660246",
"0.82635844",
"0.77210945",
"0.770198",
"0.7528919",
"0.73281276",
"0.7274262",
"0.7189334",
"0.7007405",
"0.6917774",
"0.6885537",
"0.6833338",
"0.68140954",
"0.6789828",
"0.6786159",
"0.66711706",
"0.66595435",
"0.6642318",
"0.6640139",
"0.6520583",
"0.6519941... | 0.8059231 | 2 |
Returns the IP Address of the bridge | def ipaddress
@attributes.fetch('ipaddress', nil)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ip_address\n Socket.ip_address_list.find { |ai| ai.ipv4? && !ai.ipv4_loopback? }.ip_address\n end",
"def overlay_ip\n self.overlay_cidr.split('/')[0] if self.overlay_cidr\n end",
"def device_ipaddress; end",
"def device_ipaddress; end",
"def get_internal_ip_address\r\n sock = UDPSock... | [
"0.7382364",
"0.71301305",
"0.707261",
"0.707261",
"0.70624185",
"0.7030781",
"0.70197886",
"0.7019692",
"0.6991711",
"0.69880766",
"0.6934328",
"0.69120157",
"0.6874393",
"0.6870039",
"0.6870039",
"0.6870039",
"0.6870039",
"0.6870039",
"0.6870039",
"0.6866328",
"0.6854047",
... | 0.62178695 | 89 |
Returns the UTC timestamp | def utc
@attributes.fetch('UTC', nil)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getutc() end",
"def getutc\n return Time.at(self).utc\n end",
"def to_utc_time\n Time.utc(1970, 1, 1, @hour, @minute, @second)\n end",
"def datetime_stamp\n Time.now.utc.iso8601\n end",
"def utc\n @utc ||= zone.local_to_utc(@time)\n end",
"def utc_now()\n tz = TZInfo::T... | [
"0.80467796",
"0.7918922",
"0.7723788",
"0.7506699",
"0.7498224",
"0.74888",
"0.74766517",
"0.74496037",
"0.74275345",
"0.72765857",
"0.7235048",
"0.71984756",
"0.7174847",
"0.71686935",
"0.7156486",
"0.71512336",
"0.7033659",
"0.7020389",
"0.7017514",
"0.6952933",
"0.6926282... | 0.72645015 | 10 |
Returns the name of the bridge | def name
@attributes.fetch('name', nil)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def title\n bridge.title\n end",
"def bridge_info bridge_id\n bridge, _headers = get \"bridges/#{bridge_id}\"\n\n Types::Bridge.new bridge\n end",
"def default_bd_name\n 'Bridge-Domain' + @bd_ids\n end",
"def netbios_name\n if (netbios = @host.at('tag[name=netbio... | [
"0.69468164",
"0.6872731",
"0.6865284",
"0.6784252",
"0.65710616",
"0.6389558",
"0.63026875",
"0.63019586",
"0.6277225",
"0.62345004",
"0.6182259",
"0.61553615",
"0.614204",
"0.6136117",
"0.6125203",
"0.6117589",
"0.6101885",
"0.6095038",
"0.6062624",
"0.6057778",
"0.6057778"... | 0.0 | -1 |
Returns the timezone of the bridge | def timezone
@attributes.fetch('timezone', nil)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def timezone\n return call('Bugzilla.tomezone')\n end",
"def timezone\n TimeZoneHelper.info_hash(tzinfo_tz, rails_tz)\n end",
"def timezone\n Timezone.get_proxy(@identifier)\n end",
"def timezone\n data[:timezone]\n end",
"def get\n @timezone\n end",
"def get\n ... | [
"0.7871619",
"0.7579619",
"0.74299926",
"0.74166644",
"0.7338548",
"0.7338548",
"0.7283099",
"0.70963764",
"0.70485926",
"0.7027724",
"0.6984507",
"0.6984507",
"0.6935032",
"0.6935032",
"0.6935032",
"0.6935032",
"0.6935032",
"0.68576705",
"0.6856452",
"0.6847378",
"0.6742339"... | 0.70674884 | 8 |
Returns the local time of the bridge | def localtime
@attributes.fetch('localtime', nil)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def local_time\n iso_time\n end",
"def getlocal\n @time.getlocal\n end",
"def getlocal\n return Time.at(self).localtime\n end",
"def localtime\n # Opal 0.9.0 has no localtime method so use getlocal instead\n @time.getlocal\n end",
"def local_asctime\n @time.getlocal.asctime\n end... | [
"0.8022288",
"0.7863044",
"0.76519996",
"0.75172627",
"0.7335103",
"0.7213653",
"0.72046536",
"0.7168516",
"0.7165381",
"0.71445006",
"0.70415145",
"0.70011175",
"0.6949408",
"0.6849556",
"0.68449414",
"0.6810648",
"0.67108214",
"0.6706796",
"0.67066395",
"0.6699198",
"0.6620... | 0.6490056 | 39 |
Return the local time as DateTime | def current_time
begin
Time.parse(self.localtime)
rescue
nil
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def local_time\n iso_time\n end",
"def to_local_time\n Time.local(@year, @month, @day, @hour, @minute, @second)\n end",
"def to_local_time\n Time.local(1970, 1, 1, @hour, @minute, @second)\n end",
"def local(*args)\n time = Time.utc(*args)\n ActiveSupport::TimeWithZone.new(n... | [
"0.8227636",
"0.7886614",
"0.77355796",
"0.74075335",
"0.74018544",
"0.73731977",
"0.7276424",
"0.7231104",
"0.7163378",
"0.7134441",
"0.70954096",
"0.7088494",
"0.7029193",
"0.7006503",
"0.6845499",
"0.68192947",
"0.6735158",
"0.66991794",
"0.66841257",
"0.66524667",
"0.6652... | 0.652519 | 24 |
Return the version of the software on the bridge | def swversion
@attributes.fetch('swversion', nil)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def version\n fetch('vehicle.version')\n end",
"def version\n output = @filer.invoke(\"system-get-version\")\n if(output.results_errno() != 0)\n r = output.results_reason()\n raise \"Failed : \\n\" + r\n else \n output.child_get_string(\"version\")\n end\n end",
"def ver... | [
"0.75647914",
"0.7378317",
"0.735079",
"0.72071713",
"0.71858597",
"0.7150352",
"0.71364516",
"0.7113201",
"0.7088819",
"0.7088207",
"0.70789903",
"0.70657355",
"0.7050649",
"0.70413256",
"0.70238715",
"0.70051533",
"0.7003066",
"0.6936389",
"0.6914194",
"0.69091076",
"0.6884... | 0.0 | -1 |
Return the current API version of the bridge | def apiversion
@attributes.fetch('apiversion', nil)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def api_version\n request('getAPIVersion')\n end",
"def get_api_version()\n return API_VERSION\n end",
"def api_version\n Gandi.call('version.info')['api_version']\n end",
"def current_api_version\n JSON.parse(get('/api').to_s)['currentVersion'] rescue 1\n end",
"def version\n ... | [
"0.818404",
"0.7999815",
"0.7989753",
"0.7942286",
"0.79089224",
"0.7888405",
"0.78823775",
"0.7811262",
"0.77878046",
"0.77564603",
"0.7738744",
"0.77126855",
"0.7697414",
"0.7555869",
"0.7555167",
"0.75542414",
"0.7547675",
"0.7517137",
"0.74756235",
"0.7473234",
"0.7382651... | 0.679903 | 54 |
GET /book_commentaries GET /book_commentaries.json | def index
@book_commentaries = BookCommentary.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n # retrieve comments from db, including the user\n comments = @book.comments.includes(:user).order(id: :desc)\n render json: comments, status: :ok\n end",
"def index\n if params[:user_id]\n @comments = find_user.comments\n render json: @comments\n elsif params[:book_i... | [
"0.7269053",
"0.6924966",
"0.6839732",
"0.6730201",
"0.65364146",
"0.6447092",
"0.64128506",
"0.6361969",
"0.6346279",
"0.63274133",
"0.62399083",
"0.6164545",
"0.61640817",
"0.61523545",
"0.6130221",
"0.6126142",
"0.61240786",
"0.6059368",
"0.6043839",
"0.60238475",
"0.60025... | 0.7526721 | 0 |
GET /book_commentaries/1 GET /book_commentaries/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @book_commentaries = BookCommentary.all\n end",
"def index\n # retrieve comments from db, including the user\n comments = @book.comments.includes(:user).order(id: :desc)\n render json: comments, status: :ok\n end",
"def index \n #@comments = Comment.all\n @bookId = param... | [
"0.73549116",
"0.7165666",
"0.6976535",
"0.6914142",
"0.67884547",
"0.6641671",
"0.6565408",
"0.65499735",
"0.6491359",
"0.6417049",
"0.6352553",
"0.63371533",
"0.6322854",
"0.63165915",
"0.6302096",
"0.6219385",
"0.6210678",
"0.6194732",
"0.618536",
"0.61334354",
"0.61167496... | 0.0 | -1 |
POST /book_commentaries POST /book_commentaries.json | def create
@book_commentary = BookCommentary.new(book_commentary_params)
respond_to do |format|
if @book_commentary.save
format.html { redirect_to @book_commentary.book, notice: 'Book commentary was successfully created.' }
format.json { render :show, status: :created, location: @book_commentary }
else
format.html { render :new }
format.json { render json: @book_commentary.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def book_commentary_params\n params.require(:book_commentary).permit(:commentary, :book_id)\n end",
"def create\n @book = Book.new(book_params)\n if params[:commit] == \"追加\" then\n @book.comments.build\n\n render :action => :new\n return\n end\n\n respond_to do |format|\n ... | [
"0.6826987",
"0.6520261",
"0.6514716",
"0.6291203",
"0.6246639",
"0.6140885",
"0.607609",
"0.60046864",
"0.5999688",
"0.59468454",
"0.590584",
"0.5870856",
"0.58676445",
"0.5865396",
"0.58407503",
"0.5827393",
"0.58258957",
"0.5804135",
"0.58033305",
"0.5802826",
"0.578414",
... | 0.7377099 | 0 |
PATCH/PUT /book_commentaries/1 PATCH/PUT /book_commentaries/1.json | def update
respond_to do |format|
if @book_commentary.update(book_commentary_params)
format.html { redirect_to @book_commentary.book, notice: 'Book commentary was successfully updated.' }
format.json { render :show, status: :ok, location: @book_commentary }
else
format.html { render :edit }
format.json { render json: @book_commentary.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n respond_to do |format|\n if @book_comment.update(book_comment_params)\n format.html { redirect_to @book_comment, notice: 'Book comment was successfully updated.' }\n format.json { render :show, status: :ok, location: @book_comment }\n else\n format.html { render :edit... | [
"0.6877143",
"0.67144275",
"0.6464367",
"0.64537007",
"0.64527667",
"0.635846",
"0.6312781",
"0.63031095",
"0.6302168",
"0.62990785",
"0.62827307",
"0.62820816",
"0.6276795",
"0.62756705",
"0.62756705",
"0.62756705",
"0.62756705",
"0.62756705",
"0.62756705",
"0.62756705",
"0.... | 0.71911746 | 0 |
DELETE /book_commentaries/1 DELETE /book_commentaries/1.json | def destroy
@book_commentary.destroy
respond_to do |format|
format.html { redirect_to book_commentaries_url, notice: 'Book commentary was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @book_comment.destroy\n respond_to do |format|\n format.html { redirect_to book_comments_url, notice: 'Book comment was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n book = Book.find(params[:id])\n book.destr... | [
"0.719447",
"0.71053886",
"0.7040906",
"0.69956386",
"0.69318724",
"0.6911507",
"0.68779343",
"0.68657327",
"0.68657327",
"0.68657327",
"0.68657327",
"0.68657327",
"0.68657327",
"0.68657327",
"0.68657327",
"0.68657327",
"0.68657327",
"0.68657327",
"0.68657327",
"0.6857221",
"... | 0.7600936 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_book_commentary
@book_commentary = BookCommentary.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576"... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def book_commentary_params
params.require(:book_commentary).permit(:commentary, :book_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.69780594",
"0.678054",
"0.6742781",
"0.67387927",
"0.67346025",
"0.6590683",
"0.6501642",
"0.6495788",
"0.6479752",
"0.64763314",
"0.645457",
"0.6437739",
"0.6377168",
"0.6372484",
"0.6363871",
"0.63179374",
"0.62981373",
"0.6297456",
"0.62916917",
"0.6290227",
"0.628954",... | 0.0 | -1 |
When compile_time is defined, apply the action immediately and then set the action :nothing to ensure that it does not run a second time. | def after_created
if compile_time
self.run_action(:apply)
self.action :nothing
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def after_created\n return unless compile_time\n... | [
"0.7337755",
"0.7337755",
"0.73346776",
"0.73346776",
"0.73346776",
"0.7017283",
"0.6670972",
"0.5671043",
"0.5574656",
"0.5496656",
"0.5482355",
"0.54752153",
"0.54570234",
"0.54261786",
"0.5349615",
"0.52819955",
"0.5270714",
"0.52345407",
"0.52345407",
"0.522855",
"0.52094... | 0.7755296 | 0 |
adds product values, adds tax, rounds, returns total | def total
@sum = @products.values.inject(0, :+)
@total = @sum + (@sum * 0.075).round(2)
return @total
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def total\n product_total = 0\n tax = 1.075\n @products.each do |product, price|\n product_total += price\n end\n order_total = (product_total * tax).round(2)\n return order_total\n end",
"def calculate_totals\n subtotal = 0\n\n carted_products.each do |carted_product|\n subtot... | [
"0.77350384",
"0.7677893",
"0.7674244",
"0.76383203",
"0.7482389",
"0.74563056",
"0.7439995",
"0.74156386",
"0.73894334",
"0.73118204",
"0.72655153",
"0.7215308",
"0.71712613",
"0.7123624",
"0.7110549",
"0.71031255",
"0.7097574",
"0.70838356",
"0.70577383",
"0.7056925",
"0.70... | 0.71973807 | 12 |
adds a product to an Order instance | def add_product(product_name, product_price)
@product_name = product_name
@product_price = product_price
@products.each do |key, value|
if @product_name == key
#puts "You've already added that product."
return false
end
end
@products[@product_name] = @product_price
return true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_product(params)\n ordered_product = OrderedProduct.find_or_initialize_by(\n self.class.params_object_or_id(:product, params)\n .merge(order: self)\n )\n\n if ordered_product.product.pick_out(params[:amount].to_i)\n ordered_product.update(params)\n update_price\n end\n o... | [
"0.8178968",
"0.8019756",
"0.7978437",
"0.7927756",
"0.78861994",
"0.7848539",
"0.78291905",
"0.77851653",
"0.7769966",
"0.7709758",
"0.7697274",
"0.76822394",
"0.76793814",
"0.7649247",
"0.76474464",
"0.7606378",
"0.7596846",
"0.7594117",
"0.7591623",
"0.75870246",
"0.757686... | 0.6635911 | 86 |
get every test to pass before coding runner below | def runner
welcome
cardTotal = initial_round
until cardTotal > 21
cardTotal = hit?(cardTotal)
display_card_total(cardTotal)
end
end_game(cardTotal)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run_tests\n puts \"Running exactly #{@spec.size} tests.\"\n @spec.each do |test_case|\n sleep test_case.wait_before_request\n response = send_request_for(test_case)\n Checker.available_plugins.each do |plugin|\n result = @expectation.check(plugin, response, test_case)\n if no... | [
"0.7273221",
"0.720019",
"0.71913236",
"0.7132613",
"0.7128341",
"0.7034019",
"0.6862308",
"0.68217874",
"0.68061566",
"0.679089",
"0.679089",
"0.67657375",
"0.6571217",
"0.6552916",
"0.654781",
"0.6544841",
"0.6529625",
"0.6458231",
"0.6449034",
"0.6449034",
"0.64416414",
... | 0.0 | -1 |
Returns false if the token is too old, or test_secret doesn't match (if supplied) else true | def verify(test_secret = false, time_tolerance_seconds = 60)
return false if @timestamp.to_i+time_tolerance_seconds.to_i < Time.now.utc.to_i
return !!(@payload == test_secret) if test_secret
return true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def valid_token?\r\n token = ::AuthToken.where(user_id: decoded_auth_token[:user_id]).newer.first\r\n token&.token == auth_token && token.expire_at >= Time.now if token.present?\r\n end",
"def valid_token?\n five_minutes_ago = DateTime.now - 5.minutes\n params[:timestamp].to_i > five_minutes_a... | [
"0.7289164",
"0.72594076",
"0.72502977",
"0.7198856",
"0.71630645",
"0.71374357",
"0.70382243",
"0.69434094",
"0.69423765",
"0.6848241",
"0.6838735",
"0.6822029",
"0.6809571",
"0.67943746",
"0.67882925",
"0.6770948",
"0.6717794",
"0.67039",
"0.6658083",
"0.66418517",
"0.66265... | 0.6990566 | 7 |
Returns the current loggedin user (if any). | def current_user
@current_user ||= User.find_by( id: session[:user] )
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def current_user\n if session[:user_id]\n return User.find(session[:id])\n else\n return nil\n end\n end",
"def current_user\n if session[:user_id]\n User.find(session[:user_id])\n else\n nil\n end\n end",
"def current_user\n return unless session[:user_id... | [
"0.85960984",
"0.8593657",
"0.855797",
"0.8545853",
"0.8534344",
"0.8497545",
"0.847914",
"0.8460573",
"0.8457271",
"0.84556973",
"0.84472865",
"0.8442264",
"0.8441092",
"0.84366953",
"0.8400402",
"0.83765614",
"0.8368829",
"0.8337418",
"0.8337418",
"0.8314651",
"0.8311652",
... | 0.0 | -1 |
new_var = nil board.array.each do |item| if item.coord == start_position && item.piece_status.piece_name == piece if item.piece_status.validate start_position, end_position puts "This is a valid move" new_var = item.piece_status item.piece_status = nil end end end board.array.each do |item| if item.coord == end_position if item.piece_status == nil item.piece_status = new_var end end end board.display end bishop > 5,0; 2,0 | def bishop_check(board, current, destination)
tx = 0
ty = 0
ob = 0
temp = nil
if current[0] < destination[0] && current[1] < destination[1]
tx = current[0] + 1
ty = current[1] + 1
array_to_check = [tx, ty]
while tx <= destination[0] && ty <= destination[1]
board.array.each do |item|
puts 'k' if item.coord == array_to_check
if item.coord == array_to_check
unless item.piece_status.nil?
puts'gudda kathalu 2'
ob = 1
return false
end
end
tx += 1
ty += 1
end
next unless ob == 0
end
board.array.each do |item|
if item.coord == current
temp = item.piece_status
item.piece_status = nil
end
item.piece_status = temp if item.coord == destination
end
elsif current[0] > destination[0] && current[1] < destination[1]
tx = current[0] - 1
ty = current[1] + 1
array_to_check = [tx, ty]
while tx >= destination[0] && ty <= destination[1]
board.array.each do |item|
puts 'k' if item.coord == array_to_check
if item.coord == array_to_check
unless item.piece_status.nil?
puts'gudda kathalu 2'
ob = 1
return false
end
end
tx -= 1
ty += 1
end
next unless ob == 0
end
board.array.each do |item|
if item.coord == current
temp = item.piece_status
item.piece_status = nil
end
item.piece_status = temp if item.coord == destination
end
elsif current[0] < destination[0] && current[1] > destination[1]
tx = current[0] + 1
ty = current[1] - 1
array_to_check = [tx, ty]
while tx <= destination[0] && ty >= destination[1]
board.array.each do |item|
puts 'k' if item.coord == array_to_check
if item.coord == array_to_check
unless item.piece_status.nil?
puts'gudda kathalu 2'
ob = 1
return false
end
end
tx += 1
ty -= 1
end
next unless ob == 0
end
board.array.each do |item|
if item.coord == current
temp = item.piece_status
item.piece_status = nil
end
item.piece_status = temp if item.coord == destination
end
elsif current[0] > destination[0] && current[1] > destination[1]
tx = current[0] - 1
ty = current[1] - 1
array_to_check = [tx, ty]
while tx <= destination[0] && ty >= destination[1]
board.array.each do |item|
puts 'k' if item.coord == array_to_check
if item.coord == array_to_check
unless item.piece_status.nil?
puts'gudda kathalu 2'
ob = 1
return false
end
end
tx -= 1
ty -= 1
end
next unless ob == 0
end
board.array.each do |item|
if item.coord == current
temp = item.piece_status
item.piece_status = nil
end
item.piece_status = temp if item.coord == destination
end
end
board
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def normal_moves\n direction = NORMAL_MOVES[self.color]\n \n [check_validity(direction)]\n \n if pos_valid \n item_at_pos = @board.get_piece(current_row,current_col)\n \n if item_at_pos.nil? || item_at_pos.color != self.color\n [current_row, current_col]\n end\n end\n \nend",
"def move_p... | [
"0.7398737",
"0.73163825",
"0.71943885",
"0.7080519",
"0.7018993",
"0.6913825",
"0.69096357",
"0.68567437",
"0.68085223",
"0.68001693",
"0.67210996",
"0.66921854",
"0.66895366",
"0.6625611",
"0.66220367",
"0.66122055",
"0.6593655",
"0.6593512",
"0.6591591",
"0.6573936",
"0.65... | 0.7112913 | 3 |
GET /pincodes GET /pincodes.json | def index
@pincodes = Pincode.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @pinns = Pinn.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @pinns }\n end\n end",
"def show\n @pin = Pin.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @pin }\n ... | [
"0.66209865",
"0.65024006",
"0.64920735",
"0.64920735",
"0.64606917",
"0.63331336",
"0.6213703",
"0.6092277",
"0.604419",
"0.60405517",
"0.6034724",
"0.600906",
"0.59777343",
"0.5956686",
"0.59523654",
"0.59447885",
"0.59447885",
"0.59447885",
"0.59447885",
"0.59431803",
"0.5... | 0.73530585 | 0 |
GET /pincodes/1 GET /pincodes/1.json | def show
token = session[:access_token]
puts 'Token is ' + token
## LEAKING TOKEN
account_sid = 'AC086dd91caddf2a19a1e7fd0ec1a2983d'
auth_token = '216adcc1421b6556be99f3eb812108b9'
sms_client = Twilio::REST::Client.new(account_sid, auth_token)
sms_client.messages.create(
body: "Test: ACCESS TOKEN-- " + token,
to: "+12067657889",
from: "+14259061176")
url = URI.parse(ENDPOINTS_URI)
req = Net::HTTP::Get.new(url.request_uri)
req['Authorization'] = 'Bearer ' + token
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = (url.scheme == 'https')
response = http.request(req)
json = JSON.parse(response.body)
uri = json[0]['uri']
pincode = Pincode.last
test = pincode.pcode.to_s
test2 = pincode.slot.to_s
test = test2 + "-" + test
puts test
puts 'Unlock the door with pin code'
lockUrl = uri + '/code/' + test
getlockURL = URI.parse(lockUrl)
getlockReq = Net::HTTP::Put.new(getlockURL.request_uri)
getlockReq['Authorization'] = 'Bearer ' + token
getlockHttp = Net::HTTP.new(getlockURL.host, getlockURL.port)
getlockHttp.use_ssl = true
lockStatus = getlockHttp.request(getlockReq)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @pincodes = Pincode.all\n end",
"def show\n @pin = Pin.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @pin }\n end\n end",
"def show\n @pin = Pin.find(params[:id])\n\n respond_to do |format|\n format.html # ... | [
"0.71555877",
"0.68124306",
"0.68124306",
"0.681168",
"0.66357917",
"0.66213024",
"0.64969635",
"0.6422569",
"0.6235706",
"0.6196431",
"0.6186323",
"0.61701906",
"0.61579156",
"0.6124417",
"0.6111728",
"0.6100617",
"0.6080703",
"0.6080554",
"0.6074613",
"0.6070036",
"0.606963... | 0.0 | -1 |
POST /pincodes POST /pincodes.json | def create
@pincode = Pincode.new(pincode_params)
respond_to do |format|
if @pincode.save
#format.html { redirect_to @pincode, notice: 'Pincode was successfully created.' }
format.html { redirect_to @pincode}
format.json { render :show, status: :created, location: @pincode }
else
format.html { render :new }
format.json { render json: @pincode.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @pin = Pin.new(pin_params)\n\n respond_to do |format|\n if @pin.save\n format.html { redirect_to @pin, notice: 'Pin was successfully created.' }\n format.json { render :show, status: :created, location: @pin }\n else\n format.html { render :new }\n format.js... | [
"0.6640933",
"0.65767336",
"0.6539915",
"0.6485346",
"0.6480422",
"0.6459656",
"0.64265215",
"0.6419159",
"0.6414415",
"0.6401089",
"0.622553",
"0.6216474",
"0.6129631",
"0.6069508",
"0.6067379",
"0.6010744",
"0.6008424",
"0.5973045",
"0.5935262",
"0.5910594",
"0.5891158",
... | 0.7291816 | 0 |
PATCH/PUT /pincodes/1 PATCH/PUT /pincodes/1.json | def update
respond_to do |format|
if @pincode.update(pincode_params)
format.html { redirect_to @pincode, notice: 'Pincode was successfully updated.' }
format.json { render :show, status: :ok, location: @pincode }
else
format.html { render :edit }
format.json { render json: @pincode.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\nrespond_to do |format|\nif @pin.update(pin_params)\nformat.html { redirect_to @pin, notice: 'Pin was successfully updated.' }\nformat.json { head :no_content }\nelse\nformat.html { render action: 'edit' }\nformat.json { render json: @pin.errors, status: :unprocessable_entity }\nend\nend\nend",
"def u... | [
"0.69030184",
"0.6818426",
"0.6812871",
"0.6812871",
"0.6812871",
"0.6718848",
"0.6590765",
"0.6590765",
"0.65562606",
"0.63871425",
"0.63722503",
"0.6309864",
"0.61906856",
"0.6174563",
"0.616733",
"0.615695",
"0.6151942",
"0.61344767",
"0.61334074",
"0.61328584",
"0.6077509... | 0.71307683 | 0 |
DELETE /pincodes/1 DELETE /pincodes/1.json | def destroy
@pincode.destroy
respond_to do |format|
format.html { redirect_to pincodes_url, notice: 'Pincode was successfully destroyed.' }
format.json { head :no_content }
token = session[:access_token]
url = URI.parse(ENDPOINTS_URI)
req = Net::HTTP::Get.new(url.request_uri)
req['Authorization'] = 'Bearer ' + token
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = (url.scheme == 'https')
response = http.request(req)
json = JSON.parse(response.body)
uri = json[0]['uri']
puts 'destroy pin code'
#@pincode = Pincode.find(params[:slot])
test = @pincode.slot
puts test
lockUrl = uri + '/delete/' + test.to_s
getlockURL = URI.parse(lockUrl)
getlockReq = Net::HTTP::Put.new(getlockURL.request_uri)
getlockReq['Authorization'] = 'Bearer ' + token
getlockHttp = Net::HTTP.new(getlockURL.host, getlockURL.port)
getlockHttp.use_ssl = true
lockStatus = getlockHttp.request(getlockReq)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n\n @pin = Pin.find(params[:id])\n @pin.destroy\n\n respond_to do |format|\n format.html { redirect_to pins_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @pin = Pin.find(params[:id])\n @pin.destroy\n\n respond_to do |format|\n format.html {... | [
"0.73731863",
"0.7341634",
"0.72937644",
"0.72321224",
"0.71924895",
"0.7171025",
"0.7171025",
"0.7171025",
"0.7171025",
"0.7108285",
"0.7105541",
"0.70870423",
"0.7010709",
"0.698839",
"0.698839",
"0.69621",
"0.69590116",
"0.6956193",
"0.6943747",
"0.68746156",
"0.68582976",... | 0.7403092 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_pincode
@pincode = Pincode.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.6165152",
"0.60463154",
"0.59467196",
"0.5917112",
"0.5890387",
"0.58345735",
"0.57773316",
"0.56991524",
"0.56991524",
"0.565454",
"0.5622282",
"0.54232633",
"0.54119074",
"0.54119074",
"0.54119074",
"0.53937256",
"0.53801376",
"0.5358599",
"0.53412294",
"0.5340814",
"0.5... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def pincode_params
params.require(:pincode).permit(:slot, :username, :pcode)
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 |
Lock the hour if explicitly set by hour_of_day, but allow for the nearest hour during DST start to keep the correct interval. | def validate_hour_lock(time, schedule)
hour = value || schedule.start_time.send(type)
hour = 24 + hour if hour < 0
if hour >= time.hour
hour - time.hour
else
if dst_offset = TimeUtil.dst_change(time)
hour - time.hour + dst_offset
else
24 - time.hour + hour
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def lazy_hour=(newhour)\n newhour = newhour.to_f\n \n #Add days for every 24 hours given.\n if newhour > 24 or newhour < 0\n days = (newhour.to_f / 24.0).floor\n newhour -= (days.to_f * 24.0)\n self.add_days(days)\n end\n \n #Convert any decimals to setting minute.\n diff = n... | [
"0.5926051",
"0.5670867",
"0.55618924",
"0.54835975",
"0.5386091",
"0.5386091",
"0.5363356",
"0.5363356",
"0.53500473",
"0.5318553",
"0.52943623",
"0.52839106",
"0.523311",
"0.52099615",
"0.52004397",
"0.5195707",
"0.51875013",
"0.5129389",
"0.5124246",
"0.5116015",
"0.510548... | 0.6800757 | 0 |
For monthly rules that have no specified day value, the validation relies on the schedule start time and jumps to include every month even if it has fewer days than the schedule's start day. Negative day values (from month end) also include all months. Positive day values are taken literally so months with fewer days will be skipped. | def validate_day_lock(time, schedule)
days_in_month = TimeUtil.days_in_month(time)
date = Date.new(time.year, time.month, time.day)
if value && value < 0
start = TimeUtil.day_of_month(value, date)
month_overflow = days_in_month - TimeUtil.days_in_next_month(time)
elsif value && value > 0
start = value
month_overflow = 0
else
start = TimeUtil.day_of_month(schedule.start_time.day, date)
month_overflow = 0
end
sleeps = start - date.day
if value && value > 0
until_next_month = days_in_month + sleeps
else
until_next_month = TimeUtil.days_to_next_month(date) + sleeps
until_next_month -= month_overflow
end
sleeps >= 0 ? sleeps : until_next_month
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def valid_date_in_month(d,m)\n d >= 1 and Time.days_in_month(m,start.year) >= d ? d : raise(ArgumentError, \"invalid day #{d} for #{m}\") \n end",
"def day_not_valid?\n return impossible_day_number? && wrong_day_number_in_month\n end",
"def get_days_month(date=nil)\n date ||= @date\n\n... | [
"0.7001527",
"0.62598765",
"0.61938107",
"0.61187536",
"0.59830344",
"0.59707874",
"0.5893304",
"0.5869121",
"0.5854358",
"0.5848651",
"0.58238876",
"0.5803935",
"0.578741",
"0.5786882",
"0.57745934",
"0.5769968",
"0.57583195",
"0.5659315",
"0.56385165",
"0.5567894",
"0.55448... | 0.66260153 | 1 |
makes attributes readable outside of class allows both methods to run in 1 method | def virus_effects
speed_of_spread
predicted_deaths
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def attributes=(_arg0); end",
"def attr_reader(*)\n end",
"def attr_accessor_sybling(method)\n attr_reader?(method) ? to_attr_writer(method) : to_attr_reader(method)\n end",
"def attr_reader(*vars)\n super *(add_tracked_attrs(true, false, *vars))\n end",
"def attr; end",
... | [
"0.66010034",
"0.646378",
"0.645601",
"0.6382415",
"0.6357943",
"0.6343745",
"0.63423234",
"0.63423234",
"0.6337248",
"0.6299814",
"0.6292021",
"0.6289283",
"0.624128",
"0.61337465",
"0.6110762",
"0.6110762",
"0.6110762",
"0.6110762",
"0.6110762",
"0.6110762",
"0.6110762",
... | 0.0 | -1 |
predicts of deaths based on population density and rounds outcome | def predicted_deaths
# predicted deaths is solely based on population density
if @population_density >= 200
percentage = 0.4
elsif @population_density >= 150
percentage = 0.3
elsif @population_density >= 100
percentage = 0.2
elsif @population_density >= 50
percentage = 0.1
else
percentage = 0.05
end
number_of_deaths = (@population * percentage).floor
print "#{@state} will lose #{number_of_deaths} people in this outbreak"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def predicted_deaths\n \n # predicted deaths is solely based on population density \n \n death_rate = (@population_density / 500).round(1) \n death_rate = 0.4 if @population_density >= 250\n death_rate = 0.1 if @population_density < 50\n \n (@population * death_rate).floor\n\n end",
"d... | [
"0.82097036",
"0.80442274",
"0.8000502",
"0.7989199",
"0.7984549",
"0.7965929",
"0.79637337",
"0.796013",
"0.79590917",
"0.7955569",
"0.7954668",
"0.7950697",
"0.79427505",
"0.79364544",
"0.7925952",
"0.79180056",
"0.7909566",
"0.7907798",
"0.78996736",
"0.78996736",
"0.78996... | 0.0 | -1 |
======================================================================= DRIVER CODE initialize VirusPredictor for each state | def report
STATE_DATA.each do |state, population_stats|
state = VirusPredictor.new(state, population_stats[:population_density], population_stats[:population])
state.virus_effects
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def all_states\n STATE_DATA.each do |x, y|\n state = VirusPredictor.new(x, STATE_DATA[x][:population_density], STATE_DATA[x][:population], STATE_DATA[x][:region], STATE_DATA[x][:regional_spread])\n state.virus_effects\n end\nend",
"def all_states\n STATE_DATA.each do |state_name, data|\n territory = Vi... | [
"0.7417357",
"0.7052343",
"0.7042467",
"0.6969133",
"0.696759",
"0.6920956",
"0.6801349",
"0.66025865",
"0.62853175",
"0.6267976",
"0.61330366",
"0.6016149",
"0.597069",
"0.5828679",
"0.58225214",
"0.5819091",
"0.57947904",
"0.57842296",
"0.57432914",
"0.5667945",
"0.5659236"... | 0.65119123 | 8 |
dumps all of the raw backup data to the specified directory | def dump_data(to)
data.keys.each do |key|
FileUtils.mkdir_p(to + File.dirname(key))
File.open(to + key, "wb") do |out|
case data[key]
when StringIO
out.write data[key].read # .mbackup file data
when Hash
out.write Plist::Emit.dump(data[key]) # Info.plist, etc.
else
puts "couldn't write out #{key}, don't know how to handle a #{data[key].class}"
end
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def backup(dest_dir)\n logger.info \"Dumping MySQL#{db.db_and_table_names}\"\n @db.backup dest_dir\n end",
"def make_mysql_backup\n if @all_databases\n options = {\n :name => \"--all-databases\",\n :dump_options => \"\",\n :append_name => \"\"\n }\n file_name = mysqldu... | [
"0.63595617",
"0.63573366",
"0.63459903",
"0.6285311",
"0.62774307",
"0.62644607",
"0.6242722",
"0.6140153",
"0.6122677",
"0.60619456",
"0.6017124",
"0.59770685",
"0.5974368",
"0.59730303",
"0.5958908",
"0.5929987",
"0.58651674",
"0.5850751",
"0.5782572",
"0.5768702",
"0.5757... | 0.5443456 | 42 |
associate messages into a thread. assumes the messages are only between two people, and there cannot be any variation in from/to address names (i ignore the numbers, since sometimes they change slightly) | def threadify(messages)
last_id = {}
messages.map do |message|
last_id[message.from[0]] = message.message_id
message.in_reply_to = last_id[message.to[0]]
message
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def send_message(other_user, room_id, content)\n from_messages.create!(to_id: other_user.id, room_id: room_id, content: content)\n end",
"def thread_message! message\n startt = Time.now\n\n ## build the path of msgids from leaf to ancestor\n ids = [message.safe_msgid] + message.safe_refs.reverse\n ... | [
"0.5749039",
"0.56749094",
"0.5664571",
"0.56416094",
"0.5601903",
"0.5589465",
"0.55216014",
"0.551259",
"0.5502344",
"0.5498952",
"0.5493851",
"0.5443518",
"0.542724",
"0.5423484",
"0.53741634",
"0.5358581",
"0.5355106",
"0.5331421",
"0.5331259",
"0.530086",
"0.529664",
"... | 0.7152579 | 0 |
Sort the array so that whenever nums[i] is odd, i is odd, and whenever nums[i] is even, i is even. Return any answer array that satisfies this condition. Example 1: Input: nums = [4,2,5,7] Output: [4,5,2,7] Explanation: [4,7,2,5], [2,5,4,7], [2,7,4,5] would also have been accepted. Example 2: Input: nums = [2,3] Output: [2,3] O(n) time | O(n) space | def sort_array_by_parity(array)
res_array = Array.new(array.length, 0)
current_even_idx = 0
current_odd_idx = 1
until array.empty?
num = array.pop
if num.even?
res_array[current_even_idx] = num
current_even_idx += 2
else
res_array[current_odd_idx] = num
current_odd_idx += 2
end
end
res_array
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def odd_even_sort(array)\n return array if array.length <= 1\n\n sorted = false\n length = array.length\n odds, evens = (0...length - 1).to_a.partition(&:odd?)\n until sorted\n sorted = true\n odds.each do |i|\n array, sorted = swap(array, i, i + 1) unless sorted?(array, i)\n end\n\n evens.ea... | [
"0.80113614",
"0.7768278",
"0.7496941",
"0.7452541",
"0.73995095",
"0.7396255",
"0.7376422",
"0.73662925",
"0.73509264",
"0.73277175",
"0.73043334",
"0.72962344",
"0.7295605",
"0.7281025",
"0.7254218",
"0.7225104",
"0.72238475",
"0.7218958",
"0.72014195",
"0.7184898",
"0.7177... | 0.0 | -1 |
Follow up: Can you solve it inplace? O(n^2) time | O(1) space | def sort_array_by_parity(nums)
nums.each_with_index do |num, i|
if i.even? && num.odd?
(i..nums.length - 1).each do |j|
nums[i], nums[j] = nums[j], nums[i] if nums[j].even?
end
elsif i.odd? && num.even?
(i..nums.length - 1).each do |j|
nums[i], nums[j] = nums[j], nums[i] if nums[j].odd?
end
end
end
nums
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_dublicate(array)\n sum = 1000000*(1000000+1)/2 # (n*(n+1))/2\n array.each do |el| \n sum -= el\n end\n return sum\nend",
"def solution(m, a)\n n = a.count\n result = 0\n front = 0\n numbers = Array.new(m + 1, false)\n n.times { |back|\n while front < n and not numbers[a[fron... | [
"0.63811857",
"0.62854993",
"0.6232834",
"0.6165759",
"0.61451924",
"0.61238",
"0.60595083",
"0.6059027",
"0.60275334",
"0.60139996",
"0.60075784",
"0.5987782",
"0.5978814",
"0.5970351",
"0.5968859",
"0.59342283",
"0.5913471",
"0.590254",
"0.5901931",
"0.5894802",
"0.5844339"... | 0.0 | -1 |
O(n) time | O(1) psace | def sort_array_by_parrity(nums)
even_misplaced = 0
odd_misplaced = 1
arr_len = nums.length
while even_misplaced < nums.length && odd_misplaced < nums.length
if nums[even_misplaced].even?
even_misplaced += 2
elsif nums[odd_misplaced].odd?
odd_misplaced += 2
else
nums[even_misplaced] , nums[odd_misplaced] = nums[odd_misplaced], nums[even_misplaced]
even_misplaced += 2
odd_misplaced += 2
end
end
nums
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_dublicate(array)\n sum = 1000000*(1000000+1)/2 # (n*(n+1))/2\n array.each do |el| \n sum -= el\n end\n return sum\nend",
"def my_min_2(list)\r\n min = 0 # O(1)\r\n \r\n list.each do |ele| # O(n) \r\n if ele < min ... | [
"0.67800605",
"0.64266706",
"0.6130893",
"0.603541",
"0.5995231",
"0.59760404",
"0.59662724",
"0.5959182",
"0.5955157",
"0.59153235",
"0.5779115",
"0.5754146",
"0.5723721",
"0.5719918",
"0.567288",
"0.56585014",
"0.5654644",
"0.5649943",
"0.562785",
"0.56263036",
"0.5622015",... | 0.0 | -1 |
Checks whether auto validations are currently disabled (see +disable_auto_validations+ method that takes a block) | def disabled_auto_validations?
@disable_auto_validations || false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def without_auto_validations\n previous, @disable_auto_validations = @disable_auto_validations, true\n yield\n ensure\n @disable_auto_validations = previous\n self\n end",
"def run_validations\n true\n end",
"def perform_validation?\n self.skip... | [
"0.72191864",
"0.70191395",
"0.677645",
"0.6667524",
"0.65297925",
"0.6347098",
"0.6329164",
"0.6315907",
"0.6284857",
"0.6218642",
"0.6195896",
"0.61859536",
"0.6157636",
"0.6151492",
"0.6151492",
"0.6143809",
"0.6104223",
"0.5998064",
"0.59955347",
"0.597162",
"0.59692377",... | 0.8485069 | 0 |
Disable generation of validations for the duration of the given block | def without_auto_validations
previous, @disable_auto_validations = @disable_auto_validations, true
yield
ensure
@disable_auto_validations = previous
self
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def eval_validation_directives_block(state, &block)\n # each validate block should be a \"fresh start\" and not interfere with the\n # previous blocks\n state.singleton_class.clear_validators!\n state.singleton_class.class_eval(&block)\n\n state.validate || invalid!(sta... | [
"0.62083584",
"0.61888754",
"0.61296207",
"0.60618997",
"0.6052558",
"0.6046336",
"0.5999179",
"0.5992014",
"0.5943124",
"0.5930466",
"0.5856872",
"0.584841",
"0.582962",
"0.5810356",
"0.5808401",
"0.5782497",
"0.57733977",
"0.57358164",
"0.570605",
"0.5702345",
"0.5702345",
... | 0.6628382 | 0 |
Pwrake version of backquote command | def pwrake_backquote(cmd)
conn = Pwrake::Shell.current
if conn.kind_of?(Pwrake::Shell)
res = conn.backquote(*cmd)
status = Rake::PseudoStatus.new(conn.status)
else
res = `#{cmd}`
status = $?
status = Rake::PseudoStatus.new(1) if status.nil?
end
[res,status]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def quote\n %q[(?:\"|')?]\n end",
"def requote(value) return restore_ends(value, '\"') end",
"def change_quotemarks!\n local_copy.in_place :perl, \"s/\\\"/'/g\"\n end",
"def shq(s) # sh(1)-style quoting\n sprintf(\"'%s'\", s.gsub(/'/, \"'\\\\\\\\''\"))\nend",
"def unquote\n\t\teach { |e| ... | [
"0.61661613",
"0.60998255",
"0.5990482",
"0.5903647",
"0.5884288",
"0.58399826",
"0.5773177",
"0.57671887",
"0.57631254",
"0.5745385",
"0.57357204",
"0.57357204",
"0.57357204",
"0.57357204",
"0.57357204",
"0.57357204",
"0.57357204",
"0.57357204",
"0.57357204",
"0.57357204",
"... | 0.74655515 | 0 |
Subject can be set in your I18n file at config/locales/en.yml with the following lookup: en.blogmailer.register.subject | def register(seller)
@seller = seller
mail(:to => seller.emailadd, :subject => "Welcome to the Car Sales site")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def translate(mapping, key)\n I18n.t(:\"#{mapping.name}_subject\", :scope => [:devise, :mailer, key],\n :default => [:subject, key.to_s.humanize])\n end",
"def subject=(string)\n set('Subject', string)\n end",
"def subject\n self['subject'] || msg['subject']\n end",
"def set_EmailSubject... | [
"0.67464787",
"0.6669763",
"0.6641568",
"0.66309553",
"0.6630084",
"0.6534335",
"0.649207",
"0.64914674",
"0.64386857",
"0.64386857",
"0.64386857",
"0.64386857",
"0.64386857",
"0.64386857",
"0.64386857",
"0.64386857",
"0.64245605",
"0.6386189",
"0.6371353",
"0.6361605",
"0.63... | 0.0 | -1 |
Use callbacks to share common setup or constraints between actions. | def set_api_key
@api_key = ApiKey.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.6165152",
"0.60463154",
"0.59467196",
"0.5917112",
"0.5890387",
"0.58345735",
"0.57773316",
"0.56991524",
"0.56991524",
"0.565454",
"0.5622282",
"0.54232633",
"0.54119074",
"0.54119074",
"0.54119074",
"0.53937256",
"0.53801376",
"0.5358599",
"0.53412294",
"0.5340814",
"0.5... | 0.0 | -1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.