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 |
|---|---|---|---|---|---|---|
If there are two or more words that are the same length, return the first word from the string with that length. Ignore punctuation and assume sen will not be empty. | def longest_word(sen)
tmp_arr = sen.split(" ")
tmp_longest = 0
tmp_arr.each do |i|
tmp_longest = i.size if i.size > tmp_longest
end
tmp_arr.select { |i| i.size == tmp_longest }.first
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def LongestWord(sen)\n str = sen.split(\" \")\n longest_word = str[0]\n str.each do |word|\n word.sub(/[\\w\\s]/, '')\n if longest_word.length < word.length\n longest_word = word\n end\n end\n longest_word\nend",
"def LongestWord(sen)\n\tarr = sen.gsub(/[^a-zA-Z]+/m, ' ').strip.split(\" \")\n\... | [
"0.781355",
"0.758387",
"0.74880713",
"0.74303347",
"0.73972505",
"0.7377614",
"0.7355616",
"0.7231046",
"0.7179081",
"0.7120521",
"0.70515186",
"0.7044977",
"0.7025602",
"0.7022134",
"0.7019273",
"0.6981005",
"0.6978153",
"0.69676393",
"0.69303095",
"0.6930229",
"0.6918541",... | 0.6989949 | 15 |
Subject can be set in your I18n file at config/locales/en.yml with the following lookup: en.user_mailer.welcome_email.subject | def product_email(product, user)
@greeting = 'Hi'
@product = product
mail to: user.email
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def subject (recipient)\n subject_variables = alert_variables[:subject].dup\n subject_variables.merge!(recipient_details(recipient))\n subject = \"#{I18n.t(\"#{recipient_type.to_s}_subject_#{alert_name.to_s}\", subject_variables)}\"\n subject\n end",
"def set_EmailSubject(value)\n s... | [
"0.6765104",
"0.6726595",
"0.67247695",
"0.67163604",
"0.67111814",
"0.67100495",
"0.6694839",
"0.6693109",
"0.6671716",
"0.6627427",
"0.6599362",
"0.65409476",
"0.6539258",
"0.65040624",
"0.64823294",
"0.64546007",
"0.6429769",
"0.6403822",
"0.6354559",
"0.6319615",
"0.63196... | 0.0 | -1 |
a single dash before and after each odd digit. There is one exception: don't start or end the string with a dash. You may wish to use the `%` modulo operation; you can see if a number is even if it has zero remainder when divided by two. Difficulty: medium. | def dasherize_number(num)
str = ""
arr = num.to_s.split('')
i = 0
while i<arr.count
if is_odd?(arr[i].to_f)
if i>0 && !(str[-1]=='-')
str += '-'
end
str += arr[i]
if i<arr.count-1
str += '-'
end
else
str += arr[i]
end
i+=1
end
return str
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dasherize_number(num)\n\n index = 0\n \n num_string = num.to_s\n new_string = ''\n \n while index < num_string.length\n # Simplify your checks for odd and evenness here. \n # You are checking for so many things which makes the code messy.\n # Just divide the number using modulo you don't need to chec... | [
"0.8318996",
"0.7968655",
"0.79432404",
"0.7927553",
"0.79227006",
"0.7920647",
"0.7899584",
"0.77757",
"0.7765964",
"0.7704206",
"0.77036357",
"0.76868725",
"0.7661751",
"0.76534855",
"0.7652473",
"0.7633463",
"0.7631875",
"0.7612631",
"0.7606616",
"0.7600646",
"0.7583064",
... | 0.78489393 | 7 |
Returns true if the user is logged in, false otherwise. | def logged_in?
!curr_worker_id.nil?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def user_is_logged_in()\n user = get_user()\n if user != nil\n true\n else\n false\n end\n end",
"def logged_in?\n user._logged_in?\n end",
"def logged_in?\n if session[:username]\n if session[:logged_in?]\n return true\n end\n else\n r... | [
"0.9082417",
"0.8764097",
"0.87552106",
"0.8718715",
"0.86894006",
"0.86498255",
"0.86469626",
"0.86372185",
"0.8631328",
"0.86285406",
"0.86285406",
"0.8582609",
"0.85669243",
"0.85613596",
"0.85613596",
"0.8551865",
"0.85491496",
"0.85443276",
"0.85409296",
"0.8539988",
"0.... | 0.0 | -1 |
Redirects to stored location (or to the default). | def redirect_back_or(default)
redirect_to(session[:forwarding_url] || default)
session.delete(:forwarding_url)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def redirect_to_stored(default='/')\n return_to = session[:return_to] || default\n session[:return_to] = nil\n redirect return_to\n end",
"def redirect_to_stored_location_or(default)\n redirect_to(session[:forward_url] || default)\n session.delete(:forward_url)\n end",
"def redirect_ba... | [
"0.7730111",
"0.7649159",
"0.704684",
"0.7029194",
"0.6981081",
"0.6871779",
"0.67809576",
"0.67569697",
"0.6699827",
"0.65908873",
"0.6580519",
"0.65731466",
"0.65681744",
"0.6567211",
"0.654002",
"0.653624",
"0.6530604",
"0.65075284",
"0.64961356",
"0.64893895",
"0.6443822"... | 0.0 | -1 |
Stores the URL trying to be accessed. | def store_location
session[:forwarding_url] = request.url if request.get?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def store_location\n session[:forwarding_url] = request.url if request.get?\n # Makes sure that the URL is saved only for a GET request because submitting\n # DELETE, PATCH or POST will raise errors when the URL is expecting\n # a GET request.\n end",
"def store_location\n # store last url as lon... | [
"0.6912814",
"0.6897356",
"0.688702",
"0.6786295",
"0.6786295",
"0.6786295",
"0.6786295",
"0.6786295",
"0.6786295",
"0.6694544",
"0.66805685",
"0.66383713",
"0.6634571",
"0.6630931",
"0.6593764",
"0.6593764",
"0.6593764",
"0.6593764",
"0.6593677",
"0.65701944",
"0.65585965",
... | 0.647905 | 55 |
Confirms a loggedin user. | def logged_in_user
unless logged_in?
store_location
flash[:danger] = "Please enter your worker ID to continue."
redirect_to start_url
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def correct_user\n @user = User.find(params[:id])\n if !current_user?(@user)\n message = \"currently logged in as #{current_user.name}. Not you? \"\n message += \"#{view_context.link_to('Log out.', log_out)}\".html_safe\n flash[:warning] = message\n redirect_to(root_url)\n ... | [
"0.70087826",
"0.6982988",
"0.6919373",
"0.688131",
"0.6845446",
"0.68326277",
"0.67944413",
"0.67929715",
"0.6642435",
"0.6624581",
"0.66114175",
"0.66022736",
"0.6589018",
"0.65539706",
"0.65349805",
"0.65303934",
"0.6512816",
"0.650312",
"0.64878744",
"0.6487622",
"0.64804... | 0.0 | -1 |
I worked on this challenge with: Jon Clayton. Your Solution Below | def leap_year? (year)
case
when year % 400 == 0
return true
when year % 100 == 0
return false
when year % 4 == 0
return true
else
return false
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def solution4(input)\n end",
"def challenge; end",
"def decodeHalfway(input)\n sum = 0\n\n # Only have to loop through half the array since the numbers are being compared halfway around\n # Multiply each matching character by 2 to compensate for not looping through its pair\n input.chars[0..input.length/2... | [
"0.6426526",
"0.6196587",
"0.6143841",
"0.60725206",
"0.60663986",
"0.60514444",
"0.6044827",
"0.60304916",
"0.60167587",
"0.59670925",
"0.59660167",
"0.5930118",
"0.5916622",
"0.5908013",
"0.5902738",
"0.5890668",
"0.5882447",
"0.5870266",
"0.5864797",
"0.586191",
"0.5860125... | 0.0 | -1 |
GET /property_between_floor_slaps GET /property_between_floor_slaps.json | def index
@property_between_floor_slaps = PropertyBetweenFloorSlap.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_property_between_floor_slap\n @property_between_floor_slap = PropertyBetweenFloorSlap.find(params[:id])\n end",
"def property_between_floor_slap_params\n params.require(:property_between_floor_slap).permit(:between_floor_slap_id, :property_id, :quality_id)\n end",
"def create\n @prop... | [
"0.69060063",
"0.61157036",
"0.5888169",
"0.5649257",
"0.5491359",
"0.5422482",
"0.5376796",
"0.5331189",
"0.53073645",
"0.52703154",
"0.5230716",
"0.52174205",
"0.52156436",
"0.52033854",
"0.51998276",
"0.5193905",
"0.51654613",
"0.51582396",
"0.5149543",
"0.510811",
"0.5101... | 0.78588855 | 0 |
GET /property_between_floor_slaps/1 GET /property_between_floor_slaps/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @property_between_floor_slaps = PropertyBetweenFloorSlap.all\n end",
"def set_property_between_floor_slap\n @property_between_floor_slap = PropertyBetweenFloorSlap.find(params[:id])\n end",
"def create\n @property_between_floor_slap = PropertyBetweenFloorSlap.new(property_between_flo... | [
"0.7740396",
"0.69099206",
"0.60001385",
"0.59754264",
"0.5973053",
"0.54860026",
"0.54810286",
"0.54681605",
"0.54676515",
"0.54211324",
"0.5353735",
"0.53311706",
"0.53311706",
"0.5323841",
"0.53222436",
"0.5319887",
"0.5318211",
"0.53117114",
"0.52870905",
"0.52593625",
"0... | 0.0 | -1 |
POST /property_between_floor_slaps POST /property_between_floor_slaps.json | def create
@property_between_floor_slap = PropertyBetweenFloorSlap.new(property_between_floor_slap_params)
respond_to do |format|
if @property_between_floor_slap.save
format.html { redirect_to @property_between_floor_slap, notice: 'Property between floor slap was successfully created.' }
format.json { render :show, status: :created, location: @property_between_floor_slap }
else
format.html { render :new }
format.json { render json: @property_between_floor_slap.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @property_between_floor_slaps = PropertyBetweenFloorSlap.all\n end",
"def set_property_between_floor_slap\n @property_between_floor_slap = PropertyBetweenFloorSlap.find(params[:id])\n end",
"def property_between_floor_slap_params\n params.require(:property_between_floor_slap).permi... | [
"0.6934517",
"0.68359023",
"0.65886587",
"0.55116165",
"0.5449827",
"0.5305369",
"0.5082544",
"0.50723386",
"0.5067619",
"0.50580436",
"0.50201815",
"0.50010294",
"0.49929175",
"0.49878052",
"0.49708432",
"0.4954112",
"0.49523896",
"0.49491084",
"0.49345988",
"0.49335435",
"0... | 0.6978419 | 0 |
PATCH/PUT /property_between_floor_slaps/1 PATCH/PUT /property_between_floor_slaps/1.json | def update
respond_to do |format|
if @property_between_floor_slap.update(property_between_floor_slap_params)
format.html { redirect_to @property_between_floor_slap , notice: 'Property between floor slap was successfully updated.' }
format.json { render :show, status: :ok, location: @property_between_floor_slap }
else
format.html { render :edit }
format.json { render json: @property_between_floor_slap.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_property_between_floor_slap\n @property_between_floor_slap = PropertyBetweenFloorSlap.find(params[:id])\n end",
"def update\n @floor = Floor.find(params[:id])\n params[:floor][:location_id] = params[:floor][:loc_id]\n params[:floor].delete :loc_id\n respond_to do |format|\n if @f... | [
"0.6611928",
"0.64026827",
"0.6253212",
"0.6180711",
"0.59178376",
"0.58830047",
"0.5867793",
"0.581085",
"0.5779907",
"0.57641405",
"0.5741139",
"0.57381433",
"0.56444305",
"0.5617428",
"0.5576063",
"0.5557531",
"0.5538262",
"0.55241364",
"0.551262",
"0.5512446",
"0.5505184"... | 0.69383144 | 0 |
DELETE /property_between_floor_slaps/1 DELETE /property_between_floor_slaps/1.json | def destroy
@property_between_floor_slap.destroy
respond_to do |format|
format.html { redirect_to property_between_floor_slaps_url, notice: 'Property between floor slap was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @floor_plan.destroy\n respond_to do |format|\n format.html { redirect_to location_path(@location) }\n format.json { head :no_content }\n end\n end",
"def destroy\n @floor = Floor.find(params[:id])\n @floor.destroy\n\n respond_to do |format|\n format.html { redirect... | [
"0.6767104",
"0.6629417",
"0.65859383",
"0.6548821",
"0.65027034",
"0.6496672",
"0.6478902",
"0.64782614",
"0.6418464",
"0.6389761",
"0.63772845",
"0.63682294",
"0.63654083",
"0.63643336",
"0.6358095",
"0.634887",
"0.6343281",
"0.6322753",
"0.6319015",
"0.63171756",
"0.630803... | 0.78118306 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_property_between_floor_slap
@property_between_floor_slap = PropertyBetweenFloorSlap.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.6165094",
"0.60450804",
"0.5944413",
"0.5915806",
"0.58885634",
"0.5835225",
"0.5775847",
"0.5700531",
"0.5700531",
"0.56543404",
"0.56209993",
"0.54238355",
"0.5410386",
"0.5410386",
"0.5410386",
"0.5394892",
"0.5377769",
"0.53559244",
"0.5339896",
"0.53388095",
"0.533008... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def property_between_floor_slap_params
params.require(:property_between_floor_slap).permit(:between_floor_slap_id, :property_id, :quality_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 |
saves Backer instance to all class variable | def save
self.class.all << self
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save\n self.class.save(self)\n end",
"def save\n @@all << self\n @@current << self\n end",
"def save!\n end",
"def save # save the instance to all\n @@all << self\n end",
"def save\n super save\n end",
"def save\n @@all << self\n end",
"def save\n @sav... | [
"0.6845503",
"0.67512846",
"0.6586266",
"0.6576874",
"0.656088",
"0.6484752",
"0.6478859",
"0.6467663",
"0.6466897",
"0.6466213",
"0.6458924",
"0.6458924",
"0.6458924",
"0.6458924",
"0.6458924",
"0.6458924",
"0.6458924",
"0.6458924",
"0.6438646",
"0.6400386",
"0.63979304",
... | 0.63020873 | 30 |
initializes ProjectBacker with the given project and self represents the relationship between given arguments | def back_project(project)
ProjectBacker.new(project, self)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize(project, backer) # takes in a project and a backer on initialization, accessible through an attribute reader \n @project = project\n @backer = backer\n @@all << self # stores the new instance of ProjectBacker in the @@all class variable\n end",
"def initialize(project, back... | [
"0.8448165",
"0.83274466",
"0.80026174",
"0.76844823",
"0.7049351",
"0.6912803",
"0.6855352",
"0.6848492",
"0.67650247",
"0.6757127",
"0.664558",
"0.66261196",
"0.6597131",
"0.6597131",
"0.6485619",
"0.6438077",
"0.6438077",
"0.6434818",
"0.6300408",
"0.62980866",
"0.62380385... | 0.76913834 | 4 |
Return all ProjectBacker objects associated with this backer | def project_backers
ProjectBacker.all.select do |projectbacker|
projectbacker.backer == self
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def backers\n # 2. using the array of projectBackers of self, create another array\n # of just the projects that those projectBackers reference\n self.project_backers.map { |pb_instance| pb_instance.backer }\n end",
"def backers\n # from those projectBackers, pull out the backers\n self.project_b... | [
"0.8512667",
"0.85015064",
"0.8492337",
"0.8425159",
"0.84197015",
"0.8414574",
"0.8365984",
"0.8309112",
"0.8215396",
"0.816752",
"0.80928695",
"0.7977554",
"0.79288846",
"0.7781661",
"0.77471024",
"0.76209307",
"0.7386665",
"0.7314135",
"0.71163714",
"0.6968477",
"0.6421876... | 0.7870026 | 13 |
Returns all Project objects associated with this backer | def backed_projects
self.project_backers.map do |projectbacker|
projectbacker.project
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def all\n @projects\n end",
"def all\n @projects\n end",
"def backed_projects\n self.projects.map {|back_project| back_project.project}\n end",
"def projects \n ProjectBacker.all.select {|project| project.backer == self}\n end",
"def projects\n PivotalTracker::Proje... | [
"0.7967018",
"0.7967018",
"0.7767808",
"0.7650023",
"0.76355",
"0.7597072",
"0.7594041",
"0.7529875",
"0.73503333",
"0.7340241",
"0.7286543",
"0.7274472",
"0.7220433",
"0.71822315",
"0.71686846",
"0.71537143",
"0.7083149",
"0.70614475",
"0.70041305",
"0.6965981",
"0.6945272",... | 0.7235962 | 12 |
Show contents of specific email | def show
@email = Email.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def body\n render text: fetch_email(params[:id]).body, content_type: 'text/html'\n end",
"def show_body\n I18n.with_locale @email_locale do\n @mail_body = mail_body(@preview, @part_type)\n render :show_body, layout: 'rails_email_preview/email'\n end\n end",
"def mail\n mail = MailTasks:... | [
"0.7092966",
"0.70180696",
"0.6938679",
"0.6808215",
"0.6807669",
"0.6782516",
"0.67396253",
"0.66930294",
"0.6521007",
"0.6489616",
"0.6475744",
"0.6475348",
"0.64712644",
"0.6452298",
"0.6423639",
"0.6414615",
"0.6389906",
"0.63884676",
"0.63853973",
"0.6374227",
"0.6332617... | 0.64256 | 14 |
Reader for field's value | def value
bindings[:object].send(name)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_field\n end",
"def value_read; end",
"def read\n value = record.send(\"#{name}_data\")\n value unless value.nil? || value.empty?\n end",
"def [](field_name)\n f = field(field_name)\n f && f.value\n end",
"def process_field_value(value)\r\n value\r\n end",... | [
"0.7273547",
"0.70294005",
"0.67918694",
"0.67404556",
"0.65841675",
"0.6344593",
"0.632313",
"0.63162744",
"0.6315854",
"0.6307784",
"0.62778014",
"0.6255537",
"0.6250033",
"0.62345195",
"0.6217381",
"0.6055541",
"0.6012342",
"0.6012229",
"0.6004448",
"0.5990767",
"0.5950257... | 0.0 | -1 |
Reader for field's value | def value
bindings[:object].send(name)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_field\n end",
"def value_read; end",
"def read\n value = record.send(\"#{name}_data\")\n value unless value.nil? || value.empty?\n end",
"def [](field_name)\n f = field(field_name)\n f && f.value\n end",
"def process_field_value(value)\r\n value\r\n end",... | [
"0.7275084",
"0.7029871",
"0.6794409",
"0.67397946",
"0.65828663",
"0.63447976",
"0.63250345",
"0.631679",
"0.63144624",
"0.63071734",
"0.62797993",
"0.6254796",
"0.6250294",
"0.6234026",
"0.6216726",
"0.6057279",
"0.6013759",
"0.60137326",
"0.6004446",
"0.59906214",
"0.59514... | 0.0 | -1 |
Reader for field's value | def value
bindings[:object].send(name)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_field\n end",
"def value_read; end",
"def read\n value = record.send(\"#{name}_data\")\n value unless value.nil? || value.empty?\n end",
"def [](field_name)\n f = field(field_name)\n f && f.value\n end",
"def process_field_value(value)\r\n value\r\n end",... | [
"0.7273547",
"0.70294005",
"0.67918694",
"0.67404556",
"0.65841675",
"0.6344593",
"0.632313",
"0.63162744",
"0.6315854",
"0.6307784",
"0.62778014",
"0.6255537",
"0.6250033",
"0.62345195",
"0.6217381",
"0.6055541",
"0.6012342",
"0.6012229",
"0.6004448",
"0.5990767",
"0.5950257... | 0.0 | -1 |
Unregisters the webhook with Jive | def unregister_webhook
require "open-uri"
require "net/http"
require "openssl"
return if self.add_on.nil? # Can't do it without a token!
return if self.oauth_token.nil? # Can't do it without a token!
uri = URI.parse("#{self.add_on.jive_url}/api/core/v3/webhooks/#{self.webhook_id}")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Delete.new(uri.request_uri)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer #{self.oauth_token.access_token}"
response = http.request(request)
# Need 2XX status code
if !response.code.to_i.between?(200, 299)
errors[:base] << "#{request.inspect} => #{response.body}"
return false
end
true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def unsubscribe_request_hook(name)\n EasyPost::Hooks.unsubscribe(:request, name)\n end",
"def delete_webhook(target_url)\n Uploadcare::Webhook.delete(target_url)\n end",
"def unsubscribe_response_hook(name)\n EasyPost::Hooks.unsubscribe(:response, name)\n end",
"def unregister... | [
"0.6840325",
"0.6647022",
"0.64943475",
"0.64802325",
"0.6425156",
"0.6414358",
"0.64120054",
"0.64065605",
"0.63679594",
"0.6276741",
"0.62552524",
"0.62387514",
"0.623862",
"0.62308806",
"0.61917335",
"0.6186117",
"0.6183866",
"0.6099072",
"0.60828346",
"0.6080911",
"0.6072... | 0.7900918 | 0 |
Registers the webhook with Jive | def register_webhook
require "open-uri"
require "net/http"
require "openssl"
uri = URI.parse("#{self.add_on.jive_url}/api/core/v3/webhooks")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
#http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Post.new(uri.request_uri)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer #{self.oauth_token.access_token}"
body = {
"callback" => self.callback,
"object" => self.object,
}
body["events"] = self.events if !self.events.to_s.empty?
request.body = body.to_json
response = http.request(request)
# Need 2XX status code
if !response.code.to_i.between?(200, 299)
errors[:base] << "#{request.inspect} => #{response.body}"
return false
end
json_body = JSON.parse(response.body)
self.webhook_id = json_body["id"]
true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_webhook(project_id_or_key, name, hook_url, params = {})\n params[:name] = name\n params[:hook_url] = hook_url\n post(\"projects/#{project_id_or_key}/webhooks\", params)\n end",
"def webhook\n @config = ZipMoney::Configuration \n @_webhook = ZipMoney::WebHook if @_webhoo... | [
"0.6617718",
"0.656444",
"0.65150595",
"0.64781016",
"0.64551556",
"0.6398318",
"0.63663626",
"0.63569754",
"0.63287765",
"0.63153994",
"0.6296852",
"0.6244124",
"0.62091345",
"0.61630535",
"0.6134478",
"0.61271334",
"0.6125525",
"0.6123998",
"0.6104226",
"0.6083307",
"0.6076... | 0.8315143 | 0 |
angular using only: index, create | def index
defaults = (@project.construction_default.present?) ? [@project.construction_default] : []
respond_with(defaults)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n create\n end",
"def new\n index\n end",
"def index\n new\n end",
"def index\n create\n render action: :create\n end",
"def index\n @creates = Create.all\n end",
"def index; end",
"def index; end",
"def index; end",
"def index; end",
"def index; end",
"def inde... | [
"0.73265076",
"0.6820173",
"0.6668644",
"0.6653575",
"0.65715",
"0.63550186",
"0.63550186",
"0.63550186",
"0.63550186",
"0.63550186",
"0.63550186",
"0.63550186",
"0.63550186",
"0.63550186",
"0.63550186",
"0.63550186",
"0.63550186",
"0.63550186",
"0.63550186",
"0.63550186",
"0... | 0.0 | -1 |
Write a method that computes the difference between the square of the sum of the first n positive integers and the sum of the squares of the first n positive integers. Examples: | def sum_square_difference(n)
n_integers = (1..n).to_a
square_of_sum = n_integers.inject(:+)**2
sum_of_squares = n_integers.map {|n|n**2}.inject(:+)
square_of_sum - sum_of_squares
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sum_square_difference(n)\n integers = (1..n).to_a\n\n square_of_sum = integers.sum ** 2\n sum_of_squares = integers.map { |n| n ** 2 }.sum\n\n square_of_sum - sum_of_squares\nend",
"def sum_square_difference(n)\n ((1..n).reduce(:+)**2) - (1..n).reduce{ |sum, i| sum + i**2 }\nend",
"def sum_square_dif... | [
"0.8546487",
"0.8521754",
"0.8498327",
"0.84734714",
"0.845629",
"0.84002894",
"0.8385255",
"0.83743644",
"0.83242947",
"0.82743055",
"0.8273235",
"0.8097696",
"0.80192274",
"0.7929161",
"0.78133136",
"0.7796826",
"0.7733372",
"0.7713581",
"0.7708296",
"0.7690414",
"0.7682316... | 0.85008293 | 2 |
Returns array of items from the search_result | def results
raise NotImplementedError
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def results_from_search(query_results)\n ids = query_results.map do |result|\n result['id']\n end\n find_from_search(*ids)\n end",
"def results\n numOfSearches = numEvents / @OFFSET #the number of searches we must make to return all values\n result = Arr... | [
"0.72065085",
"0.7196961",
"0.69212794",
"0.6906977",
"0.6892322",
"0.680267",
"0.67759824",
"0.67704743",
"0.6734717",
"0.67287344",
"0.6688951",
"0.6667835",
"0.66037166",
"0.6577004",
"0.64987475",
"0.6496369",
"0.64909303",
"0.6435062",
"0.63871735",
"0.6367216",
"0.63516... | 0.0 | -1 |
GET /profesores GET /profesores.json | def index
@profesores = Profesore.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @profesore = Profesore.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @profesore }\n end\n end",
"def index\n @profesors = Profesor.all\n # if @profesors!= nil\n#render json: @profesors\n#else\n# @profesors= '{\"exito\",... | [
"0.69867605",
"0.66545045",
"0.6432097",
"0.6286862",
"0.61497325",
"0.6138691",
"0.6107574",
"0.60884714",
"0.60807925",
"0.6051749",
"0.6035779",
"0.60297316",
"0.60257673",
"0.6005934",
"0.6001218",
"0.5982145",
"0.5970275",
"0.5970275",
"0.5961725",
"0.5950382",
"0.592898... | 0.6623992 | 2 |
GET /profesores/1 GET /profesores/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @profesore = Profesore.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @profesore }\n end\n end",
"def show\n @proficiency = Proficiency.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n ... | [
"0.7174125",
"0.6799708",
"0.6617429",
"0.65384585",
"0.63686675",
"0.63504875",
"0.6331206",
"0.6256576",
"0.62244624",
"0.6223824",
"0.61442184",
"0.61442184",
"0.613235",
"0.611163",
"0.61063224",
"0.61063224",
"0.61063224",
"0.6099474",
"0.60792935",
"0.60792935",
"0.6064... | 0.0 | -1 |
POST /profesores POST /profesores.json | def create
@profesore = Profesore.new(profesore_params)
respond_to do |format|
if @profesore.save
format.html { redirect_to @profesore, notice: 'Profesore was successfully created.' }
format.json { render :show, status: :created, location: @profesore }
else
format.html { render :new }
format.json { render json: @profesore.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @profesor = Profesor.new(profesor_params)\n\n if @profesor.save\n render json: @profesor, status: :created, location: @profesor\n else\n render json: @profesor.errors, status: :unprocessable_entity\n end\n end",
"def create\n @prof = Prof.new(prof_params)\n\n respond_to ... | [
"0.736268",
"0.6978027",
"0.6969686",
"0.6839492",
"0.68077594",
"0.6781387",
"0.6726943",
"0.6448134",
"0.6400282",
"0.6335833",
"0.63357866",
"0.62787294",
"0.62787294",
"0.6252644",
"0.6141328",
"0.6139076",
"0.6131122",
"0.60647273",
"0.6055458",
"0.60545486",
"0.6028342"... | 0.6744405 | 6 |
PATCH/PUT /profesores/1 PATCH/PUT /profesores/1.json | def update
respond_to do |format|
if @profesore.update(profesore_params)
format.html { redirect_to @profesore, notice: 'Profesore was successfully updated.' }
format.json { render :show, status: :ok, location: @profesore }
else
format.html { render :edit }
format.json { render json: @profesore.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @profesor = Profesor.find(params[:id])\n\n if @profesor.update(profesor_params)\n head :no_content\n else\n render json: @profesor.errors, status: :unprocessable_entity\n end\n end",
"def update\n @profesore = Profesore.find(params[:id])\n\n respond_to do |format|\n ... | [
"0.7306273",
"0.71561486",
"0.71470904",
"0.7043676",
"0.69982314",
"0.66852075",
"0.6683979",
"0.66494066",
"0.66437566",
"0.6633193",
"0.65943795",
"0.652536",
"0.6429707",
"0.64292014",
"0.64255553",
"0.640166",
"0.63983846",
"0.6380514",
"0.63465506",
"0.63442314",
"0.633... | 0.6981697 | 5 |
DELETE /profesores/1 DELETE /profesores/1.json | def destroy
@profesore.destroy
respond_to do |format|
format.html { redirect_to profesores_url, notice: 'Profesore was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @profesore = Profesore.find(params[:id])\n @profesore.destroy\n\n respond_to do |format|\n format.html { redirect_to profesores_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @prof.destroy\n respond_to do |format|\n format.html { redirect_to ... | [
"0.7433161",
"0.734054",
"0.7257294",
"0.7139833",
"0.70677567",
"0.70207715",
"0.6969561",
"0.69410104",
"0.69283",
"0.692763",
"0.6902504",
"0.6772318",
"0.6772318",
"0.6770505",
"0.6766542",
"0.67514807",
"0.67389476",
"0.6692243",
"0.6692243",
"0.6561049",
"0.6557639",
... | 0.72385556 | 3 |
Use callbacks to share common setup or constraints between actions. | def set_profesore
@profesore = Profesore.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.6165094",
"0.60450804",
"0.5944413",
"0.5915806",
"0.58885634",
"0.5835225",
"0.5775847",
"0.5700531",
"0.5700531",
"0.56543404",
"0.56209993",
"0.54238355",
"0.5410386",
"0.5410386",
"0.5410386",
"0.5394892",
"0.5377769",
"0.53559244",
"0.5339896",
"0.53388095",
"0.533008... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def profesore_params
params.require(:profesore).permit(:rut, :nombre, :apellido_paterno, :apellido_materno, :correo, :descripcion, :usuario_id, :estado)
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 |
Refresh one feed source and return the updated feed items | def refresh
FeedSource.find(params[:feed_source_id]).refresh
feed_sources = params[:feed_sources]
@feed_source_titles = {}
FeedSource.find(feed_sources).each { |source| @feed_source_titles[source.id] = source.title}
@feed_items = FeedItem.where("feed_source_id IN (?)", feed_sources).order(pub_date: :desc).limit(20).offset(0)
@feed_items = @feed_items.sort_by{ |item| item.pub_date.to_i }.reverse
render :index
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def refresh_feed(feed)\n FeedRefreshManager.refresh feed, self\n end",
"def refresh\n Feed.update_all\n # @feeds = Feed.all\n # feed_array = []\n # @feeds.each do |f|\n # EntryFeed.create_from_feed(f)\n # end\n\n redirect_to blogs_path\n flash[:notice] = \"Blogs successfully updated... | [
"0.73419046",
"0.6547046",
"0.6506305",
"0.6465421",
"0.64161277",
"0.6409836",
"0.6389569",
"0.6370014",
"0.63508123",
"0.63415533",
"0.6319646",
"0.6308639",
"0.6308639",
"0.6303377",
"0.62841046",
"0.62739736",
"0.6230807",
"0.6220272",
"0.6220272",
"0.6210587",
"0.6197166... | 0.82401633 | 0 |
Store page title options that are used on I18n interpolation. | def page_title_options
@page_title_options ||= {}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def title=(t)\n @options[:title] = t\n end",
"def page_title(options = {})\n return \"\" if @page.title.blank?\n\n options = {\n prefix: \"\",\n suffix: \"\",\n separator: \"\"\n }.update(options)\n title_parts = [options[:prefix]]\n title_parts << if respons... | [
"0.731271",
"0.73069143",
"0.7233398",
"0.72106487",
"0.716158",
"0.7127059",
"0.709165",
"0.7079146",
"0.7051273",
"0.7026661",
"0.69825894",
"0.6956374",
"0.68932176",
"0.6877517",
"0.68723416",
"0.6852441",
"0.68501896",
"0.68482125",
"0.6831096",
"0.67903167",
"0.6788046"... | 0.84882396 | 0 |
GET /results GET /results.json | def index
@results = Result.all
@results = Result.paginate(:per_page => 15, :page => params[:page])
respond_to do |format|
format.html # index.html.erb
format.json { render json: @results }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def results(path, params = {}, opts = {})\n get(path, params, opts)['results']\n end",
"def results\n with_monitoring do\n response = perform(:get, results_url, query_params)\n Search::ResultsResponse.from(response)\n end\n rescue => e\n handle_error(e)\n end",
"def index... | [
"0.76288646",
"0.74009883",
"0.73304945",
"0.7310312",
"0.71980476",
"0.7026232",
"0.7026232",
"0.70244294",
"0.69998676",
"0.6964366",
"0.69346374",
"0.69158345",
"0.6851679",
"0.6832736",
"0.67981136",
"0.67470914",
"0.6732289",
"0.67216444",
"0.6684441",
"0.66760254",
"0.6... | 0.7303821 | 4 |
GET /results/1 GET /results/1.json | def show
@result = Result.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @result }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def results(path, params = {}, opts = {})\n get(path, params, opts)['results']\n end",
"def index\n get_results\n end",
"def get_results\n\t\trace_id = params[:id]\n\t\t\n\t\trace = Race.find_by_id(race_id)\n\t\tresults = Result.get_race_results(race_id)\n\t\t\n\t\trender :json=>{:results=>results}\n\t... | [
"0.73266965",
"0.6979273",
"0.69192237",
"0.6817701",
"0.67208",
"0.6713047",
"0.6713047",
"0.66786873",
"0.66508305",
"0.6609092",
"0.66036445",
"0.65753514",
"0.6566137",
"0.64380974",
"0.6395807",
"0.63874984",
"0.63825446",
"0.63717514",
"0.6371065",
"0.6341115",
"0.63237... | 0.66351783 | 12 |
GET /results/new GET /results/new.json | def new
@result = Result.new
@available_states = State.all
@root = EventType.find(2)
@add_event_types = @result.event_types
respond_to do |format|
format.html # new.html.erb
format.json { render json: @result }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @result = Result.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @result }\n end\n end",
"def new\n @result = Result.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @result }\n e... | [
"0.74078584",
"0.7372339",
"0.7372339",
"0.7372339",
"0.7372339",
"0.6973376",
"0.6833356",
"0.68223387",
"0.68223387",
"0.68223387",
"0.68223387",
"0.68223387",
"0.68056065",
"0.67874837",
"0.6748261",
"0.6664652",
"0.6639047",
"0.6626612",
"0.66118544",
"0.6591056",
"0.6588... | 0.67580503 | 14 |
POST /results POST /results.json | def create
@result = Result.new
@result.name = params[:name]
if params[:type] == "Statuswechsel"
@result.type = "ResultStateChange"
if params[:selected_state] != nil && params[:selected_state] != ""
@state = State.find(params[:selected_state])
@result.state = @state
end
end
if params[:type] == "Ereignistypen Menge aendern"
@result.type = "ResultChangeEventTypeAmount"
if params[:event_type_operator] != nil && params[:event_type_operator] != ""
@result.event_type_operator = params[:event_type_operator]
if (params[:event_type_operator]) == "Zur Menge Hinzufuegen" || (params[:event_type_operator]) == "Aus Menge entfernen"
if params[:add_event_types] != nil
params[:add_event_types].each do |f|
@event_type = EventType.find(f)
@result.event_types << @event_type
end
end
end
end
end
if params[:info] != nil && (params[:type]) == "Info"
@result.type = "ResultInfo"
@result.info = params[:info]
end
if params[:type] == "Client Sperren"
@result.type = "ResultLock"
end
respond_to do |format|
if @result.save
format.html { redirect_to @result, notice: 'Ergebnis wurde erfolgreich erzeugt' }
format.json { render json: @result, status: :created, location: @result }
else
self.reload_edit_params
format.html { render "new" } #redirect_to new_result_path
format.json { render json: @result.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def post\n Typhoeus.post(@url,\n body: @results_hash.to_json,\n headers: { 'Content-Type' => 'application/json' })\n end",
"def create\n #TODO we need to look into the need for transactions in mongodb\n #Api::V1::Result.with_session do |session|\n #session.start_t... | [
"0.79618156",
"0.70347315",
"0.6430695",
"0.6363882",
"0.62522346",
"0.6239741",
"0.60929143",
"0.60929143",
"0.60773784",
"0.6060322",
"0.6051018",
"0.60151786",
"0.59909177",
"0.5975458",
"0.59725726",
"0.59725726",
"0.59725726",
"0.59665865",
"0.5965483",
"0.5954307",
"0.5... | 0.0 | -1 |
PUT /results/1 PUT /results/1.json | def update
@result = Result.find(params[:id])
@result.name = params[:name]
if params[:type] == "Statuswechsel"
@result.type = "ResultStateChange"
clear_entity
if params[:selected_state] != nil && params[:selected_state] != ""
@state = State.find(params[:selected_state])
@result.state = @state
end
end
if params[:type] == "Ereignistypen Menge aendern"
@result.type = "ResultChangeEventTypeAmount"
clear_entity
if params[:event_type_operator] != nil && params[:event_type_operator] != ""
@result.event_type_operator = params[:event_type_operator]
if (params[:event_type_operator]) == "Zur Menge Hinzufuegen" || (params[:event_type_operator]) == "Aus Menge entfernen"
if params[:add_event_types] != nil
params[:add_event_types].each do |f|
@event_type = EventType.find(f)
@result.event_types << @event_type
end
end
end
end
end
if params[:info] != nil && (params[:type]) == "Info"
@result.type = "ResultInfo"
clear_entity
@result.info = params[:info]
end
if params[:type] == "Client Sperren"
@result.type = "ResultLock"
clear_entity
end
respond_to do |format|
if @result.save
format.html { redirect_to @result, notice: 'Ergebnis wurde erfolgreich aktualisiert' }
format.json { head :no_content }
else
self.reload_edit_params
format.html { render "edit" }
format.json { render json: @result.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update!(**args)\n @results = args[:results] if args.key?(:results)\n end",
"def update!(**args)\n @results = args[:results] if args.key?(:results)\n end",
"def update\n @result = Result.find(params[:id])\n\n respond_to do |format|\n if @result.update_attributes(pa... | [
"0.6671565",
"0.6671565",
"0.6349844",
"0.6349844",
"0.6349844",
"0.6349844",
"0.6249474",
"0.61575747",
"0.61567533",
"0.6106437",
"0.6044483",
"0.6044483",
"0.6044483",
"0.6042009",
"0.6038036",
"0.60364544",
"0.60364544",
"0.5991131",
"0.5977438",
"0.5950011",
"0.59433126"... | 0.0 | -1 |
DELETE /results/1 DELETE /results/1.json | def destroy
@result = Result.find(params[:id])
@result.destroy
respond_to do |format|
format.html { redirect_to results_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @result.destroy\n\n respond_to do |format|\n format.html { redirect_to results_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @result1 = Result1.find(params[:id])\n @result1.destroy\n\n respond_to do |format|\n format.html { redirect_to resul... | [
"0.742324",
"0.73952013",
"0.7390635",
"0.7390635",
"0.71886176",
"0.71886176",
"0.71886176",
"0.71168256",
"0.70458597",
"0.7039028",
"0.7039028",
"0.7039028",
"0.6968855",
"0.6961157",
"0.69093835",
"0.69002604",
"0.6883082",
"0.6869606",
"0.68522197",
"0.68450713",
"0.6830... | 0.7415624 | 5 |
Method descriptions cells Returns a nested array of Brewfish::Internal::Cell instances configured to the dimensions of the Console instance tileset Returns a Brewfish::Tileset instance configured with the settings specified during initialization of the Console instance width Returns the pixel width of the Console instance height Returns the pixel height of the Console instance rows Returns the number of cell rows addressable by the Console instance cols Returns the number of cell columns addressable by the Console instance button_down? Return boolean indicating whether a given button id is being held down; only valid within the context of game_loop keyboard_map Returns a hash mapping keyboard button codes to their button ids for use in button_down?; numerical codes may differ based on keyboard layouts, implementations, etc Instance Methods | def initialize( options = {} )
# Default to Gosu rendered console
options[:type] ||= :gosu
case options[:type]
when :gosu
options[:callback_target] = self
@console_delegate = Internal::GosuConsole.new( options )
else
# TODO: Custome Brewfish error type here -- Thu Jan 26 21:35:41 2012
raise "Unsupported Console type: #{options[:type]}"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def button_down(id)\n if id == Gosu::KbEscape || id == Gosu::KbQ\n save\n close\n elsif id == Gosu::KbA\n @current_type = :terrain\n elsif id == Gosu::KbS\n @current_type = :enemies\n elsif id == Gosu::KbD\n @current_type = :candies\n elsif id == Gosu::KbLeft || id == Gosu::... | [
"0.5801726",
"0.5780867",
"0.5749513",
"0.56723183",
"0.549728",
"0.538721",
"0.5328305",
"0.52946013",
"0.52397746",
"0.523253",
"0.5178944",
"0.51389897",
"0.51240396",
"0.51164967",
"0.5088872",
"0.5026192",
"0.50200725",
"0.5017379",
"0.50160444",
"0.50158507",
"0.4999423... | 0.0 | -1 |
Override in the subclass to provide a place to do initialization of game logic, load files, set up state, etc | def game_setup
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize()\n @tileset = Gosu::Image.load_tiles(\"media/tileset.png\", TILE_WIDTH, TILE_HEIGHT, tileable: true)\n\n # Load images here so they will only be loaded once per game\n @enemyAnimation = *Gosu::Image.load_tiles(\"media/enemy_char.png\", Enemy::WIDTH, Enemy::HEIGHT)\n @por... | [
"0.7197501",
"0.6927094",
"0.68548703",
"0.68363637",
"0.67903966",
"0.6709493",
"0.6681035",
"0.66754824",
"0.6657464",
"0.6593433",
"0.6593433",
"0.6568565",
"0.6536359",
"0.6532853",
"0.65298796",
"0.6522084",
"0.6518121",
"0.6491702",
"0.64911246",
"0.64601445",
"0.646014... | 0.7465463 | 0 |
Called every update interval while the console is being shown | def game_loop
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_screen(output)\n if output != $last_update\n clear_screen\n puts(output)\n end\nend",
"def update\n return if @destoryed\n super\n #---------------------------------------------------------\n # debug information:\n unless DEBUG_PRINT_WAIT.nil?\n if @time_between_debug_print... | [
"0.6738439",
"0.6426053",
"0.6280463",
"0.6244588",
"0.61609226",
"0.6086194",
"0.6071217",
"0.6012852",
"0.599135",
"0.59864616",
"0.597321",
"0.5950648",
"0.5945575",
"0.5940598",
"0.5927845",
"0.584486",
"0.58150864",
"0.577988",
"0.5778276",
"0.5767212",
"0.5765037",
"0... | 0.0 | -1 |
Called on an instance of the subclass, this will run the game_setup method and then begin the show loop on the delegate | def game_start
game_setup
@console_delegate.show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def game_setup\n end",
"def start\n DataManager.create_game_objects\n $game_party.setup_starting_members\n $game_map.setup(Config::Starting_Map_ID)\n $game_player.moveto(Config::X_Pos, Config::Y_Pos)\n $game_player.followers.visible = false\n $game_player.refresh\n $game_player.make_encou... | [
"0.68360984",
"0.6639908",
"0.6451325",
"0.62993324",
"0.61970586",
"0.6163759",
"0.6157443",
"0.6131971",
"0.6095512",
"0.6061154",
"0.6006015",
"0.60039425",
"0.5999125",
"0.5988099",
"0.5987031",
"0.59720844",
"0.59613466",
"0.59466904",
"0.5942263",
"0.59374255",
"0.59353... | 0.77794194 | 0 |
Calling this method cause the game window to stop rendering and close | def game_close
@console_delegate.close
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def close_game\r\n $window.close\r\n end",
"def close\n @window.destroy if @window\n VER::stop_ncurses\n end",
"def quit_command()\n @subSceneScan.hide_windows()\n @target_enemy_window.active = true\n end",
"def exit\n @window.pause = true\n @window.close\n end",
"def new... | [
"0.7248885",
"0.7152591",
"0.7067125",
"0.7001458",
"0.6953493",
"0.6791762",
"0.6774483",
"0.671602",
"0.6700217",
"0.6667256",
"0.6641483",
"0.6640057",
"0.6631214",
"0.66063243",
"0.65814114",
"0.6562784",
"0.65586424",
"0.6557892",
"0.65463716",
"0.65423113",
"0.6536912",... | 0.6174471 | 41 |
Override in the subclass in order to handle single button presses, called before game_loop; keyboard_map provides a map between keyboard_code => button_id | def on_button_down( button_id )
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pressed?() sdl_event.press end",
"def button_down(key)\n end",
"def input_button\r\n n = 0\r\n LiteRGSS2RGSS_Input.each do |key, i|\r\n n = i if Input.trigger?(key)\r\n end\r\n if n > 0\r\n $game_variables[@button_input_variable_id] = n\r\n $game_map.need_refresh = true\r\n ... | [
"0.6638239",
"0.6602832",
"0.6585344",
"0.6490322",
"0.6445961",
"0.63370883",
"0.6271538",
"0.6268035",
"0.62628454",
"0.6252203",
"0.6236943",
"0.6228796",
"0.6176521",
"0.6141354",
"0.6132879",
"0.6113606",
"0.6103785",
"0.61017424",
"0.6076202",
"0.6075147",
"0.6069541",
... | 0.5949351 | 26 |
Never trust parameters from the scary internet, only allow the white list through. | def additional_packet_params
params.require(:additional_packet).permit(:content, :price)
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.6981537",
"0.67835593",
"0.6748275",
"0.67436063",
"0.6736311",
"0.65937173",
"0.6503359",
"0.6498499",
"0.6482832",
"0.6478776",
"0.645703",
"0.6439998",
"0.63802195",
"0.6377008",
"0.6366287",
"0.632018",
"0.63016284",
"0.63011277",
"0.62932974",
"0.62919617",
"0.6290564... | 0.0 | -1 |
I worked on this challenge [by myself, with: ]. count_between is a method with three arguments: 1. An array of integers 2. An integer lower bound 3. An integer upper bound It returns the number of integers in the array between the lower and upper bounds, including (potentially) those bounds. If +array+ is empty the method should return 0 Your Solution Below Pesudocode define a method that has three arguments 1. An array of integers 2. An integer lower bound 3. An integer upper bound This will return the numbers that are between the lower and upper bound and if the array is empty it will return 0 =begin def count_between(list_of_integers, lower_bound, upper_bound) x = 2 if x >= lower_bound && x <= upper_bound p x else p 0 end end =end REFACTOR USING RUBY METHOD | def count_between(list_of_integers, lower_bound, upper_bound)
list_of_integers.count {|x| x>= lower_bound && x <= upper_bound}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def count_between(list_of_integers, lower_bound, upper_bound)\n if list_of_integers == []\n return 0\nelsif upper_bound < lower_bound\n return 0\nend\n# sum = 0\n# sum = list_of_integers[lower_bound..upper_bound].each\n# for integer in lower_bound..upper_bound\n# p integer\n# if list_of_integers.each >= lower_... | [
"0.8824842",
"0.8799786",
"0.8719823",
"0.8707406",
"0.86933243",
"0.8603774",
"0.8582064",
"0.8554849",
"0.85482943",
"0.85303205",
"0.8529982",
"0.85137075",
"0.84885913",
"0.84025383",
"0.83743644",
"0.83329076",
"0.83190405",
"0.8318204",
"0.8317177",
"0.8241471",
"0.7934... | 0.82633716 | 19 |
Gets the chat property value. The chat between the user and Teams app. | def chat
return @chat
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def chat_info\n return @chat_info\n end",
"def chat\n @_chat || payload && payload['chat']\n end",
"def chat=(value)\n @chat = value\n end",
"def chat\n @_chat ||=\n if payload\n if payload.is_a?(Hash)\n p... | [
"0.71748775",
"0.7054701",
"0.7045065",
"0.7031462",
"0.7023305",
"0.7023305",
"0.67733926",
"0.6639497",
"0.6575313",
"0.6302959",
"0.6302959",
"0.6287643",
"0.5960013",
"0.5855995",
"0.5847797",
"0.58272797",
"0.57949525",
"0.57499456",
"0.57348585",
"0.57348585",
"0.571157... | 0.7338721 | 0 |
Sets the chat property value. The chat between the user and Teams app. | def chat=(value)
@chat = value
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_chat\n @chat = Chat.get_one(params[:app_token], params[:number])\n end",
"def set_chat\n @chat = @application.chats.find_by!(number: params[:id])\n end",
"def set_chat\n @chat = Chat.find(params[:id])\n end",
"def set_chat\n @chat = Chat.find(params[:id])\n end",
"def se... | [
"0.75856173",
"0.7266743",
"0.7255754",
"0.7255754",
"0.7255754",
"0.7255754",
"0.7255754",
"0.7255754",
"0.7255754",
"0.7255754",
"0.7255754",
"0.7255754",
"0.7255754",
"0.71931034",
"0.7139131",
"0.7139131",
"0.7018493",
"0.6961826",
"0.67970365",
"0.6774398",
"0.66801286",... | 0.8534229 | 0 |
Instantiates a new userScopeTeamsAppInstallation and sets the default values. | def initialize()
super
@odata_type = "#microsoft.graph.userScopeTeamsAppInstallation"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def installed_apps()\n return MicrosoftGraph::Me::JoinedTeams::Item::InstalledApps::InstalledAppsRequestBuilder.new(@path_parameters, @request_adapter)\n end",
"def initialize\n @initted = false\n @h_steam_user = @@dll_SteamAPI_GetHSteamUser.call\n return if (@s... | [
"0.54527813",
"0.52849585",
"0.5226986",
"0.51630723",
"0.51314735",
"0.5057966",
"0.50249255",
"0.5002965",
"0.50024647",
"0.49959233",
"0.4945063",
"0.4878081",
"0.48780555",
"0.48567334",
"0.48553476",
"0.48341924",
"0.48106268",
"0.48098832",
"0.47992164",
"0.479649",
"0.... | 0.74524724 | 0 |
The deserialization information for the current model | def get_field_deserializers()
return super.merge({
"chat" => lambda {|n| @chat = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::Chat.create_from_discriminator_value(pn) }) },
})
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def deserialized\n @deserialized ||= @serializer.deserialize @serialized_object\n end",
"def get_field_deserializers()\n return super.merge({\n \"detectionStatus\" => lambda {|n| @detection_status = n.get_enum_value(MicrosoftGraph::Models::SecurityDetectionStatus) },... | [
"0.6510734",
"0.63224316",
"0.6322254",
"0.63094735",
"0.62954384",
"0.6238735",
"0.6232461",
"0.62155676",
"0.6200175",
"0.6199403",
"0.6173917",
"0.61733985",
"0.61705345",
"0.61631054",
"0.61620396",
"0.6158031",
"0.6156071",
"0.6142402",
"0.613998",
"0.6138061",
"0.612005... | 0.0 | -1 |
Serializes information the current object | def serialize(writer)
raise StandardError, 'writer cannot be null' if writer.nil?
super
writer.write_object_value("chat", @chat)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def serialize\n end",
"def serialize(object) end",
"def serialize; end",
"def serialize; end",
"def serialize\n \n end",
"def serialize\n raise NotImplementedError\n end",
"def serialize\n raise NotImplementedError\n end",
"def dump\r\n super + to_s\r\n end",
... | [
"0.7951372",
"0.7645999",
"0.7579812",
"0.7579812",
"0.7440032",
"0.720861",
"0.720861",
"0.7207583",
"0.7016516",
"0.70007193",
"0.6992252",
"0.69838214",
"0.69723576",
"0.69666415",
"0.69666415",
"0.6942002",
"0.69417155",
"0.6933786",
"0.6913977",
"0.6891677",
"0.68810964"... | 0.0 | -1 |
begins the game, alternating turns and making sure each option is a valid choice, then displays the board | def play
while true
current_player.en_passant = false
board.formatted_grid
if check_for_check
if check_for_checkmate
puts "Checkmate!"
else
puts "Check!"
end
end
x, y = prompt_selection
puts ""
puts ask_move
x_end, y_end = get_move
if x_end == "back"
board.clear_board
play
end
while board.valid_place?(x_end, y_end) == false
puts "Invalid option! Try again:"
x_end, y_end = get_move
board.valid_place?(x_end, y_end)
end
#check for en passant
if board.get_cell_piece(x, y).type == "pawn" && y_end - y == 2
current_player.en_passant = true
elsif board.get_cell_piece(x, y).type == "pawn" && y - y_end == 2
current_player.en_passant = true
end
#check for promotion
if board.get_cell_piece(x, y).type == "pawn" && board.get_cell_piece(x, y).color == "white" && y_end == 0
promote(x, y)
elsif board.get_cell_piece(x, y).type == "pawn" && board.get_cell_piece(x, y).color == "black" && y_end == 7
promote(x, y)
end
#check for castling
if board.get_cell_piece(x, y).type == "king" && x_end - x == 2
board.piece_move(x + 3, y, x + 1, y)
board.set_cell_color(x + 2, y, "red")
elsif board.get_cell_piece(x, y).type == "king" && x - x_end == 2
board.piece_move(x - 4, y, x - 1, y)
board.set_cell_color(x - 2, y, "red")
end
#check if taking an opponent's piece
if is_taking_piece?(x_end, y_end)
hash_value = other_player.pieces_left.key([x_end, y_end])
current_player.pieces_left[hash_value] = [x_end, y_end]
other_player.pieces_left.delete(hash_value)
board.piece_move(x, y, x_end, y_end)
else
hash_value = current_player.pieces_left.key([x, y])
current_player.pieces_left[hash_value] = [x_end, y_end]
board.piece_move(x, y, x_end, y_end)
end
#if board.game_over
#puts game_over_message
#board.formatted_grid
#return
#else
switch_players
#end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def play\n winner = false\n while(!winner)\n puts \"please input a row of four colors\"\n puts \"your options are B: for black, b: for blue\"\n puts \"g: green, y: yellow, r: red , w: white\"\n @grid.board\n input = []\n (4).times { input << gets.... | [
"0.7186195",
"0.7076107",
"0.70755607",
"0.707066",
"0.70684546",
"0.7056037",
"0.7018",
"0.6992578",
"0.6991273",
"0.6918398",
"0.69019485",
"0.68982655",
"0.6840322",
"0.6835676",
"0.6808182",
"0.6804411",
"0.678638",
"0.6776162",
"0.677073",
"0.67694277",
"0.67683727",
"... | 0.6932986 | 9 |
def each counter = 0 while counter < size yield(item_at(counter)) counter += 1 end self end | def each
@todos.each do |todo|
yield(todo)
end
self
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def each\n 0.upto(item_count - 1) { | i | yield i }\n end",
"def each()\n i = 0\n while i < @total\n yield at(i)\n i += 1\n end\n self\n end",
"def each\n @size.times do |i|\n yield self[i]\n end\n end",
"def each(&block)\n @size.times { |position| yield self[positio... | [
"0.83711296",
"0.8343442",
"0.81811726",
"0.81114745",
"0.8110655",
"0.8041984",
"0.80414915",
"0.80196404",
"0.80196404",
"0.80196404",
"0.78144145",
"0.7655457",
"0.76375073",
"0.7622876",
"0.7592916",
"0.7476852",
"0.7449554",
"0.740364",
"0.7391068",
"0.733202",
"0.730778... | 0.0 | -1 |
def select counter = 0 selected = [] while counter < self.size item = item_at(counter) selected << item if yield(item) counter += 1 end selected end def select | def select
new_list = TodoList.new("Selected Items")
each do |todo|
new_list.add(todo) if yield(todo)
end
new_list
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def my_select\n i = 0\n result = []\n self.my_each do |x|\n if yield(x)\n result[i] = x\n i += 1\n end\n end\n return result\n end",
"def my_select\n result = []\n i = 0\n while i < self.to_a.length\n if yield self.to_a[i] \n result << self.to_a[i... | [
"0.78333724",
"0.7656714",
"0.74749136",
"0.7465597",
"0.7375105",
"0.7368831",
"0.73671216",
"0.7361724",
"0.7281646",
"0.7267998",
"0.7226581",
"0.71985614",
"0.71862906",
"0.71840125",
"0.7170346",
"0.7160385",
"0.71523285",
"0.7138043",
"0.71304107",
"0.7115363",
"0.70727... | 0.63060445 | 54 |
Kill off the ability for recursive conversion | def deep_update(other_hash)
other_hash.each_pair do |k,v|
key = convert_key(k)
regular_writer(key, convert_value(v, true))
end
self
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def convert!; end",
"def recursive => nil",
"def convert(tree, options = T.unsafe(nil)); end",
"def normalize!; end",
"def convert\n end",
"def convert\n end",
"def stop_casting(name); end",
"def shouldConvert()\n\t\tfalse\n\tend",
"def normalizer; end",
"def shouldConvert\n false\n ... | [
"0.6794795",
"0.6213863",
"0.578648",
"0.56332576",
"0.5609805",
"0.5609805",
"0.5574148",
"0.5563094",
"0.5555391",
"0.54968554",
"0.54897976",
"0.54874873",
"0.54529744",
"0.5439778",
"0.5401186",
"0.53278136",
"0.53083485",
"0.5303176",
"0.52817994",
"0.5265869",
"0.521711... | 0.0 | -1 |
las variables fuera de las clases van con $ sin signo las variables son locales | def MostrarMenu()
puts "Bienvenido a la calculadora"
puts "Por favor seleccion el calculo que desea hacer"
@opcion
hola = "hola" << " y chau"
#print hola
# hola.each_char{|c| print c
#print "letra\n"
#todo lo que va a aca es parte del each, se puede agregar codigo
#con \n hago el salto d linea
#}
#hola = hola.center(40)
#print hola #la funcion center lo que hace
#es extender la cantidad de caracteres de un string. si tiene menos queda igual, si tiene mas lo que hace es agregar espacios al rededor. Se lepuede agregar un texto para que aparezca a los costados
hola = hola.center(20, "-----")
print hola << "\n"
nro = 12
if nro > 20
#puts "es otra forma de imprimir texto"
else
puts "pasa por else"
end
if not nro > 20
puts "para negar se utiliza la palabra not"
puts "para and se utiliza la palabra and"
#nro1 == 1 and nro2 == 2
#tambien se puede usar unless que es lo mismo que if not
puts "para or se utiliza la palabra or"
#nro1 == 1 or nro2 == 2
end
#ciclo for
for i in (1..10)
puts i
#el puts imprime el salto de linea
#next es el break
#para repetir se puede usar redo
if i == 2
# redo
end
end
puts *(1..10)
#esto va a imprimir del i al 10
#operador when es similar al switch case
edad = 2
case edad
when 0..11 then print "esta entre 0 y 11"
when 12..22 then print "esta entre 12 y 22"
#para finalizar el case uso un end
else
print "hace otra cosa"
end
gets()
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_variables\n @countries = Country.sorted\n @time_periods = TimePeriod.sorted\n\n @locales = []\n I18n.available_locales.sort.each do |locale|\n @locales << [I18n.t(\"shared.locale.long.#{locale}\"), locale]\n end\n end",
"def locale; end",
"def locale; end",
"def loc... | [
"0.63007",
"0.59990424",
"0.59990424",
"0.59990424",
"0.59990424",
"0.59990424",
"0.59990424",
"0.59990424",
"0.5946603",
"0.5936303",
"0.58379185",
"0.57742393",
"0.5765312",
"0.5765312",
"0.5734248",
"0.5724293",
"0.5696144",
"0.5695971",
"0.56837225",
"0.5678516",
"0.56455... | 0.0 | -1 |
GPS version Returns an array of projects that are similar if project exists | def project_exists
if self.check_project_exists == true
return (Project.select{ |proj| proj.project_type == self.project_type } && Project.select{ |proj| proj.street1.to_f.between?((self.street1.to_f - 0.02), (self.street1.to_f + 0.02))} && Project.select{ |proj| proj.street2.to_f.between?((self.street2.to_f - 0.02), (self.street2.to_f + 0.02 ))})
else
return []
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def known_omnibus_projects\n # iterate through min/max versions for all product names\n # and collect the name for both versions\n projects = %w{ 0.0.0 1000.1000.1000 }.collect do |v|\n @version = v\n omnibus_project\n end\n # remove duplicates and return multip... | [
"0.6690948",
"0.6394917",
"0.5990774",
"0.5943927",
"0.5851132",
"0.5848677",
"0.5834253",
"0.5830118",
"0.57999",
"0.5787687",
"0.5622428",
"0.56071115",
"0.56039155",
"0.5595532",
"0.55241996",
"0.5422615",
"0.5381047",
"0.53718483",
"0.53706586",
"0.5354612",
"0.5352882",
... | 0.64128435 | 1 |
GPS version check for projects that have similar streets reversing street order as necessary. | def check_project_exists
# if latitude is within +/- 2 ten-thounsandths of another project's latitude it is the same
(Project.select{ |proj| proj.project_type == self.project_type }.count > 0 && Project.select{ |proj| proj.street1.to_f.between?((self.street1.to_f - 0.002), (self.street1.to_f + 0.002))}.count > 0 && Project.select{ |proj| proj.street2.to_f.between?((self.street2.to_f - 0.02), (self.street2.to_f + 0.02))}.count > 0)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compare_build_vers(loc_ver,rem_ver)\n if loc_ver.to_s.match(/No/)\n result = 0\n else\n if rem_ver.to_s.match(/-/) and !rem_ver.to_s.match(/beta/)\n if $verbose == 1\n puts \"Local build date: \"+loc_ver.to_s\n puts \"Remote build date: \"+rem_ver.to_s\n end\n if rem_ver.t... | [
"0.56617856",
"0.5622213",
"0.53688985",
"0.52612925",
"0.52385014",
"0.5199634",
"0.5196009",
"0.5139134",
"0.5099616",
"0.5096459",
"0.50687355",
"0.500505",
"0.4997049",
"0.49902913",
"0.4971103",
"0.4854134",
"0.48421282",
"0.48408216",
"0.48359808",
"0.48330972",
"0.4823... | 0.65193725 | 0 |
Deafults to BUH BYE! | def initialize
@assailant_header = "X-AIKIDO-ASSAILANT"
@get_redirect_status = 301
@other_redirect_status = 303
@get_redirect_url = @other_redirect_url = "https://google.com"
@get_redirect_query_params = @other_redirect_query_params = {}
@get_redirect_message = @other_redirect_message = "BUH BYE!"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bye; end",
"def berlioz; end",
"def buzzword; end",
"def buzzword; end",
"def weber; end",
"def schubert; end",
"def ibu; end",
"def bellini; end",
"def celebration; end",
"def jack_handey; end",
"def awaken!\n\t\traise 'Not implemented'\n\tend",
"def berg; end",
"def leeway; end",
"d... | [
"0.6878167",
"0.68227845",
"0.67997295",
"0.67997295",
"0.67609125",
"0.67543983",
"0.6723086",
"0.67045325",
"0.66406775",
"0.66302615",
"0.66055566",
"0.6591478",
"0.65901834",
"0.65901834",
"0.65256226",
"0.64736736",
"0.64736736",
"0.6469229",
"0.64250207",
"0.63404584",
... | 0.0 | -1 |
Implements the Singleton design pattern | def initialize
@connection = PG::Connection.open dbname: 'hospital', host: 'localhost'
@password = (OpenSSL::Digest.new 'SHA256').digest 'password'
@iv = (OpenSSL::Digest.new 'SHA256').digest 'iv'
self.add_observer CLogger.new
self
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def singleton!\n include Singleton\n end",
"def singleton\n class << self; self end\n end",
"def singleton\n @singleton = true\n end",
"def _singleton_class\n class << self\n self\n end\n end",
"def singleton_cache; end",
"def singleto... | [
"0.8225489",
"0.8186632",
"0.8080607",
"0.76473933",
"0.7592297",
"0.72845936",
"0.7242165",
"0.71727926",
"0.714887",
"0.71324277",
"0.7124301",
"0.70828354",
"0.70589",
"0.70553416",
"0.69794065",
"0.69012237",
"0.68976885",
"0.68976885",
"0.68976885",
"0.6723564",
"0.65900... | 0.0 | -1 |
Data encryption and decryption | def encrypt(data)
cipher = OpenSSL::Cipher.new 'AES-256-CBC'
cipher.encrypt
cipher.key, cipher.iv = @password, @iv
data.nil? ? '' : (cipher.update(data) + cipher.final).unpack('H*')[0]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def decrypt; end",
"def decrypt_and_encrypt(data)\n ## ** Decrypt\n keys = @keys\n begin\n #@@window.puts(\"Attempting to decrypt with primary key\")\n data = _decrypt_packet_internal(keys, data)\n #@@window.puts(\"Successfully decrypted with primary key\")\n\n # If it was successful... | [
"0.7835696",
"0.75955725",
"0.75672233",
"0.7288976",
"0.72487855",
"0.70930153",
"0.6996837",
"0.6994795",
"0.69863945",
"0.6929069",
"0.692115",
"0.69125944",
"0.6907265",
"0.6900832",
"0.68806857",
"0.68227226",
"0.6774302",
"0.677255",
"0.6767245",
"0.67495674",
"0.673739... | 0.68780655 | 15 |
do_run, do_example, do_list, do_file, do_help | def do_run
ready
aim
fire!
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def do_work()\n\n show_help()\n ::Twiga.say_info \"\\ntwiga> \"\n\n while (cmd = gets) do\n cmd.strip!\n tokens = cmd.split(/ /)\n unless tokens.empty?\n\n item = tokens[1] || 'test'\n \n case tokens.first.downcase\n\n when 'quit','exit' then break\n\n when 'reg... | [
"0.66309196",
"0.632287",
"0.6314614",
"0.6268893",
"0.62588394",
"0.6228285",
"0.61985123",
"0.6195078",
"0.6161546",
"0.6157726",
"0.6139158",
"0.61307466",
"0.61307466",
"0.61242706",
"0.61242706",
"0.61242706",
"0.60949206",
"0.60684407",
"0.6063103",
"0.6063103",
"0.6045... | 0.0 | -1 |
ready, aim, fire! (implementation of run) Set up the library path. | def ready
includes = @options.includes
unless Array === includes
error "Invalid value for @options.includes: #{includes.inspect}"
end
includes.each do |dir|
$:.unshift dir
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def globalSetup()\n # Build\n run(\"cd '#{Embedding::CODE_PATH}' && make clean && make\")\nend",
"def setup\n switch_dir\n end",
"def load_libs; end",
"def setup()\n end",
"def run_init_script; end",
"def test_library\n\tputs \"Library Loaded!\"\nend",
"def lib\n\tDir.mkdir('lib')\ne... | [
"0.65512484",
"0.63643533",
"0.6259009",
"0.6179743",
"0.61171234",
"0.6106498",
"0.6076977",
"0.604382",
"0.6035016",
"0.5977818",
"0.5977818",
"0.5977818",
"0.5973664",
"0.5973664",
"0.5973664",
"0.5968676",
"0.5963836",
"0.5963836",
"0.5963836",
"0.5963836",
"0.5963836",
... | 0.0 | -1 |
Load and run the tests. Run the setup file first if it exists. | def fire!
if @setup_file
vmsg "Running #{@setup_file} first"
load @setup_file
else
vmsg "No setup file #{@setup_file} to run"
end
if @options.run_separately
@files.each { |file|
_print_banner(file)
load file
Whitestone.run(_whitestone_options)
}
else
@files.each { |file|
vmsg "Loading file: #{file}"
load file
}
Whitestone.run(_whitestone_options)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test\n require File.expand_path(File.join(File.dirname(__FILE__), \"tests/tests\"))\n Test.run\nend",
"def setup\n # runs before every test\n # wipe and recreate .test directory, switch pwd \n Dir.chdir(@@start_dir)\n if File.exist?('.test')\n FileUtils.rm_rf('.test')\n end\n \n ... | [
"0.6915171",
"0.6847431",
"0.6780932",
"0.67183346",
"0.66953987",
"0.6670278",
"0.66423607",
"0.66323376",
"0.6609081",
"0.65928465",
"0.6550431",
"0.6481675",
"0.6443065",
"0.64173007",
"0.6409073",
"0.6401322",
"0.6391273",
"0.63834727",
"0.63688993",
"0.63684595",
"0.6362... | 0.65411377 | 11 |
Return a hash suitable for passing to Whitestone.run | def _whitestone_options()
{ :filter => @options.filter, :full_backtrace => @options.full_backtrace }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hash\n if @_hash.nil?\n @_hash = {}\n run\n end\n @_hash\n end",
"def get_entry_script_hash(*params); raise('Stub or mock required.') end",
"def hash\n hash_args.hash\n end",
"def get_executing_script_hash(*params); raise('Stub or mock required.') end",
"def get_script_hash(... | [
"0.6792897",
"0.6644945",
"0.6619084",
"0.6583516",
"0.65285563",
"0.64861715",
"0.64861715",
"0.64861715",
"0.6468073",
"0.64588356",
"0.64588356",
"0.64588356",
"0.64588356",
"0.64588356",
"0.64588356",
"0.64588356",
"0.6358151",
"0.633395",
"0.63233596",
"0.6323112",
"0.63... | 0.0 | -1 |
GET /users GET /users.json | def index
authorize User
query = flash[:query] = params[:query].to_s
@query = query.dup
@count = {}
sort = {sort_by: 'created_at', :order => 'desc'}
case params[:sort_by]
when 'username'
sort[:sort_by] = 'username'
end
case params[:order]
when 'asc'
sort[:order] = 'asc'
when 'desc'
sort[:order] = 'desc'
end
if params[:query].to_s.strip == ''
user_query = '*'
else
user_query = params[:query]
end
if user_signed_in?
role_ids = Role.where('id <= ?', current_user.role.id).pluck(:id)
else
role_ids = [1]
end
query = {
query: {
filtered: {
query: {
query_string: {
query: user_query, fields: ['_all']
}
}
}
},
sort: [
{:"#{sort[:sort_by]}" => sort[:order]}
]
}
search = User.search(query, routing: role_ids)
@users = search.page(params[:page]).records
#search.build do
# order_by sort[:sort_by], sort[:order]
#end
respond_to do |format|
format.html # index.html.erb
format.json { render json: @users }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def users(args = {})\n get(\"/users.json\",args)\n end",
"def show\n begin\n user = User.find(params[:user_id])\n render json: { users: user }, status: :ok\n rescue => e\n render json: { errors: e.message}, status: 404\n end\n end",
"def GetUsers params = {}\n\n para... | [
"0.82109934",
"0.7873764",
"0.7860689",
"0.78108346",
"0.78067017",
"0.7678852",
"0.76586664",
"0.76318866",
"0.7582366",
"0.75291824",
"0.7487637",
"0.74485743",
"0.7439024",
"0.7437192",
"0.7427442",
"0.73978853",
"0.73978853",
"0.73978853",
"0.73978853",
"0.7377353",
"0.73... | 0.0 | -1 |
GET /users/1 GET /users/1.json | def show
if @user == current_user
redirect_to my_account_url
return
end
session[:user_return_to] = nil
#unless @user.agent
# redirect_to new_user_agent_url(@user); return
#end
if defined?(EnjuBookmark)
@tags = @user.bookmarks.tag_counts.sort{|a,b| a.count <=> b.count}.reverse
end
@manifestation = Manifestation.pickup(@user.keyword_list.to_s.split.sort_by{rand}.first) rescue nil
respond_to do |format|
format.html # show.html.erb
format.html.phone
format.json { render json: @user }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n if params[:single]\n\t url = \"#{API_BASE_URL}/users/#{params[:id]}.json\"\n\t response = RestClient.get(url)\n\t @user = JSON.parse(response.body)\n\telse\n\t url = \"#{API_BASE_URL}/users.json\"\t \n response = RestClient.get(url)\n @users = JSON.parse(response.body)\t\t \n\tend\n ... | [
"0.81046426",
"0.7703556",
"0.77011716",
"0.76262826",
"0.7582106",
"0.74818",
"0.7461394",
"0.7446168",
"0.730656",
"0.7300699",
"0.72902125",
"0.72781444",
"0.72358584",
"0.72335744",
"0.72335744",
"0.72335744",
"0.72335744",
"0.72335744",
"0.72335744",
"0.72335744",
"0.722... | 0.0 | -1 |
GET /users/new GET /users/new.json | def new
#unless current_user.try(:has_role?, 'Librarian')
# access_denied; return
#end
@user = User.new
authorize @user
prepare_options
@user_groups = UserGroup.all
@user.user_group = current_user.user_group
@user.library = current_user.library
@user.locale = current_user.locale
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @newuser = Newuser.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @newuser }\n end\n end",
"def new\n @usernew = Usernew.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @usernew }\n ... | [
"0.8287397",
"0.8169197",
"0.8155916",
"0.80483407",
"0.8022376",
"0.8021751",
"0.8009459",
"0.7950995",
"0.793078",
"0.793078",
"0.7873476",
"0.7873476",
"0.7873476",
"0.7860956",
"0.7860956",
"0.7860956",
"0.7860956",
"0.7860956",
"0.7860956",
"0.7860956",
"0.7860956",
"0... | 0.0 | -1 |
POST /users POST /users.json | def create
authorize User
@user = User.new(user_params)
@user.operator = current_user
@user.set_auto_generated_password
respond_to do |format|
if @user.save
role = Role.where(:name => 'User').first
user_has_role = UserHasRole.new
user_has_role.assign_attributes({:user_id => @user.id, :role_id => role.id})
user_has_role.save
flash[:temporary_password] = @user.password
format.html { redirect_to @user, notice: t('controller.successfully_created', model: t('activerecord.models.user')) }
format.json { render json: @user, :status => :created, :location => @user }
else
prepare_options
flash[:error] = t('user.could_not_setup_account')
format.html { render action: "new" }
format.json { render json: @user.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def post_users(users)\n self.class.post('https://api.yesgraph.com/v0/users', {\n :body => users.to_json,\n :headers => @options,\n })\n end",
"def CreateUser params = {}\n \n APICall(path: 'users.json',method: 'POST',payload: params.to_json)\n \n end",
"def post b... | [
"0.77171224",
"0.7520082",
"0.7383616",
"0.72409296",
"0.71978706",
"0.71414214",
"0.7104655",
"0.7059102",
"0.7041023",
"0.70248663",
"0.7003639",
"0.7002607",
"0.7002607",
"0.7002607",
"0.6992824",
"0.6990796",
"0.6980945",
"0.69801277",
"0.6979133",
"0.6979133",
"0.6976736... | 0.0 | -1 |
PUT /users/1 PUT /users/1.json | def update
@user.assign_attributes(user_params)
if @user.auto_generated_password == "1"
@user.set_auto_generated_password
flash[:temporary_password] = @user.password
end
respond_to do |format|
@user.save
if @user.errors.empty?
format.html { redirect_to @user, notice: t('controller.successfully_updated', model: t('activerecord.models.user')) }
format.json { head :no_content }
else
prepare_options
format.html { render action: 'edit' }
format.json { render json: @user.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n render json: Users.update(params[\"id\"], params[\"user\"])\n end",
"def update\n render json: User.update(params[\"id\"], params[\"user\"])\n end",
"def UpdateUser params = {}\n \n APICall(path: 'users.json',method: 'PUT',payload: params.to_json)\n \n end",
"de... | [
"0.74114245",
"0.73920554",
"0.73041475",
"0.7254177",
"0.7202618",
"0.70756376",
"0.70535713",
"0.7029043",
"0.70075685",
"0.69883573",
"0.6983195",
"0.694263",
"0.69409895",
"0.692315",
"0.6909438",
"0.687742",
"0.68486536",
"0.6834162",
"0.6821841",
"0.6801179",
"0.6770304... | 0.0 | -1 |
DELETE /users/1 DELETE /users/1.json | def destroy
if @user.deletable_by(current_user)
@user.destroy
else
flash[:notice] = @user.errors[:base].join(' ')
redirect_to current_user
return
end
respond_to do |format|
format.html { redirect_to users_url, notice: t('controller.successfully_destroyed', model: t('activerecord.models.user')) }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def DeleteUser id\n \n APICall(path: \"users/#{id}.json\",method: 'DELETE')\n \n end",
"def delete\n render json: User.delete(params[\"id\"])\n end",
"def delete(id)\n request(:delete, \"/users/#{id}.json\")\n end",
"def delete\n render json: Users.delete(params[\"id\... | [
"0.78750724",
"0.77518034",
"0.7713981",
"0.7610077",
"0.747295",
"0.74073994",
"0.74073994",
"0.7369968",
"0.7346072",
"0.7340465",
"0.7328618",
"0.7309635",
"0.73095363",
"0.7306841",
"0.7297868",
"0.72917855",
"0.7291585",
"0.7289111",
"0.7284347",
"0.7250935",
"0.7250935"... | 0.0 | -1 |
Details: Finish the solution so that it sorts the passed in array of numbers. If the function passes in an empty array or null/nil value then it should return an empty array. For example: solution([1, 2, 10, 50, 5]) should return [1,2,5,10,50] solution(nil) should return [] | def solution(nums)
nums.to_a.sort
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sort_array(nums)\n nums.nil? ? [] : nums.sort\nend",
"def my_sort(nums, sorted=[])\n\t# get min\n\t# Remove min from nums\n\t# recursion until nums.size == 0 with new nums and new sorted\n\t# Return sorted\n\n\tmin = nums.min\n\tsorted << min\n\n\tnums.delete_if {|n| n == min}\n\n\tif nums.size > 0\n\t\tmy_... | [
"0.79653484",
"0.66269785",
"0.6622227",
"0.6622227",
"0.6503862",
"0.64985967",
"0.64985967",
"0.64849895",
"0.64233613",
"0.64233613",
"0.63996476",
"0.6398528",
"0.6390439",
"0.6390439",
"0.6390439",
"0.6373231",
"0.6340254",
"0.6340031",
"0.63360506",
"0.6335004",
"0.6313... | 0.7088003 | 1 |
No trailing slash for site | def scrape(site)
base_url = "#{site}/page/"
url_list = Array.new
post_links = Array.new
# Grabbing all the pages
(1..14).each do |i|
url_list << base_url + i.to_s
puts "Getting page " + i.to_s
end
# Going through individual pages
url_list.each do |page|
doc = Nokogiri::HTML(open(page))
# Getting post links, make sure to check the HTML <==================== CHANGE THIS ===========================
doc2 = doc.css('h2.entry-title a')
doc2.each do |link|
puts 'Collecting link ' + post_links.count.to_s
post_links << link['href']
end
end
puts "Finished with getting all the links"
CSV.open("derek-halpern-wp.csv", "wb") do |csv|
csv << ["Title", "Link", "Date", "Comments", "Likes", "Tweets", "LinkedIn", "Pins", "+ 1's"]
post_links.each_with_index do |post, index|
share_counts = "http://api.sharedcount.com/?url=#{post}"
resp = (Net::HTTP.get_response(URI.parse(share_counts))).body
result = JSON.parse(resp, :symbolize_names => true)
fb = result[:Facebook][:total_count]
tw = result[:Twitter]
ln = result[:LinkedIn]
pin = result[:Pinterest]
gp = result[:GooglePlusOne]
post_page = Nokogiri::HTML(open(post))
# Make sure the post headline follows this structure <==================== CHANGE THIS ===========================
post_title = post_page.css('h1.entry-title').text
# Make sure the comments follow this structure <==================== CHANGE THIS ===========================
post_comments = post_page.css('#comments_intro').text.to_i
#post_date = post_page.css('.meta .signature').text
#find_comments = post_page.xpath('//*[@id="comments"]/comment()').text
#convert_to_ng = Nokogiri::HTML.parse(find_comments)
#post_comments = convert_to_ng.css('h2').text.to_i
puts "Scraping post " + index.to_s + "/" + post_links.length.to_s
csv << ["#{post_title}", "#{post}", "#{post_date}","#{post_comments}", "#{fb}", "#{tw}", "#{ln}", "#{pin}", "#{gp}"]
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def trailing_slash_fix\n '/' unless ENV['PROXIED_IIIF_SERVER_URL'].last == '/'\n end",
"def force_no_trailing_slash\n force_slash :noslash\n end",
"def without_trailing_slash\n end_with?('/') ? Wgit::Url.new(chop) : self\n end",
"def omit_trailing_slash\n end_with?('/') ? Wgit::Url.new(c... | [
"0.7262811",
"0.7125822",
"0.6985909",
"0.6970237",
"0.6786317",
"0.67577666",
"0.6754375",
"0.6540662",
"0.6486175",
"0.64744586",
"0.6454143",
"0.6431418",
"0.64066476",
"0.6384281",
"0.634859",
"0.6261555",
"0.6249791",
"0.6217163",
"0.62092334",
"0.61844844",
"0.61684954"... | 0.0 | -1 |
Sortiert ein Array mit dem MaxSortAlgorithmus. | def max_sort!(a)
# Durchlaufe das Array von hinten (a.size - i ist dann immer das
# aktuelle Element)
for i in 1 .. a.size-1 do
# Suche das größte Element zwischen Index 0 und unserem aktuellen Element
max_pos = max_pos_until(a, a.size - i)
# Tausche das größte Element an unsere aktuelle Stelle
swap!(a, a.size - i, max_pos)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sort2(array, max_value)\n\nend",
"def my_max(arr) #give the method a name and select a variable that will pass through it\n\n\t\tsorted_array = arr.sort #\n\t\tsorted_array.last\n\n\tend",
"def sort_array_desc(array)\n\tarray.sort do |a, b|\n\t\tb <=> a\n\tend\nend",
"def sort\n limit = array.size - 1... | [
"0.7503693",
"0.67893755",
"0.6760639",
"0.6711813",
"0.67090034",
"0.6658954",
"0.6658954",
"0.6658617",
"0.66463536",
"0.66463536",
"0.66132593",
"0.65927076",
"0.6580084",
"0.6558103",
"0.6551675",
"0.6546806",
"0.653978",
"0.65322345",
"0.6501309",
"0.64934087",
"0.648758... | 0.66267174 | 10 |
GET /regionextras GET /regionextras.json | def index
@regionextras = Regionextra.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_region\n respond_to do |format|\n format.json{ render :json => { :region => Region.all } }\n end\n end",
"def region\n @regions = @company.companyregions\n respond_with @regions\n end",
"def regions\n client.get_stats('/stats/regions')\n end",
"def show\n render json: @regio... | [
"0.71900696",
"0.67239195",
"0.66143936",
"0.6611175",
"0.64833874",
"0.64386183",
"0.6378065",
"0.6367327",
"0.63036364",
"0.6268304",
"0.6228991",
"0.6211672",
"0.6211672",
"0.62070656",
"0.6194856",
"0.61833453",
"0.61815906",
"0.6171834",
"0.61537635",
"0.6150054",
"0.614... | 0.72709906 | 0 |
GET /regionextras/1 GET /regionextras/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_region\n respond_to do |format|\n format.json{ render :json => { :region => Region.all } }\n end\n end",
"def index\n @regionextras = Regionextra.all\n end",
"def show\n render json: @region\n end",
"def show\n @region = Region.find(params[:id])\n\n respond_to do |format|\n ... | [
"0.724429",
"0.7072834",
"0.6703882",
"0.6566322",
"0.6507994",
"0.6491359",
"0.6352008",
"0.6310948",
"0.6268031",
"0.6192416",
"0.616218",
"0.6153227",
"0.61264884",
"0.6100031",
"0.6100031",
"0.60758513",
"0.6063183",
"0.602515",
"0.59884775",
"0.598657",
"0.595573",
"0.... | 0.0 | -1 |
POST /regionextras POST /regionextras.json | def create
@regionextra = Regionextra.new(regionextra_params)
respond_to do |format|
if @regionextra.save
format.html { redirect_to @regionextra, notice: 'Regionextra was successfully created.' }
format.json { render :show, status: :created, location: @regionextra }
else
format.html { render :new }
format.json { render json: @regionextra.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def regionextra_params\n params.require(:regionextra).permit(:RegionID, :Name, :value)\n end",
"def set_regionextra\n @regionextra = Regionextra.find(params[:id])\n end",
"def create\n @region = Region.new(region_params)\n\n if @region.save\n render json: @region, status: :created, l... | [
"0.6437806",
"0.6351956",
"0.6259945",
"0.61845803",
"0.60703605",
"0.60580385",
"0.60164356",
"0.5906255",
"0.58810335",
"0.5846377",
"0.5806539",
"0.5758439",
"0.5758439",
"0.57405806",
"0.5724111",
"0.571648",
"0.56633353",
"0.5647524",
"0.5631641",
"0.5614036",
"0.5608624... | 0.67595834 | 0 |
PATCH/PUT /regionextras/1 PATCH/PUT /regionextras/1.json | def update
respond_to do |format|
if @regionextra.update(regionextra_params)
format.html { redirect_to @regionextra, notice: 'Regionextra was successfully updated.' }
format.json { render :show, status: :ok, location: @regionextra }
else
format.html { render :edit }
format.json { render json: @regionextra.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @region = Region.find(params[:id])\n\n if @region.update(region_params)\n head :no_content\n else\n render json: @region.errors, status: :unprocessable_entity\n end\n end",
"def update_region\n Region.find(params[:record][:id]).update_attributes(params[:record])\n render... | [
"0.6586227",
"0.6577751",
"0.64481485",
"0.6431758",
"0.6291979",
"0.628427",
"0.623349",
"0.623349",
"0.61646736",
"0.6111565",
"0.60827404",
"0.6052583",
"0.603586",
"0.6031507",
"0.5999401",
"0.5952492",
"0.5939089",
"0.5910816",
"0.5901486",
"0.58903587",
"0.585253",
"0... | 0.6898627 | 0 |
DELETE /regionextras/1 DELETE /regionextras/1.json | def destroy
@regionextra.destroy
respond_to do |format|
format.html { redirect_to regionextras_url, notice: 'Regionextra was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_region\n Region.find(params[:id]).destroy\n render :json => {}\n end",
"def destroy\n @region.destroy\n\n head :no_content\n end",
"def destroy\n @region = Region.find(params[:id])\n @region.destroy\n\n respond_to do |format|\n format.html { redirect_to regions_url }\n ... | [
"0.74677545",
"0.7150684",
"0.7055704",
"0.6934371",
"0.6837629",
"0.6837629",
"0.6837629",
"0.67998534",
"0.6740191",
"0.66453683",
"0.662495",
"0.6567241",
"0.6561294",
"0.65553993",
"0.6547393",
"0.654193",
"0.65335745",
"0.6477611",
"0.6430961",
"0.6404991",
"0.63848144",... | 0.7439709 | 1 |
Use callbacks to share common setup or constraints between actions. | def set_regionextra
@regionextra = Regionextra.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 regionextra_params
params.require(:regionextra).permit(:RegionID, :Name, :value)
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.6981537",
"0.67835593",
"0.6748275",
"0.67436063",
"0.6736311",
"0.65937173",
"0.6503359",
"0.6498499",
"0.6482832",
"0.6478776",
"0.645703",
"0.6439998",
"0.63802195",
"0.6377008",
"0.6366287",
"0.632018",
"0.63016284",
"0.63011277",
"0.62932974",
"0.62919617",
"0.6290564... | 0.0 | -1 |
no use for show method | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show() end",
"def show() end",
"def show() end",
"def show\n #not needed for our implementation\n end",
"def show ; end",
"def show\n\t\t end",
"def show \r\n end",
"def show\n \n end",
"def show\n \n end",
"def show\n \n end",
"def show\n \n end",
"def show\n \n e... | [
"0.85465944",
"0.85465944",
"0.85465944",
"0.84941363",
"0.84909403",
"0.84804535",
"0.84666306",
"0.83911175",
"0.83911175",
"0.83911175",
"0.83911175",
"0.83911175",
"0.83911175",
"0.83911175",
"0.83911175",
"0.83911175",
"0.83191246",
"0.82566667",
"0.82566667",
"0.8243141",... | 0.0 | -1 |
code for update your comment | def update
@comment = Comment.find(params[:id])
@comment.update(find_params)
redirect_to new_post_comment_path(@post)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n # @comment = Comment.find(params[:id])\n end",
"def comment\n\t Hookup.where(:user_id => params[:user_id], :challenge_id => params[:challenge_id]).update_attribute(:u,:c)\n end",
"def comment; end",
"def comment; end",
"def comment; end",
"def comment; end",
"def comment; end",
"def... | [
"0.7193565",
"0.7169703",
"0.712263",
"0.712263",
"0.712263",
"0.712263",
"0.712263",
"0.712263",
"0.712263",
"0.712263",
"0.712263",
"0.712263",
"0.712263",
"0.712263",
"0.712263",
"0.712263",
"0.712263",
"0.712263",
"0.712263",
"0.7120408",
"0.70499706",
"0.7019292",
"0... | 0.66451544 | 75 |
code for like any comment | def like
@post = Post.find(params[:post_id])
@comment = @post.comments.find(params[:id])
if current_user.already_dislikes?(@comment,'Comment')
like = current_user.likes.where(likeble_id: @comment.id ,
user_id: current_user.id ,likeble_type: 'Comment').first
like.like_status = true
like.save
redirect_to new_post_comment_path(@post)
else
if current_user.already_likes?(@comment ,'Comment')
redirect_to new_post_comment_path(@post)
else
like = @comment.likes.create()
like.user_id = current_user.id
like.like_status = true
like.save
redirect_to new_post_comment_path(@post)
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def comment?; end",
"def comment?; end",
"def comment(string); end",
"def comment(string); end",
"def comment(string); end",
"def comment(string); end",
"def comment; end",
"def comment; end",
"def comment; end",
"def comment; end",
"def comment; end",
"def comment; end",
"def comment; end"... | [
"0.7499248",
"0.7499248",
"0.73988605",
"0.73988605",
"0.73988605",
"0.73988605",
"0.72523737",
"0.72523737",
"0.72523737",
"0.72523737",
"0.72523737",
"0.72523737",
"0.72523737",
"0.72523737",
"0.72523737",
"0.72523737",
"0.72523737",
"0.72523737",
"0.72523737",
"0.72523737",
... | 0.0 | -1 |
code for dislike any comment | def dislike
@post = Post.find(params[:post_id])
@comment = @post.comments.find(params[:id])
if current_user.already_likes?(@comment,'Comment')
like = current_user.likes.where(likeble_id: @comment.id ,
user_id: current_user.id,likeble_type: 'Comment').first
like.like_status = false
like.save
redirect_to new_post_comment_path(@post)
else
if current_user.already_dislikes?(@comment ,'Comment')
redirect_to new_post_comment_path(@post)
else
like = @comment.likes.create()
like.user_id = current_user.id
like.like_status = false
like.save
redirect_to new_post_comment_path(@post)
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dislike\n @comment.disliked_by current_user\n end",
"def comment?; end",
"def comment?; end",
"def comment(&block)\n #SWALLOW THE BLOCK\n end",
"def verb\n \"unlike\"\n end",
"def lex_comment line\n # do nothing\n end",
"def ignore_comment\n\traise 'Expected #' if gets[ ... | [
"0.71387863",
"0.65847147",
"0.65847147",
"0.6447941",
"0.6389909",
"0.63740563",
"0.61551577",
"0.61255646",
"0.61255646",
"0.61255646",
"0.61255646",
"0.61033845",
"0.61033845",
"0.61033845",
"0.61033845",
"0.61033845",
"0.61033845",
"0.61033845",
"0.61033845",
"0.61033845",
... | 0.59034497 | 32 |
Complete the gameOfThrones function below. | def gameOfThrones(s)
words = s.split('')
frequency = Hash.new(0)
words.each { |word| frequency[word.downcase] += 1 }
odd = 0
even = 0
frequency.each do |k,v|
if v.even?
even += 1
else
odd += 1
end
end
if odd > 1
"NO"
else
"YES"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def full_game\n 52.times do\n round\n end\n output\n rematch\n end",
"def run_game\n while @p1.score != @length && @p2.score != @length\n run_round\n end\n @winner = @p1 if @p1.score == @length\n @winner = @p2 if @p2.score == @length\n puts @winner.name + \" wins the game!\"... | [
"0.6577823",
"0.64969766",
"0.6422065",
"0.6237502",
"0.6230929",
"0.6229197",
"0.62128645",
"0.61618423",
"0.6157579",
"0.6150498",
"0.6124498",
"0.61214536",
"0.61162686",
"0.6102308",
"0.6099765",
"0.60936576",
"0.608049",
"0.60762095",
"0.60744774",
"0.6060562",
"0.605890... | 0.0 | -1 |
=begin need function that takes and argument that argument will be an array reference value to check against if the next number is bigger than reference value it becomes the reference value at the end of iterating over each item the reference value the largest number =end | def max_value(our_array)
reference = -100000
our_array.each do |number|
if number > reference
reference = number
end
end
reference
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_max_number(any_array)\n\treference = any_array[1]\n\tany_array.each do |number|\n\t\tif number > reference\n\t\treference = number\n\t\tend\n\tend \n\treference\nend",
"def find_greatest(numbers)\n saved_number = numbers[0]\n\n numbers.each do |num|\n if saved_number >= num\n next\n else\n ... | [
"0.80275106",
"0.76950336",
"0.7690046",
"0.76097184",
"0.7540231",
"0.7538304",
"0.75273305",
"0.7512896",
"0.75111955",
"0.7472626",
"0.74536985",
"0.74472046",
"0.74168944",
"0.74168944",
"0.74168944",
"0.74026215",
"0.7386269",
"0.73623466",
"0.7346802",
"0.73148793",
"0.... | 0.7971969 | 1 |
=begin need function that takes two arrays as arguments the arrays have the same amount of items the function combines the arrays into a hash into key=>value pairs items of first array becomes the key items of second array becomes the value the hash is returned as a result of the function =end | def two_array(array_one, array_two)
my_hash = {}
array_one.each_with_index do |value, index|
my_hash[value] = array_two[index]
end
puts my_hash
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def combine_two_arrays_into_hashes(array_one, array_two)\n\tcombined_hash = {}\n\tcounter = 0\n\tarray_one.each do |array_item|\n\t\tcombined_hash[array_item] = array_two[counter]\n\t\tcounter = counter +\t1\n\tend\n\tcombined_hash\nend",
"def put_in_hash(array1, array2, nb=array1.length)\n hash = {}\n nb.... | [
"0.8419549",
"0.80064064",
"0.7606483",
"0.7511787",
"0.74850094",
"0.7451551",
"0.74486953",
"0.7266196",
"0.7150073",
"0.7032303",
"0.69592917",
"0.69417167",
"0.6911692",
"0.68912023",
"0.6839806",
"0.68087274",
"0.6769662",
"0.67446756",
"0.67160004",
"0.66876554",
"0.665... | 0.78371465 | 2 |
Overwrites slug_exists? from Slug. We allow duplicate slugs on different published_at dates. | def slug_exists?
Article.on(published_at).where(slug: slug).exists?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new_slug_needed?\n !slug || slug_text != slug.name\n end",
"def should_generate_new_friendly_id?\n slug.blank? || permalink_changed?\n end",
"def auto_generate_slug\n return true unless self.slug.nil?\n return true if self.respond_to?(:published?) && !self.published?\n self.slu... | [
"0.7531849",
"0.70434123",
"0.7031356",
"0.6907691",
"0.69001466",
"0.6841139",
"0.66248775",
"0.6604771",
"0.66036475",
"0.66036475",
"0.66036475",
"0.6590974",
"0.6581869",
"0.6568581",
"0.6568581",
"0.6549414",
"0.65259534",
"0.65133417",
"0.6489964",
"0.64785665",
"0.6469... | 0.8027041 | 1 |
TEMP: TODO: move to database column and form field | def lede
content.strip.split("\n").first
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def form_field\n case self.column_type\n when \"text\"\n %{<%= :#{self.model_name}.text_area :#{self.column_name}, :label => true %>}\n when \"date\"\n %{<%= :#{self.model_name}.date_select :#{self.column_name}, :label => true %>}\n when \"date_time\"\n ... | [
"0.7489837",
"0.7062744",
"0.70053643",
"0.6874576",
"0.63838303",
"0.6380619",
"0.6375783",
"0.627334",
"0.6266773",
"0.6247424",
"0.62397593",
"0.6224619",
"0.62219936",
"0.6209436",
"0.6208398",
"0.620448",
"0.6151702",
"0.61351883",
"0.6098411",
"0.6089803",
"0.60852605",... | 0.0 | -1 |
accepts only if the given token is the current_token | def soft_accept(token=current_token)
(token == current_token).tap do |result|
accept if result
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def token?(token)\n return false\n end",
"def token?\n @token && [email protected]?\n end",
"def current_token\n @current_token\n end",
"def token?\n (@token.respond_to?(:empty?) && [email protected]?)\n end",
"def valid_token?(token)\n exists?(:token => t... | [
"0.7259626",
"0.7152087",
"0.7083958",
"0.67953897",
"0.67651135",
"0.66602886",
"0.6647488",
"0.66294855",
"0.6554703",
"0.65303826",
"0.65189224",
"0.65189224",
"0.6482159",
"0.64300936",
"0.642276",
"0.6422299",
"0.639008",
"0.6312649",
"0.63045424",
"0.6296064",
"0.629102... | 0.67911273 | 4 |
accepts a method and prints the method we are transitioning to | def goto(method, args=nil)
print(method)
if args
send(method, args)
else
send(method)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def print_method(*) end",
"def display_method_info\n end",
"def display_method name\n found = load_methods_matching name\n\n raise NotFoundError, name if found.empty?\n\n filtered = filter_methods found, name\n\n out = method_document name, filtered\n\n @history.go name, out, nil\n\n display... | [
"0.77771485",
"0.7030891",
"0.69917643",
"0.69671017",
"0.69439274",
"0.6941891",
"0.6916332",
"0.6786635",
"0.6786246",
"0.6780767",
"0.67077804",
"0.67069995",
"0.6652047",
"0.65738153",
"0.6466491",
"0.6465187",
"0.64076453",
"0.6402894",
"0.63928515",
"0.63910687",
"0.637... | 0.64357305 | 16 |
this makes use of elastic search query syntax | def elasticsearch_params(page, per_page = 20)
page ||= 1
offset = (page.to_i - 1) * per_page.to_i
{
body: {
sort: order_params,
query: elasticsearch_query,
aggs: aggregates,
post_filter: {
bool: {
filter: [{
in: {
portal_ids: current_portal.self_and_descendants.pluck(:id)
}
}]
}
},
size: per_page,
from: offset
},
page: page,
per_page: per_page
}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def search\n\n # define the elasticsearch result \"size\" (limit)\n limit = params['limit'].to_i\n # define the elasticsearch result \"from\" (offset)\n offset = params['offset'].to_i\n # Pass through\n hack = params['hack']\n # Default output\n searchResults = ''\n # If we have filters,... | [
"0.7372549",
"0.6931692",
"0.68112725",
"0.67871773",
"0.6763451",
"0.672785",
"0.66661924",
"0.6661354",
"0.65298903",
"0.65002483",
"0.64560133",
"0.64094776",
"0.6371175",
"0.63626313",
"0.6361925",
"0.6361177",
"0.6356271",
"0.6320093",
"0.6319738",
"0.63006824",
"0.62943... | 0.0 | -1 |
Finds the template to render the content | def find_template(name)
# Search in theme path
template_path = Themes::ThemeManager.instance.selected_theme.resource_path("#{name}.erb",'template','ui')
# Search in the project
if not template_path
path = app.get_path(name) #File.expand_path(File.join(File.dirname(__FILE__), '..', 'views', "#{name}-fieldset-render.erb"))
template_path = path if File.exist?(path)
end
template_path
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_template(template); end",
"def locate_template(document)\n view_prefix = 'cms'\n\n return File.join(view_prefix, document.template) unless document.template.blank?\n return File.join(view_prefix, document.node.get(:template)) unless document.node.get(:template).blank?\n\n paths = [document.ti... | [
"0.7369887",
"0.7349709",
"0.72721857",
"0.7160781",
"0.7143418",
"0.71336544",
"0.7121636",
"0.7096915",
"0.70212525",
"0.7001296",
"0.696039",
"0.689798",
"0.68595356",
"0.6771585",
"0.67584056",
"0.6751749",
"0.67020124",
"0.669099",
"0.66570884",
"0.6651949",
"0.66484994"... | 0.7288165 | 2 |
Chapter Loops & Iterators Exercises | def result(answer)
puts answer
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def for_iterator\n\tfor item in 1..3 do\n\t puts \"The current item is #{item}.\"\n\tend\nend",
"def basic_4 (array_iterate)\n array_iterate.each { |n| puts \"Item: #{n}\"}\n puts\nend",
"def times_iterator(number_of_times)\n number_of_times.times do\n puts \"Welcome to Flatiron School's Web Development... | [
"0.709693",
"0.6446762",
"0.6397178",
"0.63688",
"0.62057644",
"0.61793727",
"0.6155058",
"0.6117979",
"0.61143005",
"0.60810184",
"0.6020928",
"0.59537506",
"0.59340626",
"0.59307384",
"0.59307384",
"0.58895665",
"0.5867867",
"0.5862016",
"0.5822476",
"0.5815044",
"0.5811704... | 0.0 | -1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.