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 |
|---|---|---|---|---|---|---|
The default url to be used after updating a resource. You need to overwrite this method in your own RegistrationsController. | def after_update_path_for(resource)
signed_in_root_path(resource)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def redirect_after_update\n resources_url {}\n end",
"def after_update_path_for(resource)\n edit_user_registration_path\n end",
"def after_update_path_for(resource)\n edit_user_registration_path\n end",
"def after_update_path_for(resource)\n\t\tedit_user_registration_path\n\tend",
"... | [
"0.7351943",
"0.72497755",
"0.72497755",
"0.7221928",
"0.720645",
"0.71875936",
"0.71875936",
"0.71875936",
"0.71875936",
"0.71875936",
"0.71875936",
"0.7058516",
"0.7058516",
"0.69736576",
"0.6891413",
"0.68902767",
"0.6801212",
"0.6726657",
"0.6697962",
"0.6689395",
"0.6677... | 0.0 | -1 |
Authenticates the current scope and gets the current resource from the session. | def authenticate_scope!
send(:"authenticate_#{resource_name}!", force: true)
self.resource = send(:"current_#{resource_name}")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def authenticate_scope!\n send(:\"authenticate_#{resource_name}!\")\n self.resource = resource_class.find(send(:\"current_#{resource_name}\").id)\n end",
"def authenticate_scope!\n send(:\"authenticate_#{resource_name}!\")\n self.resource = resource_class.find(send(:\"current_#{resource_na... | [
"0.74981654",
"0.74981654",
"0.7410862",
"0.7368122",
"0.7207636",
"0.7207636",
"0.7207636",
"0.7207636",
"0.7145215",
"0.6772719",
"0.6605786",
"0.65873796",
"0.65733624",
"0.65570974",
"0.6519613",
"0.6494513",
"0.64650905",
"0.6407562",
"0.6407562",
"0.6404784",
"0.640067"... | 0.7254568 | 10 |
Show invalid properties with the reasons. Usually used together with valid? | def list_invalid_properties
invalid_properties = Array.new
if @action.nil?
invalid_properties.push('invalid value for "action", action cannot be nil.')
end
if @repeat.nil?
invalid_properties.push('invalid value for "repeat", repeat cannot be nil.')
end
invalid_prope... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list_invalid_properties\n invalid_properties = super\n if @class_id.nil?\n invalid_properties.push('invalid value for \"class_id\", class_id cannot be nil.')\n end\n\n if @object_type.nil?\n invalid_properties.push('invalid value for \"object_type\", object_type cannot be nil.... | [
"0.765058",
"0.765058",
"0.765058",
"0.765058",
"0.7638772",
"0.7638772",
"0.7638772",
"0.7638772",
"0.7638772",
"0.7638772",
"0.7638772",
"0.7638772",
"0.73569804",
"0.7336038",
"0.72692806",
"0.72394663",
"0.72318745",
"0.7226795",
"0.7209003",
"0.7177062",
"0.7171715",
"... | 0.0 | -1 |
Check to see if the all the properties in the model are valid | def valid?
return false if @action.nil?
return false if @repeat.nil?
true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate_properties\n true\n end",
"def validate_properties\n true\n end",
"def validate\n super\n\n check_optional_property :collection, String\n check_optional_property :create, String\n check_optional_property :delete, String\n check_optional_property :... | [
"0.78992486",
"0.78992486",
"0.70971805",
"0.70782334",
"0.7032205",
"0.7031276",
"0.69510347",
"0.6869891",
"0.6858077",
"0.6858077",
"0.68287027",
"0.6823878",
"0.6820306",
"0.68144894",
"0.6794656",
"0.6752167",
"0.66843414",
"0.6676546",
"0.6667755",
"0.66296124",
"0.6618... | 0.0 | -1 |
Checks equality by comparing each attribute. | def ==(o)
return true if self.equal?(o)
self.class == o.class &&
action == o.action &&
attachments == o.attachments &&
attendees == o.attendees &&
description == o.description &&
duration == o.duration &&
repeat == o.repeat &&
summary == ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ==(other)\n attributes == other.attributes\n end",
"def ==(other) # :nodoc:\n @attrs == other.attrs\n end",
"def eql?(other)\n return true if self == other\n @@ATTRIBUTES.each do |att|\n return false unless self.send(att).eql?(other.send(att))\n end\n true\n en... | [
"0.7291717",
"0.7188103",
"0.70395297",
"0.7007927",
"0.68874705",
"0.6861532",
"0.6707156",
"0.6660597",
"0.66147524",
"0.658478",
"0.6584619",
"0.6580019",
"0.65543133",
"0.6543933",
"0.65068495",
"0.6479513",
"0.6456241",
"0.6415999",
"0.6412208",
"0.6412208",
"0.6412208",... | 0.0 | -1 |
Calculates hash code according to all attributes. | def hash
[action, attachments, attendees, description, duration, repeat, summary, trigger].hash
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def attr_hash\n Digest::MD5.hexdigest(\"#{@name}:#{@ruby_type}\")\n end",
"def hash() end",
"def hash() end",
"def hash() end",
"def hash() end",
"def hash() end",
"def hash() end",
"def hash() end",
"def hash\n code = 17\n code = 37*code + @x.hash\n code = 37*code + @y.hash\n ... | [
"0.7118691",
"0.70400536",
"0.70400536",
"0.70400536",
"0.70400536",
"0.70400536",
"0.70400536",
"0.70400536",
"0.68960655",
"0.67847186",
"0.6707762",
"0.670052",
"0.6688737",
"0.66705376",
"0.6489735",
"0.6462376",
"0.6462376",
"0.64444333",
"0.6413127",
"0.6395483",
"0.638... | 0.0 | -1 |
Builds the object from hash | def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
self.class.swagger_types.each_pair do |key, type|
attribute_key = self.class.attribute_map[key]
attribute_key = (attribute_key[0, 1].downcase + attribute_key[1..-1]).to_sym
if type =~ /\AArray<(.*)>/i
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build(hash)\n obj = new\n hash.each_pair do |k,v|\n obj[k] = v if variables[k]\n end\n return obj\n end",
"def build_from_hash(attributes)\n\n end",
"def build_from_hash(hash)\n instance = self.new\n\n # Add the instance attributes dynamically ... | [
"0.8011192",
"0.74710494",
"0.745837",
"0.72571075",
"0.7244619",
"0.70055205",
"0.6972621",
"0.6954448",
"0.69452715",
"0.693933",
"0.6935897",
"0.6916681",
"0.6870851",
"0.67959535",
"0.6782485",
"0.6756477",
"0.6756477",
"0.67557365",
"0.6751677",
"0.67142427",
"0.6667296"... | 0.0 | -1 |
Deserializes the data based on type | def _deserialize(type, value)
case type.to_sym
when :DateTime
DateTime.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :BOOLEAN
if value.to_s =~ /\A(true|t|yes... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _deserialize(type, value)\n case type.to_sym\n when :DateTime\n DateTime.parse(value)\n when :Date\n Date.parse(value)\n when :String\n value.to_s\n when :Integer\n value.to_i\n when :Float\n value.to_f\n when :BOOLEAN\n if value.to_s... | [
"0.7330926",
"0.7274019",
"0.72504056",
"0.7245751",
"0.72291344",
"0.72291344",
"0.72291344",
"0.72291344",
"0.72291344",
"0.72291344",
"0.72291344",
"0.72291344",
"0.72291344",
"0.72291344",
"0.72291344",
"0.72291344",
"0.72291344",
"0.72291344",
"0.72291344",
"0.72291344",
... | 0.0 | -1 |
Returns the string representation of the object | def to_s
to_hash.to_s
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_s\n @object.to_s\n end",
"def to_s\n object.to_s\n end",
"def serialize(object)\n object.to_s\n end",
"def to_s\n self.inspect\n end",
"def to_s\n @string || @object.to_s('F')\n end",
"def to_s\n @string || @object.to_s('F')\n end",
"de... | [
"0.901024",
"0.89506465",
"0.84703195",
"0.83409667",
"0.8337169",
"0.8337169",
"0.8332247",
"0.82546586",
"0.8145818",
"0.8144667",
"0.81357557",
"0.812714",
"0.8093436",
"0.8086725",
"0.8073356",
"0.8039774",
"0.80308646",
"0.80064154",
"0.80064154",
"0.80064154",
"0.800641... | 0.0 | -1 |
to_body is an alias to to_hash (backward compatibility) | def to_body
to_hash
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_body\r\n to_hash\r\n end",
"def to_body\n to_hash\nend",
"def to_body\n to_hash\nend"
] | [
"0.84283537",
"0.8347048",
"0.8347048"
] | 0.0 | -1 |
Returns the object in the form of hash | def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
next if value.nil?
hash[param] = _to_hash(value)
end
hash
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_hash\n object\n end",
"def hash\r\n return to_s.hash\r\n end",
"def hash\n to_a.hash\n end",
"def hash\n [_hash, name, owner].hash\n end",
"def hash\n return to_s.hash\n end",
"def hash\n @hash\n end",
"def hash\n @hash.hash\n end",
"def hash\n ... | [
"0.8269158",
"0.7879479",
"0.78746766",
"0.7803831",
"0.7791617",
"0.77827746",
"0.7777764",
"0.7770165",
"0.7762157",
"0.7762157",
"0.77586275",
"0.77329206",
"0.77127856",
"0.77127856",
"0.77127856",
"0.77127856",
"0.77127856",
"0.77127856",
"0.77127856",
"0.77127856",
"0.7... | 0.0 | -1 |
Outputs nonarray value in the form of hash For object, use to_hash. Otherwise, just return the value | def _to_hash(value)
if value.is_a?(Array)
value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hash\n [value].hash\n end",
"def hash\n [value].hash\n end",
"def hash\n\t\tvalue.hash\n\tend",
"def hash\n value.hash\n end",
"def hash\n @value.hash\n end",
"def hash\r\n return to_s.hash\r\n end",
"def to_hash\n @value\n end",
"def to_hash\n @va... | [
"0.67208356",
"0.67208356",
"0.6670458",
"0.6658251",
"0.65890694",
"0.64540917",
"0.64168423",
"0.64168423",
"0.63834745",
"0.6347218",
"0.6303483",
"0.6224962",
"0.6153922",
"0.61043525",
"0.6080379",
"0.6080379",
"0.607271",
"0.603735",
"0.6020807",
"0.59384143",
"0.590257... | 0.0 | -1 |
GET /heartbeats GET /heartbeats.json | def index
@heartbeats = Heartbeat.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @heartbeats }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @heart_beats = HeartBeat.all\n end",
"def show\n render json: @heartbeat\n end",
"def show\n @heartbeat = Heartbeat.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @heartbeat }\n end\n end",
"def get_heartbeats\n ... | [
"0.7511931",
"0.6779174",
"0.6749216",
"0.6321797",
"0.6292863",
"0.6237424",
"0.6233557",
"0.61642194",
"0.6153539",
"0.6063671",
"0.60364866",
"0.59836525",
"0.594041",
"0.5924661",
"0.59223926",
"0.5862464",
"0.5850641",
"0.5742875",
"0.57217294",
"0.5690941",
"0.56587386"... | 0.79452735 | 0 |
GET /heartbeats/1 GET /heartbeats/1.json | def show
@heartbeat = Heartbeat.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @heartbeat }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @heartbeats = Heartbeat.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @heartbeats }\n end\n end",
"def index\n @heart_beats = HeartBeat.all\n end",
"def show\n render json: @heartbeat\n end",
"def get_heartbeats\n Rec... | [
"0.7678846",
"0.72466946",
"0.68842596",
"0.65022284",
"0.63617367",
"0.6158657",
"0.61320883",
"0.6118239",
"0.6009443",
"0.59720826",
"0.59686863",
"0.59295446",
"0.5848068",
"0.57926166",
"0.5792602",
"0.578136",
"0.5769746",
"0.57173455",
"0.57107013",
"0.5699612",
"0.566... | 0.70229924 | 2 |
GET /heartbeats/new GET /heartbeats/new.json | def new
@heartbeat = Heartbeat.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @heartbeat }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @beat = Beat.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @beat }\n end\n end",
"def create\n @heartbeat = Heartbeat.new(params[:heartbeat])\n\n respond_to do |format|\n if @heartbeat.save\n format.html { redirect_to @hea... | [
"0.7272637",
"0.6936148",
"0.68952334",
"0.66982365",
"0.66821927",
"0.6655151",
"0.66112405",
"0.6546821",
"0.6492818",
"0.64558715",
"0.6447968",
"0.64155996",
"0.64078236",
"0.6396624",
"0.6394969",
"0.6393895",
"0.6384182",
"0.6314045",
"0.63070434",
"0.62736917",
"0.6266... | 0.77907175 | 0 |
POST /heartbeats POST /heartbeats.json | def create
@heartbeat = Heartbeat.new(params[:heartbeat])
respond_to do |format|
if @heartbeat.save
format.html { redirect_to @heartbeat, notice: 'Heartbeat was successfully created.' }
format.json { render json: @heartbeat, status: :created, location: @heartbeat }
else
form... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def alive\n @heartbeat = Heartbeat.create(heartbeats_params)\n if @heartbeat.valid?\n render json: {}, status: :created\n else\n render json: { error: 'failed to create heartbeat' }, status: :internal_server_error\n end\n end",
"def create\n @heartbeat = Heartbeat.new(hear... | [
"0.6958232",
"0.6912646",
"0.65134186",
"0.64758384",
"0.64440364",
"0.6372636",
"0.6287073",
"0.6213387",
"0.6197699",
"0.6187945",
"0.61289394",
"0.60297734",
"0.59501183",
"0.59390837",
"0.59079117",
"0.58413213",
"0.579141",
"0.57741016",
"0.5758004",
"0.56950766",
"0.569... | 0.6765585 | 2 |
PUT /heartbeats/1 PUT /heartbeats/1.json | def update
@heartbeat = Heartbeat.find(params[:id])
respond_to do |format|
if @heartbeat.update_attributes(params[:heartbeat])
format.html { redirect_to @heartbeat, notice: 'Heartbeat was successfully updated.' }
format.json { head :no_content }
else
format.html { render act... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @heartbeat = Heartbeat.find(params[:id])\n\n if @heartbeat.update(heartbeat_params)\n head :no_content\n else\n render json: @heartbeat.errors, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @heart_beat.update(heart_beat_params)\n... | [
"0.67865086",
"0.6541957",
"0.6242728",
"0.6242728",
"0.6181133",
"0.60072243",
"0.5899777",
"0.5897234",
"0.5780656",
"0.57372075",
"0.5713923",
"0.5704083",
"0.56895727",
"0.5688631",
"0.56798774",
"0.5676323",
"0.5652997",
"0.5638146",
"0.55519944",
"0.5484099",
"0.5469289... | 0.64544845 | 2 |
DELETE /heartbeats/1 DELETE /heartbeats/1.json | def destroy
@heartbeat = Heartbeat.find(params[:id])
@heartbeat.destroy
respond_to do |format|
format.html { redirect_to heartbeats_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @heart_beat.destroy\n respond_to do |format|\n format.html { redirect_to heart_beats_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @heartbeat.destroy\n\n head :no_content\n end",
"def destroy\n @hearted.destroy\n respond_to do |format|\n ... | [
"0.7675414",
"0.7251349",
"0.6893917",
"0.68327665",
"0.6829877",
"0.6743467",
"0.6726435",
"0.6646477",
"0.66232115",
"0.66232115",
"0.6596064",
"0.6574833",
"0.6530344",
"0.6443542",
"0.64309454",
"0.62750304",
"0.62739617",
"0.62703896",
"0.62701684",
"0.6240999",
"0.62399... | 0.7842111 | 0 |
Subject can be set in your I18n file at config/locales/en.yml with the following lookup: en.notifier.order_received.subject | def order_received(order)
@order = order
mail :to => "sandra_sovane@inbox.lv", :subject => 'Pragmatic Store Order Confirmation'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def message_subject=(value)\n @message_subject = value\n end",
"def subject\n self['subject'] || msg['subject']\n end",
"def subject\n @subject ||= Envelope::MessageTools.normalize(message.subject || '')\n end",
"def message_subject\n return @message_subje... | [
"0.6800689",
"0.67945725",
"0.66193247",
"0.6467936",
"0.64646465",
"0.6463497",
"0.6422386",
"0.63573945",
"0.63530016",
"0.61479187",
"0.6111878",
"0.6008901",
"0.595026",
"0.5921207",
"0.59105027",
"0.5879055",
"0.5839955",
"0.58369374",
"0.5816302",
"0.5795407",
"0.575545... | 0.5743169 | 29 |
Subject can be set in your I18n file at config/locales/en.yml with the following lookup: en.notifier.order_shipped.subject | def order_shipped
@order = order
mail :to => "sandra_sovane@inbox.lv", :subject => 'Pragmatic Store Order Shipped'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def order_notification(ship)\n @ship = ship\n mail :subject => t('mytranslations.order_notification.subject'),\n :to => Refinery::Inquiries::Setting.notification_recipients,\n :reply_to => ship.client.email\n end",
"def translate(mapping, key)\n I18n.t(:\"n... | [
"0.6710821",
"0.6340845",
"0.6214348",
"0.61685276",
"0.610235",
"0.6096921",
"0.6091533",
"0.60842127",
"0.60469395",
"0.60194784",
"0.59917605",
"0.59889793",
"0.59597987",
"0.595626",
"0.59555376",
"0.5940288",
"0.59357095",
"0.593068",
"0.59248656",
"0.5906353",
"0.590492... | 0.59147054 | 19 |
method for converting input into an index | def input_to_index(input_text)
user_input = input_text.to_i
user_input -= 1
return user_input
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def input_to_index(input)\n index = input.to_i - 1\n end",
"def input_to_index(input)\n index = input.to_i - 1\n end",
"def input_to_index(input)\n index = input.to_i - 1\n end",
"def input_to_index(user_input)\n index=(user_input .to_i) -1\nend",
"def input_to_index(user_input) \n #co... | [
"0.7487145",
"0.7487145",
"0.7487145",
"0.7451344",
"0.74293756",
"0.74141085",
"0.74085337",
"0.73864603",
"0.7358067",
"0.73324275",
"0.730765",
"0.72817945",
"0.7238189",
"0.7238189",
"0.7225225",
"0.7225225",
"0.7202509",
"0.7179698",
"0.71718866",
"0.7157185",
"0.7153394... | 0.0 | -1 |
method returns true/false based on index | def valid_move?(board_arr, index)
if index.between?(0, 8)
if board_arr[index] == "" or board_arr[index] == " " or board_arr[index] == NIL
return true
end
end
puts "invalid"
return false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def enable?(index); self.index == index; end",
"def has_index? index\n @index.include? index\n end",
"def has_index? index\n @index.include? index\n end",
"def index?\n true\n end",
"def index_valid?(index)\n index > -1 && index != length ? true : false\n end",
"def includ... | [
"0.7796415",
"0.7555843",
"0.7555843",
"0.7471939",
"0.7447597",
"0.74435395",
"0.73727673",
"0.7296839",
"0.72059846",
"0.72059846",
"0.7088272",
"0.7082087",
"0.7064204",
"0.70628333",
"0.7046051",
"0.6956422",
"0.6955822",
"0.6926004",
"0.68981075",
"0.68938947",
"0.685939... | 0.0 | -1 |
Returns the HTML for a sublist of the sitemap (an unsorted list with clickable node titles) up to a specified number of submenu levels. arguments +item+ The content node to create an unsorted list for. +levels+ The maximum of sublists. | def create_subitem(item, levels)
@current_level ||= 0
subitems = item.node.children.accessible.public.shown_in_menu.include_content.order(:position).all.map { |n| n.content }
if item.node.leaf? || subitems.empty? || @current_level == levels
@current_level = 0 if @current_level == levels
conten... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_items(item, limit, index, hierarchical = false, root_path = \"\")\n return \"\" if index > limit || !item.children.present?\n\n html = \"<ul class='#{index == 1 ? \"menu\" : \"sub-menu\"}'>\"\n item.children.order_default.each do |i|\n if i.visible && i.active\n ... | [
"0.6414822",
"0.59429574",
"0.5788237",
"0.55942804",
"0.55320394",
"0.5193488",
"0.51562625",
"0.513643",
"0.5130661",
"0.510976",
"0.49862352",
"0.4950537",
"0.4905398",
"0.48753336",
"0.4870776",
"0.4865183",
"0.48480874",
"0.48325905",
"0.48297837",
"0.48096552",
"0.47922... | 0.77893 | 0 |
Get the input from user input | def start
puts 'Enter size of matrix'
grid_size = gets.to_i
fail 'Grid size should be < 100 ' if grid_size > 100
# position of bot
puts 'Enter the position of bot(m) separated by space Ex: 0 2'
bot_pos_x, bot_pos_y = gets.strip.split.map(&:to_i)
# Get matrix rows from user input
puts 'Specify matrix r... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def user_input\n\tgets\nend",
"def get_input\n @input = gets.strip\n end",
"def get_input\n input = gets\n return input\nend",
"def get_input\n gets.chomp\n end",
"def get_input(*msg)\n print *msg\n return gets.strip\n end",
"def get_input\n @input = gets.chomp\n end",
... | [
"0.83598006",
"0.82188255",
"0.8194689",
"0.8076257",
"0.8055432",
"0.8031101",
"0.80216414",
"0.79102564",
"0.78491485",
"0.78305614",
"0.78255945",
"0.7813109",
"0.7813109",
"0.7812008",
"0.77891475",
"0.7775199",
"0.7749966",
"0.77125245",
"0.7711839",
"0.7694568",
"0.7663... | 0.0 | -1 |
Find princess position from user input matrix rows | def get_princess_position(grid_size)
princess_position = nil
grid = Array.new(grid_size)
(0...grid_size).each do |i|
grid_row = gets.split
princess_position = [i, grid_row.index('p')] if grid_row.include? 'p'
grid[i] = grid_row
end
princess_position
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def coord_to_pos(row,col)\n return nil if row.even? && col.even? || row.odd? && col.odd? #these are always empty squares in checkers!\n return row*4+(col/2).floor+1\n end",
"def index_of_position(row, col = 0)\n\t\tline_index(row) + col + 1\n\tend",
"def find_position(grid, p_m)\n grid.each_with_inde... | [
"0.6720672",
"0.66320103",
"0.6605307",
"0.6501545",
"0.6490829",
"0.64302444",
"0.6409341",
"0.6399118",
"0.6368346",
"0.6364975",
"0.63617074",
"0.63615274",
"0.63504744",
"0.6343769",
"0.62726504",
"0.6261159",
"0.6261159",
"0.62548846",
"0.623341",
"0.6205515",
"0.6203198... | 0.72393626 | 0 |
Find the next move the bot makes to rescue the princess. | def next_move(bot_pos_x, bot_pos_y, princess_position)
case
when princess_position[0] - bot_pos_x < 0 then move = 'UP'
when princess_position[0] - bot_pos_x > 0 then move = 'DOWN'
when princess_position[1] - bot_pos_y < 0 then move = 'LEFT'
when princess_position[1] - bot_pos_y > 0 then move = 'RIGHT'
end
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def next_move\n\t\tif @next_move.nil?\n\t\t\t@next_move = determine_next_move\n\t\tend\n\n\t\t@next_move\n\tend",
"def read_next_move\n\t\t\t\tms = read_acpc_matchstate\n\t\t\t\treturn ms[:last_action]\n\t\t\tend",
"def get_next_move\n\t\t\t\tif player_to_act.respond_to?(:get_move)\n\t\t\t\t\t# get the move, w... | [
"0.73405904",
"0.71620786",
"0.7159389",
"0.699724",
"0.69579464",
"0.6948939",
"0.6870679",
"0.6718187",
"0.6711911",
"0.670474",
"0.6628625",
"0.660363",
"0.6595676",
"0.6588735",
"0.6576318",
"0.657171",
"0.6542592",
"0.65393806",
"0.653315",
"0.651404",
"0.6513571",
"0.... | 0.63437057 | 33 |
This method is used in .slim files. Processes a markdown file, including nesting other md files and creating a tags list from the metadata of the included files returns an array: [result_html, tags] | def process_md_erb(filename)
renderer = Redcarpet::Render::HTML
markdown ||= Redcarpet::Markdown.new(renderer, md_extensions)
concatenated_md = embed_md_erb(filename)
result_md, metadata = extract_metadata(concatenated_md)
result_html = markdown.render(result_md)
[result_html, metadata]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def process_markdown\n attachments.each do |att|\n # ~ magic regex ~\n self.markdown = self.markdown.sub(/\\[.+?\\]\\(.+?\\/#{att.file.id}\\/.+?\\)/) do |md_str|\n att.file_attacher.store!\n \"[#{att.file_filename}](#{att.file_url})\"\n end\n end\n self.html = Kramdown::Docume... | [
"0.6584569",
"0.6494559",
"0.6293909",
"0.62119746",
"0.6135725",
"0.60691196",
"0.60310566",
"0.59942216",
"0.5956463",
"0.5938883",
"0.5909148",
"0.5873861",
"0.57966214",
"0.5790085",
"0.578459",
"0.57412416",
"0.5727431",
"0.57046556",
"0.56719977",
"0.5671853",
"0.566561... | 0.7105307 | 0 |
In .md.erb files, metadata is stored in a custom format: It looks like: METADATA The content of the block has keyval pairs separated by newlines Accepted keyval pairs are: TAGS: This method finds all metadata in a concatenated markdown string and removes it from the result. Returns an Array: [result md, metadata hash] | def extract_metadata(markdown_string)
metadata_results = OpenStruct.new
return markdown_string unless markdown_string.include? "**METADATA**"
result = markdown_string.split("**METADATA**").map do |section|
metadata, content = section.split("****")
parse_metadata_section(section).each do |key,res... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def extract_metadata\n YAML_METADATA.match(content) do |match|\n @metadata = YAML.load(match[0])\n @content = content.gsub(YAML_METADATA, \"\")\n end\n end",
"def process_md_erb(filename)\n renderer = Redcarpet::Render::HTML\n markdown ||= Redcarpet::Markdown.new(renderer, md_ext... | [
"0.6789341",
"0.6440488",
"0.61502534",
"0.6017993",
"0.5928651",
"0.5889146",
"0.58474535",
"0.5843077",
"0.57650805",
"0.57554",
"0.573926",
"0.5713302",
"0.56963176",
"0.5654637",
"0.5628647",
"0.55616385",
"0.55475855",
"0.55433655",
"0.5529663",
"0.5503852",
"0.5475491",... | 0.7501597 | 0 |
Get results of parsing a single metadata section Returns a hash | def parse_metadata_section(metadata_string)
metadata_string.split("\n").reduce({}) do |result, line|
key, val = line.split(": ")
if [key, val].none? { |str| str.blank? }
result[key.strip.downcase.to_sym] = val.strip.split(", ")
end
result
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def extract_metadata; end",
"def aws_get_metadata\n murl = 'http://169.254.169.254/latest/meta-data/'\n result = self.aws_get_url(murl)\n metadata = Hash.new()\n\n # TODO this isn't entirely right.. if the element ends in '/', it's actually another level of hash..\n result.split(\"\\n\").each do... | [
"0.68426186",
"0.683919",
"0.6795711",
"0.6795711",
"0.67125195",
"0.66991884",
"0.6635327",
"0.66267294",
"0.66212165",
"0.6597764",
"0.65353304",
"0.6511194",
"0.6503749",
"0.6473436",
"0.6381361",
"0.6379911",
"0.6377388",
"0.636003",
"0.63443315",
"0.6333173",
"0.63248307... | 0.6635717 | 6 |
Extensions to Redcarpet's markdown renderer | def md_extensions
# empty for now
{}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def markdown(text) # Define method markdown with redcarpet gem\n\t\tRedcarpet::Markdown.new(Redcarpet::Render::HTML).render(text)\n end",
"def markdown\n markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML)\n end",
"def html_markup_markdown(text); end",
"def mdrender\n \t@markdown = Redcarpe... | [
"0.81267416",
"0.8101759",
"0.80778104",
"0.80389714",
"0.79952765",
"0.7814983",
"0.7721974",
"0.77175796",
"0.771666",
"0.77165115",
"0.7710892",
"0.7710892",
"0.7708709",
"0.77014035",
"0.769753",
"0.76561254",
"0.7646463",
"0.76455903",
"0.7639899",
"0.7627906",
"0.761546... | 0.0 | -1 |
Embed a markdown file in another markdown file Concatenates markdown. Doesn't convert to html. | def embed_md_erb(filename) # => markdown string
ERB.new(File.read(filename)).result(binding)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_markdown\n files = Dir.glob('**/*.html')\n files.each do |f|\n new_f = f.gsub 'html', 'markdown'\n system \"mv #{f} #{new_f}\" if File.file? f\n end\n end",
"def render_markdown(file)\n renderer = PygmentizeHTML\n extensions = {:autolink => true, :hard_wrap => true, :space_after_... | [
"0.64110047",
"0.61663574",
"0.61309576",
"0.60383177",
"0.602433",
"0.5994981",
"0.5969158",
"0.5955647",
"0.5946289",
"0.59067684",
"0.58571017",
"0.58539855",
"0.58489794",
"0.5847564",
"0.5843688",
"0.5843653",
"0.58358675",
"0.58303547",
"0.58190703",
"0.5738081",
"0.573... | 0.6912467 | 0 |
A list of .md.erb file paths Ignores readme and license | def md_erb_files
Dir.glob("**/*.md.erb").reject do |path|
["license", "readme"].any? do |str|
path.downcase.ends_with? "#{str}.md.erb"
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list\n\t\tfiles.map! { |filename|\n\t\t\t{:title => file_to_pagename(filename), :link => filename.chomp(\".md\")}\n\t\t}\n\tend",
"def list\n\t\tfiles.map! { |filename|\n\t\t\t{:title => file_to_pagename(filename), :link => filename.chomp(\".md\")}\n\t\t}\n\tend",
"def erb_path\n \"#{File.dirname(__... | [
"0.7057528",
"0.7057528",
"0.68402666",
"0.6676598",
"0.6528362",
"0.6495087",
"0.6491898",
"0.6486261",
"0.63012654",
"0.6300635",
"0.6262226",
"0.62137765",
"0.61862236",
"0.6184075",
"0.61706054",
"0.6164567",
"0.6157253",
"0.61545193",
"0.6151136",
"0.6150876",
"0.6137231... | 0.756004 | 0 |
Transform /my/path/name.txt into 'name' | def file_title(path)
filename_from_path(path).split(".")[0]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_name_from_file_name(file)\n file.sub!('/', '').sub!('.jpg', '').gsub!(/[-_]/, ' ').split.map(&:capitalize).join ' '\n end",
"def file_to_name(file)\n return file.split(\"_\").map(&:capitalize).join\n end",
"def file_name(name)\n name.to_s.gsub(/-/, \"_\").underscore\n end",
"d... | [
"0.6706654",
"0.6523925",
"0.6345981",
"0.62749",
"0.62706864",
"0.6213187",
"0.6210752",
"0.62034154",
"0.61876065",
"0.6168698",
"0.6168698",
"0.6151321",
"0.6125011",
"0.6112734",
"0.6105802",
"0.60909456",
"0.6074677",
"0.6055076",
"0.60114884",
"0.5935425",
"0.5928453",
... | 0.0 | -1 |
Runs a specified shell command in a separate thread. If it exceeds the given timeout in seconds, kills it. Returns any output produced by the command (stdout or stderr) as a String. Uses Kernel.select to wait up to the tick length (in seconds) between checks on the command's status If you've got a cleaner way of doing ... | def run_with_timeout(command, timeout, tick)
output = ''
begin
# Start task in another thread, which spawns a process
stdin, stderrout, thread = Open3.popen2e(command)
# Get the pid of the spawned process
pid = thread[:pid]
start = Time.now
while (Time.now - start) < timeout and thread.aliv... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run_with_timeout(command, timeout, tick)\n output = ''\n begin\n # Start task in another thread, which spawns a process\n stdin, stderrout, thread = Open3.popen2e(command)\n # Get the pid of the spawned process\n pid = thread[:pid]\n start = Time.now\n\n while (Time.now - st... | [
"0.81469893",
"0.7946549",
"0.78772396",
"0.7831198",
"0.77707744",
"0.7172078",
"0.71152586",
"0.69348264",
"0.6767639",
"0.63780695",
"0.6231993",
"0.6161322",
"0.61484355",
"0.6127456",
"0.60837674",
"0.6047761",
"0.60357475",
"0.6031448",
"0.59493357",
"0.59354496",
"0.58... | 0.8100713 | 1 |
It is required by google FullCalender js | def allDay
FALSE
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def service\n Googlecal::Base.service\n end",
"def g_cal\n @g_cal ||= Google::Calendar.new(\n :client_id => @client_id,\n :client_secret => @secret,\n :calendar => @calendar_id,\n :redirect_url => \"urn:ietf:wg:oauth:2.0:oob\" # this is what Google uses for 'app... | [
"0.66656655",
"0.6306662",
"0.6242163",
"0.6164427",
"0.61604214",
"0.616021",
"0.5997413",
"0.5956652",
"0.5947041",
"0.5947041",
"0.5920075",
"0.5916335",
"0.58496094",
"0.58265",
"0.5808734",
"0.5753126",
"0.5717849",
"0.56975996",
"0.5679915",
"0.56746125",
"0.56701356",
... | 0.0 | -1 |
== Class Methods ==================================================== == Instance Methods ================================================= Server Instance Methods | def receive_line(line)
arguments = line.split(/\s+/)
command = arguments.shift
if (!command or command.empty?)
reply_with_error
else
command_sym = :"#{command.downcase}_command"
if (respond_to?(command_sym))
send(command_sym, *arguments)... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def server; end",
"def server; end",
"def server; end",
"def server; end",
"def server; end",
"def server; end",
"def server; end",
"def server; end",
"def server\n self\n end",
"def server\n super\n end",
"def server\n super\n end",
"def server\n\t\treturn @server... | [
"0.77852726",
"0.77852726",
"0.77852726",
"0.77852726",
"0.77852726",
"0.77852726",
"0.77852726",
"0.77852726",
"0.7355302",
"0.73002726",
"0.73002726",
"0.7191093",
"0.70575774",
"0.69718635",
"0.6856856",
"0.6856856",
"0.6794205",
"0.6794205",
"0.67753464",
"0.67133224",
"0... | 0.0 | -1 |
This is necessary since Rails 3.0.4 See and | def handle_unverified_request
true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def private; end",
"def probers; end",
"def extra; end",
"def refutal()\n end",
"def custom; end",
"def custom; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def view_flow; end",
"def rails_3\n defined?(ActiveRecord::VERSION) && ActiveRecord::VERSION::... | [
"0.7121049",
"0.58587027",
"0.58177334",
"0.5817659",
"0.5698671",
"0.5698671",
"0.5684884",
"0.5684884",
"0.5684884",
"0.5684884",
"0.56329834",
"0.5577374",
"0.55254394",
"0.5512003",
"0.55052704",
"0.5503234",
"0.54796845",
"0.54687154",
"0.54683936",
"0.545734",
"0.545734... | 0.0 | -1 |
+each_child+ iterates over each child. | def each_child(&block) # :yields: child_node
children.each(&block)
nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def each_child\n @children.each { |child| yield child }\n end",
"def each_child\n @children.each { |child| yield child }\n end",
"def each_child\n @children.each_pair { |_, child| yield child }\n end",
"def each_child(&_block)\n @children.each { |child| yield child }\n end",
"def ea... | [
"0.83317053",
"0.83268374",
"0.81140023",
"0.80316937",
"0.7905068",
"0.7903883",
"0.788483",
"0.75929475",
"0.7458274",
"0.74274695",
"0.72852683",
"0.72834605",
"0.7254624",
"0.7145825",
"0.7081104",
"0.7064256",
"0.6837179",
"0.67730933",
"0.6771015",
"0.67336655",
"0.6684... | 0.8106261 | 3 |
+each_child_with_index+ iterates over each child. | def each_child_with_index(&block) # :yields: child_node, index
children.each_with_index(&block)
nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def each_child_with_index\n end",
"def each_child_index\n end",
"def each_with_index(&block)\n @tree.each_with_index(&block)\n end",
"def child(index)\n @children[index]\n end",
"def get_child(index)\n @children[index]\n end",
"def get_child(index)\n \t@children[index]\n ... | [
"0.82137316",
"0.7930641",
"0.73494834",
"0.706672",
"0.70498025",
"0.70198655",
"0.6961662",
"0.67976767",
"0.6777808",
"0.6738946",
"0.6671282",
"0.6645055",
"0.6573938",
"0.6547132",
"0.65461504",
"0.6528009",
"0.6524863",
"0.65145725",
"0.64962417",
"0.64926803",
"0.64828... | 0.8773223 | 1 |
+find_element+ searches an element which universal name is specified by the arguments. It returns nil if not found. | def find_element(*names)
traverse_element(*names) {|e| return e }
nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_name name\n find_element :name, name\n end",
"def find_element(*args)\n sleep 0.1\n how, what, timeout = extract_args(args)\n by = Selenium::WebDriver::SearchContext::FINDERS[how.to_sym]\n wait = Object::Selenium::WebDriver::Wait.new({:timeout => timeout, :message => \"element no... | [
"0.71347195",
"0.7113149",
"0.6979475",
"0.686167",
"0.6686384",
"0.66583276",
"0.6535173",
"0.6529971",
"0.65133566",
"0.6501438",
"0.6477793",
"0.6443796",
"0.6404845",
"0.6374332",
"0.6307289",
"0.62016606",
"0.61916465",
"0.6083959",
"0.6042386",
"0.6016829",
"0.59899044"... | 0.7357559 | 1 |
+each_hyperlink_uri+ traverses hyperlinks such as HTML href attribute of A element. It yields Hpricot::Text (or Hpricot::Loc) and URI for each hyperlink. The URI objects are created with a base URI which is given by HTML BASE element or the argument ((|base_uri|)). +each_hyperlink_uri+ doesn't yields href of the BASE e... | def each_hyperlink_uri(base_uri=nil) # :yields: hyperlink, uri
base_uri = URI.parse(base_uri) if String === base_uri
links = []
each_hyperlink_attribute {|elem, attr, hyperlink|
if %r{\{http://www.w3.org/1999/xhtml\}(?:base)\z}i =~ elem.name
base_uri = URI.parse(hyperlink.to_s)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def each_uri(base_uri=nil) # :yields: URI\n each_hyperlink_uri(base_uri) {|hyperlink, uri| yield uri }\n end",
"def each_uri(base_uri=nil) # :yields: URI\n each_hyperlink_uri(base_uri) {|hyperlink, uri| yield uri }\n end",
"def each_hyperlink # :yields: text\n links = []\n each_hyperl... | [
"0.80388737",
"0.80388737",
"0.68152297",
"0.6563176",
"0.61115044",
"0.59787226",
"0.5922701",
"0.56546956",
"0.55441445",
"0.54774034",
"0.54203355",
"0.5384993",
"0.5340982",
"0.53149194",
"0.5239278",
"0.52178496",
"0.51959705",
"0.51754093",
"0.51732105",
"0.5149983",
"0... | 0.83022004 | 1 |
+each_hyperlink+ traverses hyperlinks such as HTML href attribute of A element. It yields Hpricot::Text or Hpricot::Loc. Note that +each_hyperlink+ yields HTML href attribute of BASE element. | def each_hyperlink # :yields: text
links = []
each_hyperlink_attribute {|elem, attr, hyperlink|
yield hyperlink
}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def each_hyperlink # :yields: text\n each_hyperlink_attribute {|elem, attr, hyperlink|\n yield hyperlink\n }\n end",
"def each_hyperlink_uri(base_uri=nil) # :yields: hyperlink, uri\n base_uri = URI.parse(base_uri) if String === base_uri\n links = []\n each_hyperlink_attribute {... | [
"0.77974546",
"0.6900931",
"0.6900931",
"0.6458919",
"0.645232",
"0.645232",
"0.6238984",
"0.6070783",
"0.5955524",
"0.5760612",
"0.57457316",
"0.5647629",
"0.5582062",
"0.55414397",
"0.553746",
"0.55043495",
"0.55015755",
"0.5463523",
"0.5451055",
"0.5444632",
"0.54409724",
... | 0.7916504 | 0 |
+each_uri+ traverses hyperlinks such as HTML href attribute of A element. It yields URI for each hyperlink. The URI objects are created with a base URI which is given by HTML BASE element or the argument ((|base_uri|)). | def each_uri(base_uri=nil) # :yields: URI
each_hyperlink_uri(base_uri) {|hyperlink, uri| yield uri }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def each_hyperlink_uri(base_uri=nil) # :yields: hyperlink, uri\n base_uri = URI.parse(base_uri) if String === base_uri\n links = []\n each_hyperlink_attribute {|elem, attr, hyperlink|\n if %r{\\{http://www.w3.org/1999/xhtml\\}(?:base)\\z}i =~ elem.name\n base_uri = URI.parse(hyperlin... | [
"0.8447926",
"0.8447926",
"0.6748913",
"0.67058986",
"0.6264313",
"0.6128267",
"0.60414875",
"0.5970319",
"0.5841095",
"0.5840394",
"0.5712688",
"0.56757635",
"0.56583065",
"0.5569994",
"0.556946",
"0.5550127",
"0.55427045",
"0.55214435",
"0.54943734",
"0.5464179",
"0.5443334... | 0.88244975 | 1 |
+author+ searches author and return it as a text. It returns nil if not found. +author+ searchs following information. in HTML in HTML authorname in RSS authorname in RSS | def author
traverse_element('meta',
'{http://www.w3.org/1999/xhtml}meta') {|e|
begin
next unless e.fetch_attr('name').downcase == 'author'
author = e.fetch_attribute('content').strip
return author if !author.empty?
rescue IndexError
end
}
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def author\n traverse_element('meta',\n '{http://www.w3.org/1999/xhtml}meta') {|e|\n begin\n next unless e.fetch_attr('name').downcase == 'author'\n author = e.fetch_attribute('content').strip\n return author if !author.empty?\n rescue IndexError\n end\n ... | [
"0.7628827",
"0.7618069",
"0.737916",
"0.7331381",
"0.7310339",
"0.73037755",
"0.72365296",
"0.71748424",
"0.7109011",
"0.7036566",
"0.7010603",
"0.6967935",
"0.6964151",
"0.69358504",
"0.6879695",
"0.6864359",
"0.6818832",
"0.68099236",
"0.6806723",
"0.6770926",
"0.67676795"... | 0.78793484 | 0 |
If the steps list is changed, this method will probably no longer be valid. | def send_to_correct_step
if Member::States.include? step
original_state = @member.state
set_state previous_step
if !@member.valid?
member_step = wizard_steps.index(original_state) || 0
jump_to wizard_steps[member_step.next]
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def valid_steps\n @valid_steps ||= self.steps\n end",
"def steps=(new_value)\n @steps = new_value\n end",
"def valid_steps= valid_steps\n unless valid_steps.nil?\n valid_steps = valid_steps.collect {|s| s.to_sym}\n valid_steps = steps.select {|s| valid_steps.include? s}\n ... | [
"0.70787966",
"0.69534796",
"0.6756621",
"0.6710165",
"0.6421414",
"0.6409363",
"0.6273505",
"0.60578233",
"0.60547745",
"0.6027131",
"0.60084236",
"0.59220606",
"0.59220606",
"0.58423513",
"0.5835021",
"0.58194196",
"0.574197",
"0.57391196",
"0.5729767",
"0.57267",
"0.571848... | 0.56465715 | 27 |
Depending on record type, the address can be nil or an array containing different address parts. | def decompose_address(parts)
addresses = parts || []
address, city, zip, country_code = nil, nil, nil, nil
if !addresses.empty?
address = addresses[0] if addresses[0]
zip, city = addresses[1].split(" ", 2) if addresses[1]
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def address_as_string(type)\n ad = address(type)\n begin\n ad.nil? ? nil : \"#{ad.country.name}, #{ad.city.name}, #{ad.street1}, #{ad.street2}\"\n rescue\n \"sorry, bad address\"\n end\n end",
"def address\n unless addresses.empty?\n addresses.first\n else\n nil\n ... | [
"0.65583926",
"0.65539306",
"0.647403",
"0.63811654",
"0.6258254",
"0.62276167",
"0.6187602",
"0.6187602",
"0.6161641",
"0.6125532",
"0.6121623",
"0.60956407",
"0.6089826",
"0.60646635",
"0.6062472",
"0.6053029",
"0.6043283",
"0.60272133",
"0.60201013",
"0.601169",
"0.5916684... | 0.0 | -1 |
FIXME: Requires UTF8 Encoding (see 11) | def parse_moreinfo
if @input.match?(/Tov.* ld\.:\n/)
p("whois.nic.hu: parse_moreinfo") if 1 == 2 || $DEBUG
@ast["moreinfo"] = @input.scan_until(/^\n/)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def encodings; end",
"def encoding; end",
"def encoding; end",
"def encoding; end",
"def encoding; end",
"def encoding; end",
"def encoding; end",
"def encoding; end",
"def encoding; end",
"def encoding; end",
"def encoding; end",
"def encoding; end",
"def encoding; end",
"def encoding; e... | [
"0.70922756",
"0.7077035",
"0.7077035",
"0.7077035",
"0.7077035",
"0.7077035",
"0.7077035",
"0.7077035",
"0.7077035",
"0.7077035",
"0.7077035",
"0.7077035",
"0.7077035",
"0.7077035",
"0.7077035",
"0.7077035",
"0.6784962",
"0.6755033",
"0.6662436",
"0.6662436",
"0.66331244",
... | 0.0 | -1 |
FIXME: Requires UTF8 Encoding (see 11) | def parse_not_found
if @input.match?(/Nincs (.*?) \/ No match\n/)
p("whois.nic.hu: parse_not_found") if 1 == 2 || $DEBUG
@input.scan(/Nincs (.*?) \/ No match\n/)
return @ast['NotFound'] = true
end
@ast['NotFound'] = false
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def encodings; end",
"def encoding; end",
"def encoding; end",
"def encoding; end",
"def encoding; end",
"def encoding; end",
"def encoding; end",
"def encoding; end",
"def encoding; end",
"def encoding; end",
"def encoding; end",
"def encoding; end",
"def encoding; end",
"def encoding; e... | [
"0.7091389",
"0.7075765",
"0.7075765",
"0.7075765",
"0.7075765",
"0.7075765",
"0.7075765",
"0.7075765",
"0.7075765",
"0.7075765",
"0.7075765",
"0.7075765",
"0.7075765",
"0.7075765",
"0.7075765",
"0.7075765",
"0.6783546",
"0.6753659",
"0.66605264",
"0.66605264",
"0.66308355",
... | 0.0 | -1 |
FIXME: Requires UTF8 Encoding (see 11) | def parse_in_progress
if @input.match?(/(.*?) folyamatban \/ Registration in progress\n/)
p("whois.nic.hu: parse_in_progress") if 1 == 2 || $DEBUG
@input.scan(/(.*?) folyamatban \/ Registration in progress\n/)
return @ast['InProgress'] = true
e... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def encodings; end",
"def encoding; end",
"def encoding; end",
"def encoding; end",
"def encoding; end",
"def encoding; end",
"def encoding; end",
"def encoding; end",
"def encoding; end",
"def encoding; end",
"def encoding; end",
"def encoding; end",
"def encoding; end",
"def encoding; e... | [
"0.7091389",
"0.7075765",
"0.7075765",
"0.7075765",
"0.7075765",
"0.7075765",
"0.7075765",
"0.7075765",
"0.7075765",
"0.7075765",
"0.7075765",
"0.7075765",
"0.7075765",
"0.7075765",
"0.7075765",
"0.7075765",
"0.6783546",
"0.6753659",
"0.66605264",
"0.66605264",
"0.66308355",
... | 0.0 | -1 |
Use callbacks to share common setup or constraints between actions. | def set_user
@user = User.find(session[:user_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 user_params
params.require(:user).permit(:username, :email, :myprofileurl)
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 |
before_action :set_child, only: [:show, :edit, :update, :destroy] | def update_attributes(hash)
hash.keys.each do |key|
m = "#{key}="
Child.send(m, hash[key]) if Child.respond_to?(m)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_child\n @child = Child.find(params[:id])\n end",
"def set_child\n @child = Child.find(params[:id])\n end",
"def set_child\n @child = Child.find(params[:id])\n end",
"def set_child\n @child = Child.find(params[:id])\n end",
"def set_child\n @child = Child.find(params... | [
"0.7531524",
"0.73038155",
"0.73038155",
"0.73038155",
"0.73038155",
"0.73038155",
"0.73038155",
"0.73038155",
"0.73038155",
"0.73038155",
"0.73038155",
"0.7189979",
"0.6919538",
"0.6531595",
"0.6493758",
"0.64724576",
"0.6402979",
"0.63683087",
"0.62908024",
"0.62908024",
"0... | 0.0 | -1 |
GET /children GET /children.json | def index
children = []
base_uri = 'https://postjson-d117c.firebaseio.com/'
@firebase = Firebase::Client.new(base_uri)
childrenjs = @firebase.get("Child")
parsed = JSON.parse(childrenjs.raw_body)
kids = parsed.deep_symbolize_keys
kids.uniq.each do |key, value|
value.each do |key2, val... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def children\n @pages = @page.children\n \n respond_to do |format|\n format.json { render :json => @pages }\n format.xml { render :xml => @pages }\n end\n end",
"def children\n render json: { status: 'ok', content: [] }\n end",
"def children\n @resource.children\n end... | [
"0.80130404",
"0.7882042",
"0.7781168",
"0.7538884",
"0.7376999",
"0.73671556",
"0.7354207",
"0.73513156",
"0.7289584",
"0.72810805",
"0.72810805",
"0.7223111",
"0.7223111",
"0.7223111",
"0.7223111",
"0.7161739",
"0.71592",
"0.7154487",
"0.7149481",
"0.7119744",
"0.7077208",
... | 0.6708626 | 39 |
GET /children/1 GET /children/1.json | def show
children = []
base_uri = 'https://postjson-d117c.firebaseio.com/'
@firebase = Firebase::Client.new(base_uri)
childrenjs = @firebase.get("Child")
parsed = JSON.parse(childrenjs.raw_body)
kids = parsed.deep_symbolize_keys
kids.uniq.each do |key, value|
value.each do |key2, valu... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def children\n @pages = @page.children\n \n respond_to do |format|\n format.json { render :json => @pages }\n format.xml { render :xml => @pages }\n end\n end",
"def children\n @id = fix_id(params[:id], params[:format], params[:extra])\n if params[:root]==\"source\" then\n @isRo... | [
"0.7499588",
"0.7324712",
"0.72646785",
"0.71289086",
"0.70389336",
"0.7035334",
"0.69792575",
"0.6978602",
"0.6978602",
"0.6977394",
"0.6936022",
"0.6908084",
"0.68532836",
"0.6773779",
"0.6773779",
"0.6773779",
"0.6773779",
"0.6759537",
"0.66919076",
"0.66919076",
"0.667522... | 0.6175378 | 62 |
POST /children POST /children.json | def create
@child = Child.new(child_params)
base_uri = 'https://postjson-d117c.firebaseio.com/'
@firebase = Firebase::Client.new(base_uri)
kid = []
child_params.each do |k,v|
kid << k
kid<< v
end
# render :json => kid
response = @firebase.push("Child", ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_post!(params)\n @children.create! params\n end",
"def create\n @children = Children.new(params[:children])\n\n respond_to do |format|\n if @children.save\n flash[:notice] = 'Children was successfully created.'\n format.html { redirect_to(@children) }\n format.xml {... | [
"0.7426617",
"0.73090565",
"0.685491",
"0.6664779",
"0.6652258",
"0.65630364",
"0.6543847",
"0.651399",
"0.6508057",
"0.6461266",
"0.6390719",
"0.6346286",
"0.62191105",
"0.61931896",
"0.6185605",
"0.61737835",
"0.6164681",
"0.6148178",
"0.613725",
"0.61069894",
"0.6087279",
... | 0.5761691 | 61 |
POST /children/android POST /children/android.json | def android
#skip_before_action :verify_authenticity_token
print "\n----------------------\n"
data_json = JSON.parse(request.raw_post)
print data_json
print "\n----------------------\n"
data_json = JSON.parse(request.raw_post)
@child = Child.new(data_json)
if @child.glucose < 4
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_post!(params)\n @children.create! params\n end",
"def create\n @child = Child.new(child_params)\n base_uri = 'https://postjson-d117c.firebaseio.com/'\n @firebase = Firebase::Client.new(base_uri)\n kid = []\n child_params.each do |k,v|\n kid << k\n kid<< v\n \n ... | [
"0.61876756",
"0.61232656",
"0.59076315",
"0.5800263",
"0.57623804",
"0.56646115",
"0.56434715",
"0.55546004",
"0.55292016",
"0.5500024",
"0.5483911",
"0.54587495",
"0.5443823",
"0.5340869",
"0.53280234",
"0.53124446",
"0.5302902",
"0.52970505",
"0.52618855",
"0.5249299",
"0.... | 0.5638051 | 7 |
PATCH/PUT /children/1 PATCH/PUT /children/1.json | def update
respond_to do |format|
if @child.update(child_params)
format.html { redirect_to @child, notice: 'Child was successfully updated.' }
format.json { render :show, status: :ok, location: @child }
else
format.html { render :edit }
format.json { render json: @child.e... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @children = Children.find(params[:id])\n\n respond_to do |format|\n if @children.update_attributes(params[:children])\n flash[:notice] = 'Children was successfully updated.'\n format.html { redirect_to(@children) }\n format.xml { head :ok }\n else\n format.... | [
"0.7087602",
"0.6747008",
"0.65239745",
"0.6425298",
"0.64243084",
"0.64243084",
"0.64243084",
"0.6372172",
"0.6325486",
"0.6317983",
"0.62796867",
"0.6267304",
"0.62311465",
"0.62205744",
"0.60959387",
"0.6091433",
"0.6057536",
"0.6040286",
"0.6024075",
"0.6024075",
"0.60240... | 0.64609504 | 4 |
DELETE /children/1 DELETE /children/1.json | def destroy
@child.destroy
respond_to do |format|
format.html { redirect_to children_url, notice: 'Child was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @children = Children.find(params[:id])\n @children.destroy\n\n respond_to do |format|\n format.html { redirect_to(childrens_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @child.destroy\n respond_to do |format|\n format.html { redirect_to children_u... | [
"0.7690423",
"0.7553778",
"0.754166",
"0.7339654",
"0.7039886",
"0.7039886",
"0.68095887",
"0.67939544",
"0.6781426",
"0.6747409",
"0.67131644",
"0.67131644",
"0.6713039",
"0.6677913",
"0.667762",
"0.667456",
"0.66403186",
"0.6628512",
"0.6609712",
"0.660891",
"0.66086495",
... | 0.70389456 | 6 |
Use callbacks to share common setup or constraints between actions. | def set_child
@child = Child.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 child_params
params.require(:child).permit(:id, :age, :name)
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 |
Messages to petition office share recipient, replyto and from. | def assert_default_office_mail_attributes(mail)
assert_equal ["#{@petition.subdomain}@petities.nl"], mail.reply_to
assert_equal ['webmaster@petities.nl'], mail.from
assert_equal [@petition.office.email], mail.to
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def send_reply(from, to, title, message)\n RestClient.post API_URL+\"/messages\",\n :from => from.email,\n :to => to.email,\n :subject => \"Follow Up: UROP Application for \"+title,\n :text => message\n end",
"def reply_to_all\n message = reply\n message.to(to - [receiver] + [sender... | [
"0.6878627",
"0.65042347",
"0.65042347",
"0.64381874",
"0.6378649",
"0.63711226",
"0.63221955",
"0.6261616",
"0.62599975",
"0.62409365",
"0.62379",
"0.620096",
"0.61982906",
"0.61939484",
"0.6179729",
"0.61725646",
"0.6101129",
"0.60994095",
"0.6079302",
"0.603338",
"0.602803... | 0.0 | -1 |
Messages to petitioner share recipient and from. | def assert_default_petitioner_mail_attributes(mail)
assert_equal ['webmaster@petities.nl'], mail.from
assert_equal [@petition.petitioner_email], mail.to
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def share_mail(signature, target_email)\n @signature = signature\n @petition = @signature.petition\n\n @person_function = ''\n if @signature.person_function.present?\n @person_function = t('mail.mailafriend.note') + \" \\\"#{@signature.person_function}\\\"\"\n end\n\n mail(\n to: target... | [
"0.68873954",
"0.6824299",
"0.6693002",
"0.6665495",
"0.6573322",
"0.655986",
"0.6530265",
"0.6495105",
"0.64732164",
"0.6430664",
"0.6423017",
"0.6410572",
"0.6344357",
"0.6300223",
"0.62174165",
"0.61617494",
"0.6160349",
"0.6158979",
"0.6136039",
"0.6119723",
"0.6119417",
... | 0.0 | -1 |
Allow us to create virtual resources Generally, in plugins This sets a virtual resource against the Resource class Example: virtual_resource(:virtualhost) do end This defines a virtualhost as a virtual resource and consequently gives the methods has_virtualhost and does_not_have_virtualhost Note that you can define any... | def virtual_resource(name=:virtual_resource, opts={}, &block)
symc = "#{name}".camelcase
eval <<-EOE
class PoolParty::Resources::#{symc} < PoolParty::Resources::Resource
end
EOE
klass = "PoolParty::Resources::#{symc}".constantize
klass.module_eval &block if block
klas... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def virtualize(name, &block)\n self.virtuals ||= {}\n self.virtuals[name] = block\n end",
"def virtual(name, prefix, partial); end",
"def create_resource_for(resource_name)\n resource = self.class.const_set(resource_name, Class.new(Meli::Base))\n resource.prefix = self.class.prefix\n... | [
"0.6193856",
"0.61181206",
"0.58901125",
"0.58762294",
"0.5762889",
"0.57170725",
"0.5681904",
"0.56050956",
"0.5586102",
"0.5586102",
"0.5586102",
"0.5580727",
"0.5492244",
"0.5492244",
"0.5476484",
"0.54550904",
"0.544449",
"0.5380875",
"0.53635705",
"0.53572696",
"0.534537... | 0.7368436 | 0 |
GET /comitemembers GET /comitemembers.json | def index
@comitemembers = Comitemember.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def org_members\n @members = @github.orgs.members.list APP_CONF['org']\n render json: @members\n end",
"def get_members\n @user = User.find_by(user_params)\n @members = @user.members\n \n if not @members.nil?\n render json: @members\n else \n render... | [
"0.71432966",
"0.694869",
"0.68203515",
"0.68028605",
"0.6689545",
"0.6473378",
"0.64205074",
"0.6404864",
"0.6404864",
"0.6404864",
"0.6396081",
"0.63664275",
"0.63625294",
"0.63535416",
"0.6270629",
"0.626547",
"0.6260208",
"0.6250421",
"0.62264526",
"0.6221824",
"0.6221824... | 0.72308576 | 0 |
GET /comitemembers/1 GET /comitemembers/1.json | def show
@comitemembers = Comitemember.all
@members = Member.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @comitemembers = Comitemember.all\n end",
"def org_members\n @members = @github.orgs.members.list APP_CONF['org']\n render json: @members\n end",
"def get_members\n @user = User.find_by(user_params)\n @members = @user.members\n \n if not @members.nil?\n ... | [
"0.69486254",
"0.67406553",
"0.6699259",
"0.64049786",
"0.6331328",
"0.62991095",
"0.62991095",
"0.62991095",
"0.6281681",
"0.62797064",
"0.6247294",
"0.6195165",
"0.6152859",
"0.61428124",
"0.6118622",
"0.6094992",
"0.60852486",
"0.6083268",
"0.6048129",
"0.6037079",
"0.6012... | 0.6751013 | 1 |
POST /comitemembers POST /comitemembers.json | def create
@comitemember = Comitemember.new(comitemember_params)
respond_to do |format|
if @comitemember.save
format.html { redirect_to @comitemember, notice: 'Comitemember was successfully created.' }
format.json { render :show, status: :created, location: @comitemember }
else
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n #sanity checks, can only modify memberships that you own\n if params[:user_id].to_i != current_user.id then\n render json: {message:'You do not own the membership list'}, :status => :unprocessable_entity\n return\n end\n\n #ensure the membership params is there\n unless params... | [
"0.6300617",
"0.6072829",
"0.60053545",
"0.5898235",
"0.58789206",
"0.5867267",
"0.5820536",
"0.58042413",
"0.5761981",
"0.5716328",
"0.5660342",
"0.565942",
"0.5642265",
"0.56367296",
"0.5628035",
"0.5615737",
"0.5606229",
"0.56003624",
"0.559563",
"0.5564302",
"0.55602056",... | 0.65262336 | 0 |
PATCH/PUT /comitemembers/1 PATCH/PUT /comitemembers/1.json | def update
respond_to do |format|
if @comitemember.update(comitemember_params)
format.html { redirect_to @comitemember, notice: 'Comitemember was successfully updated.' }
format.json { render :show, status: :ok, location: @comitemember }
else
format.html { render :edit }
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_tenant_circle(args = {}) \n put(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend",
"def update_current_logged_in_user(args = {}) \n put(\"/users.json/current\", args)\nend",
"def update\n #Finding the specific chore where the id matches the one we pass in with the body\n @v1_chore = Chor... | [
"0.6328931",
"0.6263779",
"0.6221073",
"0.61286914",
"0.60677963",
"0.6047596",
"0.5946337",
"0.59281516",
"0.5908788",
"0.5905915",
"0.5905915",
"0.589533",
"0.58863354",
"0.58671445",
"0.58397555",
"0.5839703",
"0.58211136",
"0.5811436",
"0.57822436",
"0.5778672",
"0.577405... | 0.63957405 | 0 |
DELETE /comitemembers/1 DELETE /comitemembers/1.json | def destroy
@comitemember.destroy
respond_to do |format|
format.html { redirect_to comitemembers_url, notice: 'Comitemember was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @dotsmember = Dotsmember.find(params[:id])\n @dotsmember.destroy\n\n respond_to do |format|\n format.html { redirect_to dotsmembers_url }\n format.json { head :no_content }\n end\n end",
"def destroy \n @oc_member = OcMember.find(params[:id])\n @oc_member.destroy\n\n ... | [
"0.70215803",
"0.7013852",
"0.6995687",
"0.69403404",
"0.68829453",
"0.68829453",
"0.6860483",
"0.6860483",
"0.6831408",
"0.68240196",
"0.68240196",
"0.6805549",
"0.6794228",
"0.6794228",
"0.6794228",
"0.6794228",
"0.6794228",
"0.6794228",
"0.6794228",
"0.6793067",
"0.6764800... | 0.73591983 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_comitemember
@comitemember = Comitemember.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 comitemember_params
params.require(:comitemember).permit(:committee_id, :member_id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",... | 0.0 | -1 |
Fetch the full name of the user | def full_name
"#{self.first_name} #{self.last_name}"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def user_full_name\n @user[\"name\"]\n end",
"def get_user_name\n\t\tretVal = \"User Not Found\"\n\t\tuser_id = self.user_id\n\t\tuser = User.find(user_id, :select=>[\"fname\",\"lname\"])\n\t\tunless user.nil?\n\t\t\tretVal = user.fname + \" \" + user.lname\n\t\tend\n\t\treturn retVal\n\tend",
"def name\n\... | [
"0.83837295",
"0.8210241",
"0.8114376",
"0.80621254",
"0.8050322",
"0.8023667",
"0.8012451",
"0.7961",
"0.79534596",
"0.79534596",
"0.79511935",
"0.79436636",
"0.79127276",
"0.7909869",
"0.78790694",
"0.7841238",
"0.78361505",
"0.77807677",
"0.7778531",
"0.7717547",
"0.771453... | 0.0 | -1 |
if an students unapplies for that said job then we just delete the record. | def student_unapplied
@job_application = JobApplication.find(params[:id])
if @job_application.student_id == current_user.roleable.id
@job_application.delete
flash[:notice] = "Listo, ya no estas aplicando para ese puesto"
redirect_to see_jobs_path
else
flash[:notice] = "No puedes desaplicar para un tra... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def jobs_del\r\n job_profile_id = params[:job_profile_id]\r\n job_profile = JobProfile.find(job_profile_id, :select => \"id, account_id\")\r\n \r\n return jump_to(\"/errors/forbidden\") unless job_profile.account_id == session[:account_id]\r\n \r\n JobProfile.delete(job_profile_id)\r\n @job_pr... | [
"0.66234404",
"0.65108913",
"0.6461721",
"0.6416897",
"0.63391805",
"0.63268554",
"0.63065636",
"0.6295047",
"0.6269776",
"0.62350667",
"0.62238663",
"0.62159127",
"0.61691797",
"0.6156001",
"0.61480963",
"0.61480963",
"0.61183065",
"0.6116055",
"0.6114518",
"0.61044985",
"0.... | 0.64928657 | 2 |
if the company decides to hire the student then we only update the status of the JobApplication record | def company_hired
@job_application = JobApplication.find(params[:id])
if @job_application.job.company_id == current_user.roleable.id
@job_application.status = "Contratado"
flash[:notice] = "Se ha contratado correcamente al egresado!"
@student = Student.find(@job_application.student_id)
@student.state = ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_job_status\n if hired_changed? and job\n if hired\n self.job.update_attribute :open, false\n else\n self.job.update_attribute :open, true\n end\n end\n end",
"def update\n if params[:job][:staff].present?\n @job.staff.clear\n params[:job][:staff].each ... | [
"0.68167233",
"0.68161434",
"0.6808715",
"0.66528803",
"0.6624636",
"0.65516996",
"0.6507115",
"0.6507115",
"0.6503819",
"0.6483749",
"0.64693576",
"0.64426386",
"0.6429988",
"0.63662696",
"0.636339",
"0.63604766",
"0.63483274",
"0.63429314",
"0.6331158",
"0.63070214",
"0.626... | 0.71218586 | 0 |
What we scaffold: Build model (with unit tests) Migration (Include deleted_at for soft delete) Build factories with limited support for FFaker Build controller (with unit tests) Build routes Build views (_form, edit, index, new) Build policy objects (with unit tests) Build feature tests (index, create, update, destroy ... | def scaffold
# Generate models
generate("frontier_model", ARGV[0])
unless model.skip_ui?
# Generate controllers
generate("frontier_controller", ARGV[0])
# Generate views
generate("frontier_crud_views", ARGV[0])
# Generate policies
generate("frontier_policy", ARGV[0])
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @build = Build.new\n\n \n end",
"def build; end",
"def build\n end",
"def build\r\n end",
"def build\r\n end",
"def build!\n end",
"def build(*args)\n model = generate(*args)\n model.save\n model\n end",
"def model_class\n ::Ci::Build\n end",
"def new... | [
"0.62157387",
"0.62056005",
"0.6149594",
"0.6122502",
"0.6122502",
"0.60071087",
"0.5970789",
"0.5875449",
"0.5805002",
"0.5791995",
"0.57330227",
"0.5677001",
"0.56711984",
"0.56518173",
"0.56518173",
"0.5630826",
"0.55909956",
"0.55895394",
"0.5559768",
"0.5516053",
"0.5491... | 0.6104936 | 5 |
The patch is to fix a core dump in Bug in PIL's quantize() with 64 bit architectures. | def patches
DATA
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pointer_size\n is_64bit ? 8 : 4\n end",
"def compressed_size; end",
"def compressed_size; end",
"def pixel_size; size.x * size.y; end",
"def compressed_size=(_arg0); end",
"def convert_image\n [16, 32, 64, 128].each do |size|\n convert_to_cache(size)\n end\n end",
"def large_image_w... | [
"0.5699385",
"0.5538211",
"0.5538211",
"0.5505387",
"0.53384584",
"0.5265782",
"0.519072",
"0.51459587",
"0.512661",
"0.51040226",
"0.5103516",
"0.5087984",
"0.5080438",
"0.5080438",
"0.5059701",
"0.50545794",
"0.5041337",
"0.5024155",
"0.5024155",
"0.50112885",
"0.49735287",... | 0.0 | -1 |
set default for private attribute to false | def public?
!private
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_defaults\n self.hidden ||= false\n end",
"def fields_are_private_by_default?\n ensure_setup!\n options[:visibility] == :private\n end",
"def by_default?\n false\n end",
"def set_defaults\n self.is_admin == false\n end",
"def set_defaults\n # By the way, this me... | [
"0.7142315",
"0.71222454",
"0.690919",
"0.69055337",
"0.6838684",
"0.679225",
"0.6785153",
"0.670946",
"0.6698765",
"0.6676067",
"0.66545254",
"0.66462314",
"0.6640952",
"0.6635633",
"0.6631872",
"0.6614501",
"0.66107017",
"0.6553514",
"0.6535993",
"0.65251917",
"0.6514636",
... | 0.0 | -1 |
Class to read input from user and compare again known commands some commands require two words | def handle_input
# Takes user input
input = STDIN.gets.chomp
system('clear')
# Single word commands
# QUIT
if input == 'quit'
@run_game = false
puts "Thanks for playing!"
sleep(3)
system('clear')
# BACKPACK
elsif input == 'backpack'
@player.print_backp... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def process_input(input)\n args = input.split(' ')\n command = args.shift\n return false if command.nil?\n results = self.class.search(command, ConsoleProgram.scopes.active)\n if results.length == 1\n results.first.new(args)\n else\n multiple_commands = []\n results.each do |klass|... | [
"0.72747916",
"0.67126584",
"0.6711882",
"0.66055363",
"0.65910697",
"0.6519679",
"0.6517951",
"0.642518",
"0.6409627",
"0.6408113",
"0.6400838",
"0.63081086",
"0.6274884",
"0.6272199",
"0.6240104",
"0.62262005",
"0.62257683",
"0.6216708",
"0.61950654",
"0.619037",
"0.6183787... | 0.64604276 | 7 |
Initialises all game objects and their attributes | def initialize_environment
# Create items
@key = Item.new("key", "Head to the livingroom and use it before the ghost finds you!", "d", true)
@phone = ScoreItem.new("phone", "This works better with charge", "You've used the phone to leave a good review and the ghost loved it! Your score has improved by one s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_game_objects\n rm_extender_create_game_objects\n $game_self_vars = Hash.new\n $game_labels = Hash.new\n $game_self_labels = Hash.new\n end",
"def init_game\n @io.welcome_msg\n @num_decks = @io.get_num_decks \n @player_cnt = @io.get_player_cnt(@max_players)\n players_... | [
"0.73748857",
"0.6818352",
"0.6765243",
"0.65569055",
"0.65507984",
"0.65133375",
"0.64690095",
"0.6439903",
"0.640616",
"0.6393699",
"0.6378587",
"0.63523334",
"0.63146687",
"0.63107437",
"0.6303703",
"0.6258151",
"0.624342",
"0.62359524",
"0.6231693",
"0.62161237",
"0.62067... | 0.5770501 | 66 |
Validates item is in room Removes item from room and adds to players backpack | def take_item(command)
if @current_room.has_item?(command) # item isn't in current room
self.new_current_item(command)
# Remove from room and add to backpack
@current_room.remove_item(command)
@player.pick_up(command)
puts "\nYou have picked up a #{@current_item.name}"
puts @curr... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def drop_item(item)\n #this will take an item from the hero's inventory and place it in the current room\n end",
"def remove_from_gamespace\n # remove it from the room it's in.\n self.from_room \n self.recycle \n # Possibly in the future return all switches. I.e. an admin taking over an NPC body.... | [
"0.69065285",
"0.6767096",
"0.67458135",
"0.6603359",
"0.6277711",
"0.6174731",
"0.6172688",
"0.6087252",
"0.6060096",
"0.6024024",
"0.60207987",
"0.59822786",
"0.5825139",
"0.5798893",
"0.5798189",
"0.57874787",
"0.5768507",
"0.57216734",
"0.5717968",
"0.57084304",
"0.570267... | 0.6196508 | 5 |
Validates item is in backpack and depending on item type either adjusts score or finishes game | def use_item(command)
if @player.has_item?(command)
# Player is carrying item
self.new_current_item(command)
if @current_item.is_key?
if @current_room == @lroom
puts "Congratulations! You escaped the AirBnB"
puts "You escaped with a rating of: \n"
puts @star... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_item\n # continue input if item should be used\n return false if !self.check_item_condition?\n # if item not usable or item use process not executed and no selection\n if $game_player.battler.item == 0 ||\n !$game_player.use_item($data_items[$game_player.battler.item]) &&\n ... | [
"0.6544835",
"0.6384428",
"0.63258195",
"0.6312675",
"0.6167244",
"0.6150383",
"0.6149054",
"0.6097104",
"0.60433525",
"0.6040932",
"0.6009231",
"0.6005586",
"0.59727484",
"0.59668845",
"0.5927016",
"0.5894959",
"0.5849974",
"0.584237",
"0.5819108",
"0.58133554",
"0.58028847"... | 0.5872931 | 16 |
Validates direction inputted leads to a room Updates current room | def go_room(command)
if @current_room.has_exit?(command)
# current room has this exit
exit_room = @current_room.get_exit(command) # return string of room name
# Search for instance of this room
# update current room
@game_rooms.each do |room|
if room.is_room?(exit_room)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @room = Room.update(params.require(:id), room_attributes)\n if @room.valid?\n success\n else\n validation_errors(@room)\n end\n end",
"def update\n if @moving.update(moving_params)\n unless @moving.save_rooms(params[:moving][:rooms])\n flash[:warni... | [
"0.64552754",
"0.64520425",
"0.6423017",
"0.626482",
"0.6104987",
"0.60988015",
"0.6079913",
"0.60535735",
"0.6041613",
"0.6041613",
"0.6041613",
"0.6038573",
"0.6012011",
"0.5983828",
"0.5973101",
"0.59718484",
"0.5955458",
"0.59512436",
"0.5949693",
"0.5948011",
"0.5947553"... | 0.61764306 | 4 |
Print available commands, directions, rooms & items | def print_commands
puts "Your available commands are: ".green
puts "go take use help backpack quit\n\n"
puts "Directions:".green
@current_room.print_exits
if @current_room.has_items?
# Room has items in it
puts "\nItems available: ".colorize(:green)
@current_room.print_items
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list_commands\n puts UI_ARROW.light_yellow + \" \" + \"'fight', 'f', or 'battle' to view enemies and fight.\"\n puts UI_ARROW.light_yellow + \" \" + \"'armoury' or 'a' to go to the armoury.\"\n puts UI_ARROW.light_yellow + \" \" + \"'stats' to view your current status.\"\n puts UI_ARROW.light_yello... | [
"0.71835214",
"0.70898813",
"0.68807715",
"0.65819234",
"0.645604",
"0.64390475",
"0.6406011",
"0.6381512",
"0.63746774",
"0.63736993",
"0.6351202",
"0.6326877",
"0.6311376",
"0.6264881",
"0.61981565",
"0.6196223",
"0.6152291",
"0.61484236",
"0.6144797",
"0.6130418",
"0.61241... | 0.85641176 | 0 |
Print welcome message to user formatted in a red bo with a border | def print_welcome
box = TTY::Box.frame(width: 90, height: 17, align: :center, style: {bg: :red}) do
"\nWelcome to the AirBnB escape game!\n
You have rented an AirBnB for the night and during your stay\n
have realised that your super host might be supernatural.\n
In order to survive, you must... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def welcome_message\n puts \"\n ┏━━━┓━━━━┏┓━━━━━━━┏┓━━━━━━━━┏┓━\n ┃┏━┓┃━━━━┃┃━━━━━━━┃┃━━━━━━━┏┛┗┓\n ┃┗━┛┃┏┓┏┓┃┗━┓┏┓━┏┓┃┃━┏┓┏━━┓┗┓┏┛\n ┃┏┓┏┛┃┃┃┃┃┏┓┃┃┃━┃┃┃┃━┣┫┃━━┫━┃┃━\n ┃┃┃┗┓┃┗┛┃┃┗┛┃┃┗━┛┃┃┗┓┃┃┣━━┃━┃┗┓\n ┗┛┗━┛┗━━┛┗━━┛┗━┓┏┛┗━┛┗┛┗━━┛━┗━┛\n ... | [
"0.73284364",
"0.713477",
"0.71022743",
"0.71007407",
"0.70024383",
"0.6943597",
"0.69146645",
"0.6900986",
"0.68961215",
"0.68570006",
"0.6851913",
"0.682991",
"0.67697144",
"0.67637426",
"0.6749306",
"0.67271733",
"0.6710904",
"0.6693463",
"0.6655457",
"0.66517806",
"0.6633... | 0.7259877 | 1 |
Opens file and writes new line to it | def write_to_file(line, my_file)
# Error Handling
begin
File.open(my_file, "a") { |f| f.write "#{line}\n" }
rescue => e
raise FileNotFoundError,"Could not find file"
puts e.message
puts e.backtrace.inspect
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_line_to_file(file, line)\n File.open(file, \"a\") {|f| f.puts(\"#{line}\")}\n end",
"def newline()\n @file.write(\"\\n\")\n end",
"def append_line\n File.open(path, 'w') do |fh|\n lines.each do |l|\n fh.puts(l)\n end\n fh.puts line\n end\n end",
"def append_line_t... | [
"0.74757147",
"0.73306346",
"0.7309672",
"0.73075056",
"0.7270581",
"0.7237945",
"0.72036654",
"0.7099398",
"0.6749733",
"0.6701245",
"0.6529158",
"0.6493587",
"0.6462126",
"0.64620805",
"0.6383742",
"0.6383742",
"0.6367607",
"0.6347354",
"0.63328964",
"0.632448",
"0.62951887... | 0.6183684 | 27 |
Validates item as an item in the game and updates current item | def new_current_item(command)
@game_items.each do |item|
if item.is_item?(command)
@current_item = item
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_item\n # continue input if item should be used\n return false if !self.check_item_condition?\n # if item not usable or item use process not executed and no selection\n if $game_player.battler.item == 0 ||\n !$game_player.use_item($data_items[$game_player.battler.item]) &&\n ... | [
"0.7698581",
"0.7389902",
"0.72924334",
"0.7193974",
"0.6940228",
"0.6888836",
"0.6828286",
"0.6714838",
"0.6701786",
"0.6676836",
"0.6666414",
"0.66294634",
"0.6620903",
"0.65999854",
"0.6526522",
"0.6517986",
"0.64891446",
"0.64812785",
"0.6467987",
"0.6456754",
"0.6456328"... | 0.0 | -1 |
Get the rails logger. | def rails_logger
defined?(Rails) && Rails.respond_to?(:logger) && Rails.logger
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def logger\n if !Rails.nil?\n return Rails.logger\n else\n return Logger.new( STDOUT )\n end\n end",
"def logger\n unless @logger\n if defined?(Rails) && ::Rails.logger\n @logger = ::Rails.logger\n else\n @logger = ::Logger.new(STDERR)\n ... | [
"0.8582375",
"0.8527005",
"0.85252905",
"0.8474324",
"0.83409715",
"0.82954866",
"0.8262594",
"0.82197416",
"0.8206335",
"0.8206335",
"0.81383276",
"0.80863273",
"0.795165",
"0.79264176",
"0.7888504",
"0.7888504",
"0.7849386",
"0.78331345",
"0.78239095",
"0.7817571",
"0.78131... | 0.82239556 | 7 |
Get the default logger. | def default_logger
logger = Logger.new(STDOUT)
logger.level = Logger::INFO
logger
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def default_logger\n Logger.new(debug? ? STDOUT : nil)\n end",
"def logger\n return @logger ||= default_logger\n end",
"def logger\n @logger ||= default_logger\n end",
"def logger\n @logger ||= default_logger\n end",
"def default_logger\n Logger.new(STDOUT)\n end... | [
"0.84414726",
"0.83610004",
"0.82711554",
"0.8249946",
"0.81388146",
"0.8112992",
"0.8112992",
"0.79669183",
"0.7891161",
"0.7767544",
"0.7767544",
"0.7712007",
"0.76754177",
"0.7641371",
"0.76356536",
"0.7630005",
"0.76122713",
"0.7607246",
"0.7607246",
"0.76035166",
"0.7528... | 0.79327685 | 8 |
Gets Page object that has given url. Very inefficient O(n) solution. | def get_page_from_url(url,col)
col.each do |page|
return page if page.url == url
end
return nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_page_from_url(url)\n site.pages.each do |page|\n if page.url == url then\n return page\n end\n end\n end",
"def get_page_from_url(url)\n\t(site.pages + site.posts).each do |page|\n\t\treturn page if page.url == url\n\tend\n\n\treturn nil\nend",
"def get_page_from_url... | [
"0.8597803",
"0.8333806",
"0.8118418",
"0.73395467",
"0.7280933",
"0.72130805",
"0.6951641",
"0.69040656",
"0.6886852",
"0.6777563",
"0.6535708",
"0.65314656",
"0.6522608",
"0.64791226",
"0.63877803",
"0.63153005",
"0.6297834",
"0.62097734",
"0.6172128",
"0.6127341",
"0.61022... | 0.7226216 | 5 |
Gets Page object that has given path. Very inefficient O(n) solution. | def get_pages_from_path(path,col)
a = []
col.each do |page|
if page.data['title']
pt = page.url.split("/")
fl=pt[-1]
if pt[0..-2].join("/") == path and fl != "index.html"
a << page
elsif pt[0..-3].join("/") == path and fl=="index.html"
a << page
end
end
end
return a
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_page_by_path(page_path, output = :OBJECT, post_type = 'page')\n slugs = page_path.split('/')\n ancestors = []\n p_class = Railspress::WpPost.find_sti_class(post_type)\n page = nil\n begin\n post_parent = 0\n slugs.each do |slug|\n begin\n page = p_class.where(post_n... | [
"0.7723916",
"0.76899713",
"0.7555201",
"0.71748966",
"0.67586327",
"0.6656543",
"0.65503126",
"0.6549743",
"0.65392",
"0.64404523",
"0.6359445",
"0.63447756",
"0.6318401",
"0.62927735",
"0.6291127",
"0.6221604",
"0.6218575",
"0.61995095",
"0.61596596",
"0.6033376",
"0.602129... | 0.5869679 | 32 |
uses the string instance method scan. scan matches a given pattern and for every match populates an array with the match. | def print_in_box(string)
lines = string.scan(/.{1,76}/)
width = lines.first.to_s.size + 2
top_bot = "+#{'-' * width}+"
padding = "|#{' ' * width}|"
text = lines.map { |line| "| #{line.ljust(width - 2)} |" }
puts [top_bot, padding, text, padding, top_bot]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def scan(pattern); end",
"def scan(pattern, &blk)\n @string.scan(pattern, &blk)\n end",
"def scan(pattern, &blk)\n @string.scan(pattern, &blk)\n end",
"def scan(pattern)\n do_scan pattern, true, true, true\n end",
"def scan\n list = []\n io.each do |input|\n # T... | [
"0.749408",
"0.72997355",
"0.72997355",
"0.697791",
"0.6790932",
"0.6716557",
"0.6712049",
"0.65929854",
"0.64626783",
"0.64626783",
"0.6414182",
"0.6297995",
"0.6211988",
"0.61919695",
"0.6190965",
"0.6146892",
"0.6146892",
"0.6144913",
"0.613808",
"0.60917413",
"0.6038085",... | 0.0 | -1 |
Map out the columns for future reference on type conversion :nodoc: | def _protobuf_map_columns(force = false)
COLUMN_TYPE_MAP_MUTEX.synchronize do
@_protobuf_mapped_columns = false if force
return unless table_exists?
return if _protobuf_mapped_columns?
@_protobuf_columns = {}
@_protobuf_column_types = ::Hash.new { ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def map_columns\n @map_columns ||= attribute_definitions.values.select { |c| c.type == :map }\n end",
"def mapped_columns\n @columns.map do |column|\n @mappings[column] || column.to_s.send(@inflector)\n end\n end",
"def convert_columns(arr)\n if ccs = @column_conver... | [
"0.71485853",
"0.6956067",
"0.6920979",
"0.6796395",
"0.6789203",
"0.6781656",
"0.6765806",
"0.6754353",
"0.6662339",
"0.66538286",
"0.6539466",
"0.6534895",
"0.65174633",
"0.64978445",
"0.6494216",
"0.64723724",
"0.64312786",
"0.6411026",
"0.63987535",
"0.6382866",
"0.636604... | 0.6365645 | 21 |
PUT /grants/1 PUT /grants/1.json | def update
@grant = Grant.find(params[:id])
respond_to do |format|
if @grant.update_attributes(params[:grant])
format.html { redirect_to @grant, :notice => 'Grant was successfully updated.' }
format.json { head :ok }
else
format.html { render :action => "edit" }
form... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n keystone.update_tenant({:id=>params[:id],:name=>params[:name],:description=>params[:description],:enabled=>params[:enabled]})\n respond_to do |format|\n format.html { redirect_to tenants_path, :notice => 'Tenant was successfully updated.' }\n format.json { head :ok }\n end\n en... | [
"0.64853686",
"0.62773246",
"0.6226604",
"0.61623996",
"0.61225176",
"0.60765207",
"0.6064201",
"0.5903576",
"0.58978826",
"0.57945323",
"0.57646036",
"0.5749848",
"0.566394",
"0.5653271",
"0.56494325",
"0.5623392",
"0.5623392",
"0.56206733",
"0.56206733",
"0.5608681",
"0.559... | 0.6564642 | 0 |
Very permissive. Might get unnecessary reloads. That's okay. | def pm_is_in_ancestry?(vc, screen_names)
screen_names.any? do |screen_name|
vc.class.to_s.include?(screen_name) ||
vc.class.ancestors.any? do |ancestor|
screen_name.include?(ancestor.to_s)
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pausable; end",
"def private; end",
"def reloader; end",
"def reloader; end",
"def used?; end",
"def reload!\n begin\n #TODO not implemented 2007/04/09 by shino\n raise \"not yet implemented!\"\n end\n end",
"def reload!\n begin\n #TODO not imple... | [
"0.693961",
"0.6875048",
"0.6596903",
"0.6596903",
"0.65255535",
"0.65233326",
"0.65233326",
"0.65233326",
"0.65233326",
"0.6450183",
"0.6417622",
"0.63835275",
"0.63705623",
"0.63209975",
"0.6285962",
"0.6285962",
"0.6285962",
"0.6285962",
"0.6283785",
"0.6283785",
"0.628378... | 0.0 | -1 |
Use callbacks to share common setup or constraints between actions. | def set_blog_post
@blog_post = BlogPost.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 |
Only allow a trusted parameter "white list" through. | def blog_post_params
params.require(:blog_post).permit(:title, :content, :published, :category_id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allowed_params\n ALLOWED_PARAMS\n end",
"def expected_permitted_parameter_names; end",
"def param_whitelist\n [:role, :title]\n end",
"def default_param_whitelist\n [\"mode\"]\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def permitted_params\n []\n end",
... | [
"0.71230334",
"0.70530915",
"0.69479465",
"0.6902122",
"0.67367256",
"0.67172784",
"0.6689043",
"0.66784793",
"0.6660117",
"0.6555213",
"0.6528485",
"0.6458438",
"0.6452378",
"0.6451654",
"0.64478326",
"0.6433326",
"0.6413599",
"0.6413599",
"0.63907677",
"0.63787645",
"0.6378... | 0.0 | -1 |
def select_category_from_projects "SELECT category FROM projects;" end Make sure each ruby method returns a string containing a valid SQL statement. | def selects_the_titles_of_all_projects_and_their_pledge_amounts #GROUP BY will get rid of repeats
#projects have many pledges, pledges belong to projects
"SELECT projects.title, SUM(pledges.amount)
FROM pledges INNER JOIN projects ON pledges.project_id = projects.id
GROUP BY projects.title"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def select_category_from_projects\n\"SELECT category FROM projects;\"\nend",
"def selects_the_category_names_and_pledge_amounts_of_all_pledges_in_the_music_category\n\"SELECT projects.category, pledges.amount\nFROM pledges\nINNER JOIN projects\nON projects.id = pledges.project_id\nWHERE projects.category = 'musi... | [
"0.9197428",
"0.70681554",
"0.69905895",
"0.6650687",
"0.6622008",
"0.65134215",
"0.6487074",
"0.63231736",
"0.60595876",
"0.59397984",
"0.5938012",
"0.59359765",
"0.59009475",
"0.58821595",
"0.58702105",
"0.58538514",
"0.5852772",
"0.58400726",
"0.58187836",
"0.5783952",
"0.... | 0.0 | -1 |
SELECT Cats.name, Cats.breed, Owners.name FROM Cats INNER JOIN Owners ON Cats.owner_id = Owners.id; | def selects_user_names_and_amounts_of_all_pledges_grouped_by_name_then_orders_them_by_the_amount
#Select users.name, SUM(pledges.amount) #Group by users.name #order by SUM(pledges.amount)
#pledges belong to users, users have many pledges --> pledges go after from
"SELECT users.name, SUM(pledges.amount)
FROM pledges I... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list_owners\n Owner.all.each_with_index do |owner, i|\n puts \"\\n#{i + 1}. #{owner.name} \\nAddress: #{owner.address}\"\n puts \"Food provided: #{owner.food_provided.capitalize}\"\n puts \"Has a cat? #{owner.cat_already.to_s.capitalize} | Has a dog? #{owner.dog.to_s.cap... | [
"0.7125217",
"0.66479516",
"0.66479516",
"0.6584939",
"0.65329665",
"0.64940083",
"0.64466745",
"0.64332014",
"0.64326346",
"0.6429383",
"0.63726604",
"0.62606883",
"0.620419",
"0.6121527",
"0.61146575",
"0.60934967",
"0.6089321",
"0.60817194",
"0.60728776",
"0.6055935",
"0.6... | 0.0 | -1 |
Replace this with your real tests. | def test_accessors
assert_kind_of WikiVisit, @visit
assert_kind_of WikiPage, @visit.wiki_page
assert_kind_of User, @visit.user
assert_equal Time.parse("2007-01-08 00:43:00"), @visit.time_of_visit
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def testing\n # ...\n end",
"def __dummy_test__\n end",
"def tests; end",
"def tests; end",
"def spec; end",
"def spec; end",
"def self_test; end",
"def self_test; end",
"def test \n end",
"def test_0_dummy\n\t\tend",
"def test\n\n end",
"def test\n end",
"def test\n end"... | [
"0.7446459",
"0.6956364",
"0.69155836",
"0.69155836",
"0.6864151",
"0.6864151",
"0.66406286",
"0.66406286",
"0.66253287",
"0.6547665",
"0.6524571",
"0.6484549",
"0.6484549",
"0.6484549",
"0.6403847",
"0.6389188",
"0.6389188",
"0.6389188",
"0.6389188",
"0.6389188",
"0.6389188"... | 0.0 | -1 |
Complete each step below according to the challenge directions and include it in this file. Also make sure everything that isn't code is commented in the file. I worked on this challenge by myself. 1. Pseudocode What is the input? The input for the first method will be an array of numbers, and for the second method wil... | def total(an_array)
an_array.reduce(:+)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sentence_maker(array)\n\tx = 0\n\tsum = \"\"\n\twhile x <= array.length-1\n\t\tif x == array.length-1\n\t\t\tsum += array[x].to_s\n\t\t\tx += 1\n\t\telse \n\t\t\tsum += array[x].to_s + \" \"\n\t\t\tx += 1\n\t\tend\t\n\tend\n\tsum += \".\"\n\tsum.capitalize!\n\treturn sum\nend",
"def sentence_maker(array)\n ... | [
"0.6243902",
"0.62435853",
"0.59667695",
"0.593968",
"0.59014624",
"0.583775",
"0.58294076",
"0.5768723",
"0.57597804",
"0.5749126",
"0.5747635",
"0.5744971",
"0.56973886",
"0.5681837",
"0.5654107",
"0.56465286",
"0.56130755",
"0.560964",
"0.5604325",
"0.5599078",
"0.5583098"... | 0.0 | -1 |
Multiples of 3 and 5 Problem 1 If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. Find the sum of all the multiples of 3 or 5 below 1000. | def brut_force_solution
(1...1000).inject(0){|sum, digit| ((digit % 3 == 0) || (digit % 5 == 0)) ? sum += digit : sum}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_sum_of_multiples_of_3_and_5_below_1000\n answer = 0\n for number in 1...1000\n answer += number if number % 3 == 0 || number % 5 == 0\n end\n answer\nend",
"def sum_of_multiples\n multiples_of_three_or_five = []\n\n for n in 3...1000\n if n % 3 == 0\n multiples_of_three_or_five.push(n)\... | [
"0.8610462",
"0.85608023",
"0.8475745",
"0.84110177",
"0.83885396",
"0.8364759",
"0.8358236",
"0.8334711",
"0.83078986",
"0.8298419",
"0.82765603",
"0.82644993",
"0.82576615",
"0.8125646",
"0.8122031",
"0.8110295",
"0.80918163",
"0.8063683",
"0.7961667",
"0.79474473",
"0.7945... | 0.0 | -1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.