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 |
|---|---|---|---|---|---|---|
PATCH/PUT /producers/1 PATCH/PUT /producers/1.json | def update
@producer = Pusher.update_producer(params)
if @producer.valid?
head :no_content
else
render json: @producer.errors, status: :unprocessable_entity
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n authorize @producer\n if @producer.update(producer_params)\n head :no_content\n else\n render json: @producer.errors, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @producer.update(producer_params)\n format.html { redirect... | [
"0.6487498",
"0.6350371",
"0.5804539",
"0.58020866",
"0.57748497",
"0.5707767",
"0.56957006",
"0.5679055",
"0.56272244",
"0.5599534",
"0.5597903",
"0.5591269",
"0.55858034",
"0.5566249",
"0.5565811",
"0.5561921",
"0.55531967",
"0.5543999",
"0.55323875",
"0.5526327",
"0.551988... | 0.6214617 | 2 |
DELETE /producers/1 DELETE /producers/1.json | def destroy
@producer = Pusher.destroy_producer(params)
head :no_content
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @producer = Producer.find(params[:id])\n @producer.destroy\n\n respond_to do |format|\n format.html { redirect_to producers_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @producer.destroy\n respond_to do |format|\n format.html { redirect_to ... | [
"0.7154517",
"0.677698",
"0.67714006",
"0.64637613",
"0.64623994",
"0.63576084",
"0.6248228",
"0.62432295",
"0.62385875",
"0.6217202",
"0.6178175",
"0.61697525",
"0.6138118",
"0.6136051",
"0.6121802",
"0.611557",
"0.6107682",
"0.6098637",
"0.60703355",
"0.6069831",
"0.6067683... | 0.6649517 | 3 |
most common letter in the array, and a count of how many times it appears. Difficulty: medium. | def most_common_letter(string)
idx = 0
while idx < string.length
letter = string[idx]
count = 0
idx1 = 0
while idx1 < string.length
if string[idx1] == letter
count += 1
end
idx1 += 1
end
idx += 1
end
puts [letter, count]
return [letter, count]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def most_common_letter(string)\n # #create array, letter and count to return \n # mostCommon = []\n # count = 0\n # #assign the first letter to a variable\n # i = 0\n # #loop through array\n # while i < string.length\n # count = string.count(string[i])\n # for j in string\n # #count how many times ... | [
"0.78851956",
"0.7627264",
"0.76267445",
"0.7623407",
"0.7517604",
"0.7409256",
"0.7402383",
"0.7383039",
"0.7335671",
"0.73182625",
"0.72361624",
"0.7208984",
"0.7204907",
"0.7200099",
"0.7183736",
"0.7168996",
"0.71407104",
"0.71365255",
"0.70735353",
"0.70425355",
"0.70299... | 0.75683826 | 4 |
propose a new item with quantity | def propose_item_with_quantity(name, price, quantity, selling_mode, increment, end_time, description = "", log = true)
item = self.propose_item(name,price,selling_mode,increment,end_time, quantity, description,log)
item
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add\n @item.increment(:quantity)\n @item.save!\n\n refresh\n end",
"def add_item(product_id:, quantity: 1)\n product = Product.find(product_id)\n\n order_item = order.items.find_or_create_by(\n product_id: product_id\n )\n\n order_item.price = product.price\n order_item.quantity... | [
"0.7752051",
"0.7704649",
"0.75937855",
"0.7586079",
"0.7562667",
"0.7522789",
"0.75090563",
"0.7491194",
"0.74564815",
"0.7416457",
"0.74152505",
"0.7402384",
"0.73710334",
"0.73679346",
"0.7359215",
"0.7333172",
"0.73271745",
"0.72894347",
"0.7275302",
"0.7266912",
"0.72657... | 0.785348 | 0 |
propose a new item | def propose_item(name, price, selling_mode, increment, end_time, quantity = 1, description = "", log = true)
if selling_mode == :fixed
item = Item.fixed(name, price, self, description)
elsif selling_mode == :auction
item = Item.auction(name, price, self, increment.to_i, end_time, description)
end
item.quantity = quantity
item.save
self.attach_item(item)
ItemAddActivity.create(self, item).log if log
item
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_item(new_item)\n item = Item.new(new_item)\n items.push(item)\n end",
"def add_item(new_item)\n item = Item.new(new_item)\n @items.push(item)\n end",
"def propose_item(name, price, selling_mode, increment, end_time, description = \"\", log = true)\n if selling_mode == \"fixed\"\n ... | [
"0.6981362",
"0.6852838",
"0.674562",
"0.6734719",
"0.6647732",
"0.6625688",
"0.6613227",
"0.6558322",
"0.65454644",
"0.650865",
"0.6504293",
"0.64834315",
"0.6445756",
"0.64384943",
"0.6434799",
"0.64330024",
"0.64062095",
"0.6404805",
"0.6404805",
"0.6404805",
"0.6393626",
... | 0.7235941 | 0 |
sell item matching an offer | def sell_to_offer(offer,item)
active = item.active?
item.activate if !active
#offer.from.credits +=offer.price*offer.quantity
purchase = Purchase.create(item,offer.quantity,item.owner,offer.from)
purchase.adapt_price_to_offer(offer)
purchase.prepare
PurchaseActivity.successful(purchase).log
offer.delete
item.deactivate if !active
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sell(item)\r\n self.add_credits(item.price * item.quantity)\r\n Marketplace::Activity.create(Activity.ITEM_SOLD, item, \"#{item.name} has been sold by #{self.name}\")\r\n Marketplace::Activity.create(Activity.USER_SOLD_ITEM, self, \"#{self.name} sold #{item.name}\")\r\n end",
"def sell_requ... | [
"0.7122848",
"0.69785243",
"0.6918258",
"0.6728744",
"0.66711533",
"0.6624512",
"0.65788925",
"0.65503424",
"0.64741457",
"0.6469359",
"0.6461519",
"0.64297235",
"0.642102",
"0.6401419",
"0.63795",
"0.6374036",
"0.63039875",
"0.6261828",
"0.6261102",
"0.6260047",
"0.62582946"... | 0.76911545 | 0 |
get a list of all active items of a user | def get_active_items
self.items.select { |i| i.active? } #TODO only fixed or only auction
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fetch_all_active_items\n @items.values.select{|item| item.active}\n end",
"def get_active_items\n self.items.select { |i| i.active? } #TODO only fixed or only auction\n end",
"def index\n @items = @current_user.items\n end",
"def index \n \t@items = Item.paginate(page: params[:... | [
"0.7867313",
"0.73099804",
"0.7211172",
"0.7211117",
"0.7161697",
"0.710768",
"0.7060774",
"0.7047599",
"0.70148796",
"0.6965865",
"0.69565445",
"0.6945257",
"0.68824565",
"0.6881317",
"0.68749595",
"0.6871562",
"0.686274",
"0.686274",
"0.68104917",
"0.68051094",
"0.68002504"... | 0.7312948 | 1 |
attach a bought item to the user. If the bought item matches an already owned item, items will be composed, i.e their respective quantities will be added | def attach_item(item)
equal_item = self.check_for_equal_item(item.name,item.price,item.description)
if equal_item == nil
self.items << item
item.owner = self
item.deactivate
else
equal_item.quantity += item.quantity
equal_item.deactivate
item.delete
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def buy_item(user, item)\r\n if(self.has_enough_money(item) and user.has_item(item))\r\n self.get_item(user, item)\r\n self.pay_amount(user, item.get_price)\r\n else\r\n #transaction not possible\r\n end\r\n end",
"def buy_new_item(item_to_buy, quantity, a... | [
"0.73715043",
"0.7309045",
"0.7253374",
"0.70903224",
"0.7074505",
"0.70599717",
"0.69619083",
"0.6961877",
"0.6881912",
"0.68477535",
"0.6728815",
"0.6710392",
"0.66967636",
"0.6684488",
"0.66226447",
"0.66168904",
"0.6609025",
"0.65925187",
"0.6570102",
"0.6564247",
"0.6559... | 0.7787981 | 0 |
releases a certain quantity of an item | def release_quantity_of_item(item, quantity)
if self.items.include?(item)
item.quantity -= quantity
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def use_item(item_name:, quantity:)\n total_items_quantity[item_name] -= quantity\n end",
"def reserve_inventory!(order_quantity)\n self.quantity -= order_quantity\n save!\n end",
"def sell_inventory(material, quantity)\n material.quantity -= quantity\n end",
"def purchase\n \t@stock -= 1\n ... | [
"0.7100202",
"0.7001074",
"0.69820267",
"0.687481",
"0.67463577",
"0.67162484",
"0.67162484",
"0.66184425",
"0.6617048",
"0.6597131",
"0.6555539",
"0.654294",
"0.65269905",
"0.6490382",
"0.64864016",
"0.6464276",
"0.64587927",
"0.63866997",
"0.6383126",
"0.6379867",
"0.636671... | 0.79756016 | 0 |
deletes the owner of an item to release it | def release_item(item)
if self.items.include?(item)
item.owner = nil
self.items.delete(item)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def release_item(item)\n if self.items.include?(item)\n item.owner = nil\n self.items.delete(item)\n end\n end",
"def remove_item(item)\r\n items.delete(item)\r\n item.owner = nil\r\n end",
"def dispose_item(item)\n if self == item.owner\n equipments.delete(item.... | [
"0.85387784",
"0.789855",
"0.71152526",
"0.7090574",
"0.6851771",
"0.68334115",
"0.6792848",
"0.6687587",
"0.66385573",
"0.64041644",
"0.63915133",
"0.6359432",
"0.6359343",
"0.6342233",
"0.63086724",
"0.62975305",
"0.62655383",
"0.62579817",
"0.62361425",
"0.6233602",
"0.622... | 0.8555008 | 0 |
deletes chosen item, raises error if trader can not delete item | def delete_item(item_id, log = true)
item = Item.by_id(item_id)
fail if item.nil?
fail unless self.can_delete?(item)
item.owner.release_item(item)
item.delete
ItemDeleteActivity.create(self, item).log if log
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def deleted(item)\n end",
"def delete_item(item)\n @chores.delete(item)\n end",
"def delete_item(item_id)\n raise \"implemented in subclass\"\n end",
"def delete(id)\n @item = Item.find_by_id(id)\n \n begin\n item.destroy!\n say 'Item Deleted'\n ... | [
"0.72942626",
"0.7277605",
"0.71380806",
"0.7057933",
"0.70311725",
"0.7027778",
"0.69744664",
"0.68943083",
"0.6868107",
"0.684921",
"0.6798211",
"0.6694011",
"0.6674505",
"0.6674079",
"0.66614825",
"0.66524804",
"0.6644929",
"0.6620526",
"0.6614372",
"0.66004586",
"0.658960... | 0.0 | -1 |
confirm a previously prepared purchase | def confirm_purchase(purchase)
purchase.confirm
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def confirm!\n return false if purchased?\n confirmed!\n end",
"def successful_purchase_response\n end",
"def confirm!\n confirm_integration product_payload\n variants_payload.each { |key, v| confirm_integration v }\n end",
"def confirmation\n @merchant = @current_merchant\n ... | [
"0.80120355",
"0.71839976",
"0.7034328",
"0.69552207",
"0.69417167",
"0.6840967",
"0.68290037",
"0.68160766",
"0.67721665",
"0.67500556",
"0.67412174",
"0.67292356",
"0.6726638",
"0.67259914",
"0.66930574",
"0.666647",
"0.662746",
"0.6584693",
"0.65668005",
"0.65359044",
"0.6... | 0.8436574 | 0 |
confirms all pending purchases | def confirm_all_pending_purchases
self.pending_purchases.each{|purchase| purchase.confirm}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def confirm!\n self.pending = false\n self.save\n self.createDebts\n end",
"def confirm_purchase(purchase)\r\n purchase.confirm\r\n end",
"def confirm!\n return false if purchased?\n confirmed!\n end",
"def void_pending_purchase_orders\n self.purchase_orders.se... | [
"0.7165871",
"0.710431",
"0.6915711",
"0.671638",
"0.66638136",
"0.65216666",
"0.65216666",
"0.6379331",
"0.6322846",
"0.630819",
"0.63065654",
"0.62531257",
"0.6160262",
"0.6138251",
"0.61300164",
"0.6119833",
"0.6099496",
"0.6082478",
"0.6058828",
"0.60534346",
"0.60512286"... | 0.87315136 | 0 |
add purchase to user's pending purchases list | def add_to_pending(purchase)
self.pending_purchases.push(purchase)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_to_purchases(purchase_record)\n @purchases << purchase_record\n end",
"def pending!(purchase)\n post(purchase, \"#{collection_path}/pending\")\n end",
"def pending!(purchase)\n post(purchase, \"#{collection_path}/pending\")\n end",
"def do_purchase\n user.purchases.crea... | [
"0.7393064",
"0.6969941",
"0.6969941",
"0.67944",
"0.6484065",
"0.6417725",
"0.6390281",
"0.6367429",
"0.62931055",
"0.62603235",
"0.6224885",
"0.6166776",
"0.6166744",
"0.60608613",
"0.59752727",
"0.5958694",
"0.59393317",
"0.5899517",
"0.589537",
"0.58802223",
"0.58519614",... | 0.8696216 | 0 |
delete purchase from user's pending purchases list | def delete_pending(purchase)
self.pending_purchases.delete(purchase)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_purchase_order_items\n purchase_order_items.destroy_all\n end",
"def destroy\n @purchase_list.destroy\n end",
"def destroy\n @purchase = Purchase.find(params[:id])\n if current_user == @purchase.user\n @purchase.destroy\n end\n redirect_to \"/products\"\n end",
"def remov... | [
"0.7128409",
"0.69421244",
"0.6914868",
"0.69054824",
"0.67975605",
"0.66891444",
"0.6648817",
"0.6601199",
"0.652107",
"0.6518998",
"0.65046024",
"0.64683145",
"0.64472157",
"0.6365561",
"0.6346627",
"0.6293252",
"0.62929934",
"0.6292903",
"0.62905794",
"0.6240558",
"0.61875... | 0.85486287 | 0 |
returns true if an user is allowed to edit | def can_edit?(item)
item.editable_by?(self)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def can_edit?(user)\n user == current_user\n end",
"def can_edit?(user)\n (self.user == user) || !!(user && user.admin?)\n end",
"def can_edit?\n allows_current_user_access_to? :edit\n end",
"def can_edit?(user)\n return user == self.user || user.has_role?(:admin)\n end",
"def can_edit?(obj... | [
"0.89824325",
"0.89695275",
"0.89458466",
"0.8923159",
"0.88882214",
"0.8879104",
"0.88332",
"0.88221055",
"0.88102555",
"0.88102555",
"0.88102555",
"0.86176544",
"0.85845137",
"0.8525991",
"0.8524973",
"0.84765583",
"0.84514827",
"0.844656",
"0.8439928",
"0.8433217",
"0.8400... | 0.7631594 | 89 |
returns true if user is allowed to buy item | def can_buy?(item)
item.buyable_by?(self)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def can_buy?(item)\n item.buyable_by?(self)\n end",
"def check_buyable\n raise PermissionDeniedError, \"出品したアイテムはサポートできません\" if @item.owner?(current_user)\n end",
"def test_can_buy_org_item\n user = User.named(\"user\")\n org = Organization.named(\"org\")\n\n item = org.propose_item(\"Item... | [
"0.83556855",
"0.80316854",
"0.7427995",
"0.7392608",
"0.7370311",
"0.72309196",
"0.7112417",
"0.7045148",
"0.7044457",
"0.6986249",
"0.69859576",
"0.69794226",
"0.69610906",
"0.69420904",
"0.6913748",
"0.6912129",
"0.6909094",
"0.6885142",
"0.68847775",
"0.6845791",
"0.68448... | 0.8416713 | 0 |
returns true if user is allowed to activate an item | def can_activate?(item)
item.activatable_by?(self)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def can_activate?(item)\n item.activatable_by?(self)\n end",
"def activated?\n self.user && self.user.activated?\n end",
"def can_activate?\n self.person && self.person_match? && self.has_not_expired?\n end",
"def can_activate?\n self.person && self.email_match?\n end",
"def can_activat... | [
"0.8513891",
"0.7573564",
"0.7317395",
"0.71086276",
"0.7026378",
"0.70057917",
"0.6754494",
"0.6717668",
"0.67154217",
"0.67154217",
"0.6700493",
"0.66995585",
"0.66611975",
"0.66611975",
"0.66450006",
"0.66209126",
"0.6610475",
"0.6610475",
"0.6592199",
"0.657829",
"0.65740... | 0.85580724 | 0 |
returns the system user as a string | def to_s
"#{self.name}, #{self.credits}"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def username\n if @username.nil?\n if os_type(:nice, :not_extended) == 'Solaris'\n @username = @platform.exec(\"/usr/ucb/whoami\").strip\n else\n @username = @platform.exec(\"whoami\").strip\n end\n end\n \n @username\n end",
"def current_user\n `whoami`.strip\nend",
... | [
"0.76619476",
"0.7593824",
"0.7580131",
"0.75659436",
"0.7537774",
"0.7537774",
"0.73637843",
"0.7309964",
"0.7252067",
"0.7183811",
"0.71215916",
"0.7020186",
"0.7012508",
"0.69794655",
"0.69579184",
"0.6932179",
"0.6868921",
"0.686678",
"0.6831591",
"0.68000525",
"0.6791788... | 0.0 | -1 |
sends a certain amount of money from the user/org to a another user/org. Raises TradeException if operation failed | def transfer_credits_to(receiver, amount)
fail if receiver.nil?
raise TradeError, "NOT_ENOUGH_CREDITS " unless self.credits >= amount
self.credits -= amount
receiver.credits += amount
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def send_money(amount)\n fail unless amount >= 0\n self.credits += amount\n end",
"def transfer(amount, other)\n @balance -= amount\n other.balance += amount\n puts \"#{@owner} your balance will be #{@balance} after the transfering to #{other.owner}\"\n end",
"def pay_amount(user, amount... | [
"0.7407845",
"0.6859771",
"0.68348825",
"0.68243057",
"0.6739805",
"0.6675821",
"0.6639141",
"0.6617399",
"0.6584416",
"0.6527296",
"0.65162516",
"0.6511019",
"0.64488953",
"0.6440366",
"0.6419267",
"0.64138186",
"0.64058757",
"0.63811177",
"0.635775",
"0.635775",
"0.63569605... | 0.66593105 | 6 |
save time for item page | def acknowledge_item_properties!
self.open_item_page_time = Time.now
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize(item_description)\n @description = item_description\n @completed_status = false\n @created_time = Time.now.strftime(\"%H:%M\") #Time now\n @due_time = (Time.now + 18000).strftime(\"%H:%M\") # TIme now = 5hrs\n end",
"def get_time\n @time = Time.now.strftime(\"%H:%M:%S... | [
"0.62111086",
"0.61838603",
"0.6096088",
"0.5926099",
"0.59230864",
"0.59115034",
"0.59008425",
"0.58849764",
"0.5861833",
"0.5861833",
"0.5861833",
"0.5861833",
"0.5861833",
"0.5861833",
"0.5861833",
"0.5861833",
"0.5861833",
"0.58504725",
"0.5848829",
"0.58429843",
"0.58216... | 0.5755125 | 25 |
returns true when user is aware of latest changes to item, false otherwise | def knows_item_properties?(item)
!(self.open_item_page_time < item.edit_time)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def updated?\n updater && author != updater\n end",
"def stale?\n unlocked? and item.has_attribute?(:updated_at) and updated_at < item.updated_at\n end",
"def notified? \n \titem = Item.find(item_id)\n \tif(item.expired? == true && notifiy == false)\n \t\treturn false\n \telse\n \t\treturn true\n ... | [
"0.72555524",
"0.7141727",
"0.7061713",
"0.7020555",
"0.691659",
"0.68981385",
"0.6887284",
"0.6882717",
"0.68728644",
"0.68728644",
"0.6866883",
"0.6841455",
"0.6839733",
"0.6826875",
"0.6818973",
"0.67970276",
"0.6792768",
"0.6774203",
"0.6762768",
"0.6711058",
"0.6681324",... | 0.6660707 | 23 |
AUCTION CODE NOT BY TEAM 6, made by TEAM 4 during Intermezzo! We are not responsible for auction design We just made their code match Ruby method name conventions because at the beginning they it was all JavaStyle code . | def bid(item, amount)
if can_bid?(item, amount)
previous_winner = item.current_winner
previous_max_bid = item.highest_bid.nil? ? 0 : item.bidders[previous_winner]
item.bidders[self] = amount
# reduce money if user is new winner, otherwise nothing happens
current_winner = item.current_winner
current_max_bid = item.bidders[current_winner]
previous_winner.credits += previous_max_bid unless previous_winner.nil?
current_winner.credits -= current_max_bid
#Do not always send mail for demo purposes
=begin
if !previous_winner.nil? && previous_winner != current_winner
# we got a new winner
Security::MailDispatcher.send_new_winner_mail(previous_winner.email, item) unless [nil, ""].include?(previous_winner.email)
end
=end
else
raise TradeError, "INVALID_BID" #Bid is too small or already exists or user doesn't have enough money.
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def jack_handey; end",
"def koan_4\nend",
"def silly_adjective; end",
"def buzzword; end",
"def buzzword; end",
"def koan_3\nend",
"def ninety_nine_bottles_of_beer\nend",
"def ninety_nine_bottles_of_beer\nend",
"def ninety_nine_bottles_of_beer\nend",
"def king_richard_iii; end",
"def method_124... | [
"0.7063156",
"0.66484076",
"0.6564346",
"0.65059173",
"0.65059173",
"0.6502689",
"0.64307857",
"0.64307857",
"0.64307857",
"0.6387483",
"0.6289124",
"0.62881607",
"0.62881607",
"0.62881607",
"0.62881607",
"0.62881607",
"0.62881607",
"0.62881607",
"0.6231263",
"0.6219352",
"0.... | 0.0 | -1 |
checks whether trader already has a similar item in his inventory | def check_for_equal_item(name, price, description, item_not_to_compare = nil)
index = items.index {|x| x.name.eql?(name) and x.price.eql?(price) and x.description.eql?(description) and x != item_not_to_compare}
return items[index] unless index == nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def trade_item_with_party(new_item, old_item)\n return false if new_item && !$game_party.has_item?(new_item)\n temp = UI_MSG::ITEM\n UI_MSG.const_set(:ITEM, false)\n $game_party.gain_item(old_item, 1)\n $game_party.lose_item(new_item, 1)\n UI_MSG.const_set(:ITEM, temp)\n return true\n end",
... | [
"0.6481306",
"0.645586",
"0.63714516",
"0.63661486",
"0.63661486",
"0.6328455",
"0.63275975",
"0.62222743",
"0.61834425",
"0.61536324",
"0.6120706",
"0.6105216",
"0.60374576",
"0.60334563",
"0.6033018",
"0.5976975",
"0.59376866",
"0.5921286",
"0.59120154",
"0.5909201",
"0.590... | 0.60371816 | 13 |
returns the trader found by name | def by_name(name)
return User.by_name(name) if User.exists?(name)
Organization.by_name(name) if Organization.exists?(name)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_loader(name)\n @loaders.each do |loader|\n return loader if loader.name == name\n end\n end",
"def trader; end",
"def lister(name)\n lister_class = @listers.find do |lister|\n lister.name == name\n end\n \n if lister_class\n lister_class\n else... | [
"0.632402",
"0.6290499",
"0.59771174",
"0.5910349",
"0.5657011",
"0.5621896",
"0.55718124",
"0.5558965",
"0.5515383",
"0.54553074",
"0.54553074",
"0.5386797",
"0.536628",
"0.53463763",
"0.5308552",
"0.5274393",
"0.52408075",
"0.5218273",
"0.5216964",
"0.52148116",
"0.5209624"... | 0.0 | -1 |
returns true if the system includes a certain trader with the name specified | def exists?(name)
User.exists?(name) || Organization.exists?(name)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def includes_recipe?(recipe_name)\n run_list.include?(recipe_name)\n end",
"def include?(name); end",
"def pbTrainerCheck(tr_type, tr_name, max_battles, tr_version = 0)\r\n return true if !$DEBUG\r\n # Check for existence of trainer type\r\n pbTrainerTypeCheck(tr_type)\r\n tr_type_data = GameData::... | [
"0.5888238",
"0.5787151",
"0.5757915",
"0.5697748",
"0.5591588",
"0.5573237",
"0.5568156",
"0.55568385",
"0.55483603",
"0.5478202",
"0.54692006",
"0.54633176",
"0.5462344",
"0.54104614",
"0.54025984",
"0.53912944",
"0.53881776",
"0.5381641",
"0.53653157",
"0.5353985",
"0.5345... | 0.0 | -1 |
make display delay in seconds | def delay(frame)
(frame*40).to_i.times {Graphics.update}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def redisplay_delay\r\n 20\r\n end",
"def delay(seconds); end",
"def delay(seconds); end",
"def delay\n sleep(2)\n end",
"def delay(seconds)\n sleep(seconds)\n end",
"def delay; end",
"def delay; end",
"def delay; end",
"def delay_time\n end",
"def delay\n \"%3d days %2d h... | [
"0.817539",
"0.7338207",
"0.7338207",
"0.7234594",
"0.72319514",
"0.70718074",
"0.70718074",
"0.70718074",
"0.6912656",
"0.6888546",
"0.68167716",
"0.67870784",
"0.666166",
"0.6615868",
"0.658306",
"0.64956176",
"0.64712447",
"0.6469668",
"0.63935375",
"0.6328195",
"0.6229597... | 0.63839656 | 19 |
GET /moneyboxes GET /moneyboxes.json | def index
@moneyboxes = Moneybox.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @cashboxes = Cashbox.all\n end",
"def list_all_tenantcircles_for_a_version_box(args = {}) \n get(\"/aosversions.json/aosversionbox/circles/#{args[:aosVersionBoxId]}\", args)\nend",
"def list_all_aos_version_boxes(args = {}) \n get(\"/aosversions.json/aosversionbox\", args)\nend",
"def get_coi... | [
"0.6577376",
"0.6549823",
"0.65441465",
"0.64175475",
"0.63030446",
"0.62492555",
"0.6243145",
"0.6115511",
"0.6090706",
"0.60815036",
"0.60267776",
"0.6010496",
"0.5971386",
"0.59683895",
"0.59509456",
"0.58704364",
"0.5822551",
"0.58150595",
"0.581109",
"0.5799254",
"0.5778... | 0.7581377 | 0 |
GET /moneyboxes/1 GET /moneyboxes/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @moneyboxes = Moneybox.all\n end",
"def set_moneybox\n @moneybox = Moneybox.find(params[:id])\n end",
"def show\n @money = Money.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @money }\n end\n end",
"... | [
"0.736724",
"0.6672739",
"0.6480729",
"0.64327234",
"0.6415882",
"0.64104277",
"0.63878334",
"0.6286464",
"0.6254037",
"0.6202156",
"0.6179334",
"0.61311936",
"0.6058122",
"0.60506576",
"0.59938073",
"0.59689903",
"0.5932825",
"0.589672",
"0.5885079",
"0.58766013",
"0.5853696... | 0.0 | -1 |
POST /moneyboxes POST /moneyboxes.json | def create
@account = Account.new
# data = params[:moneybox]
@account.name = params[:name]
respond_to do |format|
if @moneybox.save
format.html { redirect_to @moneybox, notice: 'Moneybox was successfully created.' }
format.json { render action: 'show', status: :created, location: @moneybox }
else
format.html { render action: 'new' }
format.json { render json: @moneybox.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @moneyboxes = Moneybox.all\n end",
"def set_moneybox\n @moneybox = Moneybox.find(params[:id])\n end",
"def create\n @box = current_user.boxes.build(params[:box])\n @box.status = 'draft'\n\n respond_to do |format|\n if current_user.address.blank?\n flash[:not... | [
"0.62224865",
"0.6189699",
"0.6116553",
"0.6081428",
"0.60730594",
"0.6062627",
"0.59471655",
"0.5901364",
"0.58348054",
"0.580331",
"0.5766668",
"0.5752638",
"0.5741719",
"0.57053983",
"0.5652516",
"0.5641717",
"0.5632716",
"0.559753",
"0.5586972",
"0.55226356",
"0.5512933",... | 0.65258867 | 0 |
PATCH/PUT /moneyboxes/1 PATCH/PUT /moneyboxes/1.json | def update
respond_to do |format|
if @moneybox.update(moneybox_params)
format.html { redirect_to @moneybox, notice: 'Moneybox was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: 'edit' }
format.json { render json: @moneybox.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @box = Box.find(params[:id])\n\n respond_to do |format|\n if @box.update_attributes(params[:box])\n format.html { redirect_to @box, notice: 'Box was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format... | [
"0.68441975",
"0.65989393",
"0.657906",
"0.65616673",
"0.64943945",
"0.6387296",
"0.63081044",
"0.62886214",
"0.62861",
"0.6283163",
"0.6246032",
"0.62444025",
"0.62130284",
"0.61920047",
"0.61198187",
"0.6110951",
"0.6061957",
"0.6053636",
"0.60061836",
"0.6005279",
"0.59672... | 0.72163934 | 0 |
DELETE /moneyboxes/1 DELETE /moneyboxes/1.json | def destroy
@moneybox.destroy
respond_to do |format|
format.html { redirect_to moneyboxes_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @cashbox.destroy\n respond_to do |format|\n format.html { redirect_to cashbox_index_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @cashbox.destroy\n respond_to do |format|\n format.html { redirect_to cashboxes_url, notice: 'Cashbox was successf... | [
"0.7229852",
"0.7117079",
"0.70890284",
"0.7074077",
"0.6972092",
"0.69267416",
"0.67843646",
"0.66681075",
"0.66362035",
"0.66166526",
"0.6606855",
"0.6599356",
"0.6599271",
"0.6522575",
"0.651303",
"0.65083313",
"0.6485756",
"0.64824367",
"0.6472177",
"0.6461107",
"0.645996... | 0.7852458 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_moneybox
@moneybox = Moneybox.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 |
GET /albums/1 GET /albums/1.json | def show
@album = Album.find(params[:id])
@output = "<div ><br><table class='entries'><br><tr>"
10.times { |i| @output.concat("<th></th>") }
@output.concat("</tr></tr>")
irc = 0
@album.photos.each do |photo|
irc += 1
@output.concat( "<td><div class='thumbnail'><a href='/photos/show?id=".concat(photo.id.to_s) )
@output.concat( "'><img class='icons' src='/images/".concat(photo.path) )
@output.concat( "/".concat(photo.image))
@output.concat( "' /></a></div></td>\n")
if irc == 10
irc = 0
@output.concat( "</tr>\n<tr>" )
end
end
@output.concat( "</tr>\n</table>\n</div>" )
# respond_to do |format|
# format.html # show.html.erb
#format.json { render json: @album }
# end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def album\n album = Album.find(params[:id])\n render json: album\n end",
"def get_album album_id\n get(\"/albums/#{album_id}\")\n end",
"def index\n @albums = Album.all\n render json: @albums\n end",
"def albums\n if params[:artist_id]\n albums = Artist.find(params[:ar... | [
"0.8010893",
"0.79601175",
"0.7838933",
"0.76931643",
"0.7598457",
"0.7579601",
"0.7575355",
"0.75562096",
"0.75089633",
"0.7500134",
"0.74333906",
"0.7426798",
"0.7391768",
"0.73389864",
"0.7287336",
"0.7271081",
"0.72389615",
"0.7209903",
"0.7200635",
"0.7192762",
"0.719262... | 0.0 | -1 |
GET /albums/new GET /albums/new.json | def new
@album = Album.new
respond_to do |format|
format.html # new.html.erb
#format.json { render json: @album }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @album = current_user.albums.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @album }\n end\n end",
"def new\n @album = Album.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @album }\n ... | [
"0.8188497",
"0.7981985",
"0.7981985",
"0.78127694",
"0.7684331",
"0.7587475",
"0.7581201",
"0.75649863",
"0.7560995",
"0.7540411",
"0.7529835",
"0.7486769",
"0.7486765",
"0.7453004",
"0.7450529",
"0.7412938",
"0.7363582",
"0.73290324",
"0.7294751",
"0.72580093",
"0.72580093"... | 0.78804016 | 3 |
POST /albums POST /albums.json | def create
@album = Album.new(params[:album])
respond_to do |format|
if @album.save
#Dir.chdir("public/images")
Dir.mkdir(@album['directory'])
flash[:notice] = 'Album was successfully created.'
#flash[:notice] = Dir.pwd
format.html { redirect_to @album }
#format.json { render json: @album, status: :created, location: @album }
else
format.html { render action = "new" }
#format.json { render json: @album.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_albums\n url = 'https://stg-resque.hakuapp.com/albums.json'\n uri = URI(url)\n response = Net::HTTP.get(uri)\n albums = JSON.parse(response)\n\n albums.each do |album|\n Album.create!(album.except('id'))\n end\nend",
"def create\n @album = current_user.albums.build(album_params)\n\n res... | [
"0.7753841",
"0.728448",
"0.72349143",
"0.7196897",
"0.7180527",
"0.7081311",
"0.7081311",
"0.7081311",
"0.7004145",
"0.7004145",
"0.69842875",
"0.6973087",
"0.69712293",
"0.6958873",
"0.694998",
"0.69284946",
"0.6897242",
"0.68912",
"0.6847369",
"0.6824543",
"0.6823664",
"... | 0.6240188 | 66 |
PUT /albums/1 PUT /albums/1.json | def update
@album = Album.find(params[:id])
respond_to do |format|
if @album.update_attributes(params[:album])
flash[:notice] = 'Album was successfully updated.'
format.html { redirect_to @album }
format.json { head :no_content }
else
format.html { render action = "edit" }
# format.json { render json: @album.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @album = current_user.albums.find(params[:id])\n\n respond_to do |format|\n if @Album.update_attributes(params[:album])\n format.html { redirect_to @album, notice: 'album was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render ... | [
"0.68898857",
"0.6792222",
"0.6670106",
"0.6660307",
"0.6606993",
"0.6606993",
"0.65957916",
"0.6580667",
"0.6580667",
"0.6580667",
"0.6578174",
"0.6538606",
"0.6499689",
"0.64891946",
"0.64501524",
"0.64501524",
"0.64501524",
"0.6420907",
"0.64052725",
"0.64043105",
"0.63698... | 0.63631684 | 26 |
DELETE /albums/1 DELETE /albums/1.json | def destroy
@album = Album.find(params[:id])
@album.destroy
# Dir.chdir("public/images")
Dir.delete(@album['directory'])
respond_to do |format|
format.html { redirect_to albums_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n\n @album = @user.albums.find(params[:id])\n @album.destroy\n\n respond_to do |format|\n format.html { redirect_to albums_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @album.destroy\n render json: @album\n end",
"def destroy\n @album = Albu... | [
"0.801051",
"0.79122156",
"0.7840477",
"0.77915406",
"0.77915406",
"0.77915406",
"0.77915406",
"0.77915406",
"0.7785304",
"0.7780388",
"0.7775917",
"0.77713436",
"0.77632475",
"0.77632475",
"0.77632475",
"0.7684608",
"0.7640788",
"0.7640206",
"0.76009154",
"0.7557025",
"0.754... | 0.71876234 | 59 |
GET /suggested_ages GET /suggested_ages.json | def index
@suggested_ages = SuggestedAge.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_suggested_age\n @suggested_age = SuggestedAge.find(params[:id])\n end",
"def suggested_age_params\n params.require(:suggested_age).permit(:name)\n end",
"def index_by_age_sorted_by_price\n @age = Age.find(params[:age_id])\n @gifts = @age.gifts\n render json: @gifts, inclu... | [
"0.64890534",
"0.617056",
"0.58913225",
"0.58588105",
"0.5774988",
"0.57044846",
"0.5673096",
"0.5631754",
"0.55987513",
"0.5589724",
"0.55795664",
"0.55722576",
"0.5570519",
"0.5561018",
"0.5551909",
"0.55376065",
"0.55047417",
"0.54952925",
"0.5468958",
"0.5448533",
"0.5438... | 0.7210646 | 0 |
GET /suggested_ages/1 GET /suggested_ages/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @suggested_ages = SuggestedAge.all\n end",
"def set_suggested_age\n @suggested_age = SuggestedAge.find(params[:id])\n end",
"def suggested_age_params\n params.require(:suggested_age).permit(:name)\n end",
"def show\n @gage = Gage.find(params[:id])\n\n respond_to do |form... | [
"0.7099652",
"0.67179596",
"0.6148087",
"0.60026646",
"0.5952918",
"0.5890401",
"0.58126235",
"0.5792887",
"0.5769358",
"0.5689199",
"0.56374407",
"0.5620202",
"0.5611857",
"0.5598545",
"0.55929244",
"0.5569114",
"0.55652297",
"0.5563592",
"0.556017",
"0.5532992",
"0.5529653"... | 0.0 | -1 |
POST /suggested_ages POST /suggested_ages.json | def create
@suggested_age = SuggestedAge.new(suggested_age_params)
respond_to do |format|
if @suggested_age.save
format.html {
flash[:notice] = 'La edad sugerida se creó satisfactoriamente.'
redirect_to suggested_ages_path
}
format.json { render :show, status: :created, location: @suggested_age }
else
format.html { render :new }
format.json { render json: @suggested_age.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def suggested_age_params\n params.require(:suggested_age).permit(:name)\n end",
"def set_suggested_age\n @suggested_age = SuggestedAge.find(params[:id])\n end",
"def index\n @suggested_ages = SuggestedAge.all\n end",
"def update\n respond_to do |format|\n if @suggested_age.update(... | [
"0.6687431",
"0.62753564",
"0.6156147",
"0.59321713",
"0.5755394",
"0.55906904",
"0.54308695",
"0.5430047",
"0.54174876",
"0.539183",
"0.539162",
"0.53759205",
"0.53399396",
"0.53324497",
"0.5327658",
"0.5311165",
"0.53110087",
"0.5286432",
"0.52847314",
"0.5279038",
"0.52531... | 0.6861874 | 0 |
PATCH/PUT /suggested_ages/1 PATCH/PUT /suggested_ages/1.json | def update
respond_to do |format|
if @suggested_age.update(suggested_age_params)
format.html {
flash[:notice] = 'La edad sugerida se actualizó satisfactoriamente.'
redirect_to suggested_ages_path
}
format.json { render :show, status: :ok, location: @suggested_age }
else
format.html { render :edit }
format.json { render json: @suggested_age.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_suggested_age\n @suggested_age = SuggestedAge.find(params[:id])\n end",
"def update\n @gage = Gage.find(params[:id])\n\n respond_to do |format|\n if @gage.update_attributes(params[:gage])\n format.html { redirect_to @gage, notice: 'Gage was successfully updated.' }\n form... | [
"0.64502907",
"0.6194011",
"0.61906266",
"0.60452795",
"0.6040802",
"0.60342443",
"0.60311645",
"0.6014141",
"0.60067177",
"0.5993743",
"0.59886533",
"0.5961253",
"0.59359497",
"0.59280133",
"0.5927895",
"0.5898095",
"0.58975756",
"0.5894361",
"0.5892792",
"0.5889187",
"0.588... | 0.7048096 | 0 |
DELETE /suggested_ages/1 DELETE /suggested_ages/1.json | def destroy
@suggested_age.destroy
respond_to do |format|
format.html {
flash[:notice] = 'La edad sugerida se eliminó satisfactoriamente.'
redirect_to suggested_ages_path
}
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @gage = Gage.find(params[:id])\n @gage.destroy\n\n respond_to do |format|\n format.html { redirect_to gages_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @advocacy = Advocacy.find(params[:id])\n @advocacy.destroy\n\n respond_to do |format|\n ... | [
"0.6958503",
"0.6870441",
"0.67324245",
"0.67225105",
"0.6712022",
"0.66936725",
"0.668789",
"0.66814315",
"0.6667803",
"0.6658467",
"0.6640429",
"0.66345865",
"0.66145176",
"0.66112804",
"0.65976185",
"0.65950966",
"0.6594942",
"0.65878034",
"0.6583884",
"0.657517",
"0.65729... | 0.7465402 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_suggested_age
@suggested_age = SuggestedAge.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6165152",
"0.60463154",
"0.59467196",
"0.5917112",
"0.5890387",
"0.58345735",
"0.57773316",
"0.56991524",
"0.56991524",
"0.565454",
"0.5622282",
"0.54232633",
"0.54119074",
"0.54119074",
"0.54119074",
"0.53937256",
"0.53801376",
"0.5358599",
"0.53412294",
"0.5340814",
"0.5... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def suggested_age_params
params.require(:suggested_age).permit(:name)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",... | 0.0 | -1 |
Given an array of numbers and a target number, write a function to check if two numbers in the list sum equal to the target number. You should ask / they may ask solve before looking at this. (select to view) What if the list is sorted? Can you do it without using additional memory? | def two_number_sum array, n
array.sort!
reverse_index = array.size - 1
index = 0
while index >= reverse_index
if array[index] + array[reverse_index] > n
reverse_index -= 1
elsif array[index] + array[reveres_index] < n
index += 1
else
puts "#{array[index]} + #{array[reverse_index]}"
index += 1
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ok_two_sum(arr, target)\n sorted = quick_sort(arr)\n\n arr.each do |el|\n b_target = target - el\n return true if b_search(arr, b_target)\n end\n false\nend",
"def okay_two_sum?(arr, target)\n arr.sort!\n\n arr.select! { |el| el < target }\n\n arr.each { |el| arr.include?(target - el) ? (return ... | [
"0.812872",
"0.8014042",
"0.7991881",
"0.79207283",
"0.79196185",
"0.79155",
"0.7909621",
"0.7899482",
"0.78901523",
"0.78825253",
"0.78772056",
"0.7875436",
"0.78481394",
"0.78456914",
"0.78445363",
"0.7835107",
"0.78241056",
"0.7814977",
"0.780704",
"0.7805164",
"0.77891034... | 0.0 | -1 |
Remove the nonpath compontents in the path_info (eg. the application context, which is naughtily passed in via the path_info) | def identifier_from_path
@identifier_from_path ||= request.path_info.each_with_object({}) do | (key, value), hash|
case value
when String, Symbol, Numeric
hash[key] = value
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clean_path_info(path_info)\n parts = path_info.split(PATH_SEPS)\n\n clean = []\n\n # Walk over each part of the path\n parts.each do |part|\n # Turn `one//two` or `one/./two` into `one/two`.\n next if part.empty? || part == \".\"\n\n if part == \"..\"\n # Turn `one/two/../` in... | [
"0.71762913",
"0.6885928",
"0.6716323",
"0.6564095",
"0.6539877",
"0.6502877",
"0.6493856",
"0.64874",
"0.6482505",
"0.6471732",
"0.64251405",
"0.64216",
"0.64189816",
"0.63800365",
"0.63728887",
"0.6354283",
"0.63109547",
"0.6241099",
"0.6241099",
"0.62384945",
"0.6236761",
... | 0.0 | -1 |
See comments for base_url in lib/pact_broker/doc/controllers/app.rb | def ui_base_url
request.env["pactbroker.base_url"] || ""
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def base_url\n # Using the X-Forwarded headers in the UI can leave the app vulnerable\n # https://www.acunetix.com/blog/articles/automated-detection-of-host-header-attacks/\n # Either use the explicitly configured base url or an empty string,\n # rather than request.base_url, wh... | [
"0.73768973",
"0.7365687",
"0.71546173",
"0.7089082",
"0.701406",
"0.7009818",
"0.697468",
"0.6877361",
"0.68367034",
"0.68036413",
"0.6803307",
"0.6749636",
"0.67450804",
"0.67395866",
"0.66945314",
"0.6660361",
"0.6650225",
"0.6573239",
"0.6567789",
"0.6558564",
"0.65317833... | 0.7721294 | 0 |
We only use utf8 so leave encoding as it is | def encode(body)
body
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def force_default_encoding; end",
"def default_encoding\n Encoding::UTF_8\n end",
"def utf8\n self.encode('UTF-8', 'binary', :invalid => :replace, :undef => :replace, :replace => '?')\n end",
"def to_utf8!; replace(to_utf8); end",
"def ignore_encoding_error; end",
"def suppress_encoding; end",
... | [
"0.7801877",
"0.7774677",
"0.77638423",
"0.77203697",
"0.7693535",
"0.7692788",
"0.75883067",
"0.75883067",
"0.75883067",
"0.75883067",
"0.75883067",
"0.75883067",
"0.75883067",
"0.75883067",
"0.75883067",
"0.75883067",
"0.75883067",
"0.75883067",
"0.75883067",
"0.75883067",
... | 0.0 | -1 |
Not necessarily an existing integration | def integration
if consumer_specified? && provider_specified?
OpenStruct.new(consumer: consumer, provider: provider)
else
nil
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def integration_name; end",
"def integration\n @integration\n end",
"def integrate!\n raise NotImplementedError.new\n end",
"def integrations; end",
"def integrations; end",
"def missing; end",
"def integration_path(integration)\n \"spec/integration/#{integration}\"\nend",
"def i... | [
"0.7420807",
"0.7124254",
"0.6791569",
"0.661722",
"0.661722",
"0.5888167",
"0.5796363",
"0.5697063",
"0.56926394",
"0.55801815",
"0.5578326",
"0.5578326",
"0.55775416",
"0.5544825",
"0.5544825",
"0.554074",
"0.5468669",
"0.5468576",
"0.54601115",
"0.5449964",
"0.54396534",
... | 0.0 | -1 |
Ensure we have valid JSON if a JSON body is required OR if a body has been provided | def content_type_is_json_but_invalid_json_provided?
content_type_json? && ((request_body_required? || any_request_body?) && invalid_json?)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def valid_json(json)\n JSON(json)\n #NOTE: Rescuing TypeError too in case json is not a String\n rescue ::JSON::ParserError, TypeError\n nil\n end",
"def format_body(body, json)\n if json && !body.is_a?(String) && !body.nil?\n body.to_json\n elsif body.is_a?(Stri... | [
"0.71599287",
"0.7132338",
"0.6883168",
"0.6831633",
"0.67973024",
"0.6708845",
"0.66111934",
"0.64998543",
"0.64998543",
"0.6497647",
"0.6497647",
"0.6452888",
"0.6445513",
"0.6441618",
"0.6435888",
"0.64142275",
"0.641292",
"0.6410751",
"0.6361437",
"0.63413286",
"0.6321772... | 0.7447415 | 0 |
TODO rename to put_to_create_supported, otherwise it sounds like it's a policy issue Not a Webmachine method. This is used by security policy code to identify whether a PUT to a non existing resource can create a new object. | def put_can_create?
false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def can_create?(obj)\n false\n end",
"def can_create?(obj)\n false\n end",
"def patch_can_create?\n false\n end",
"def http_method_modifies_resource?\n ['PUT','POST','PATCH'].include?(method.to_s.upcase)\n end",
"def should_fail_to_create(key, value, error, message)\n ... | [
"0.712357",
"0.712357",
"0.7070993",
"0.6593049",
"0.6552015",
"0.62096786",
"0.6202629",
"0.60856044",
"0.60856044",
"0.6028774",
"0.5995979",
"0.5974593",
"0.5965384",
"0.59235704",
"0.589666",
"0.58952254",
"0.5871741",
"0.5871741",
"0.5871741",
"0.5871741",
"0.5871741",
... | 0.7974128 | 0 |
TODO rename to patch_to_create_supported, otherwise it sounds like it's a policy issue Not a Webmachine method. This is used by security policy code to identify whether a PATCH to a non existing resource can create a new object. | def patch_can_create?
false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def can_create?(obj)\n false\n end",
"def can_create?(obj)\n false\n end",
"def put_can_create?\n false\n end",
"def http_method_modifies_resource?\n ['PUT','POST','PATCH'].include?(method.to_s.upcase)\n end",
"def can_create?\n allows_current_user_access_to? :create\... | [
"0.7045069",
"0.7045069",
"0.66991454",
"0.6512275",
"0.61496884",
"0.6131855",
"0.608308",
"0.60082823",
"0.598155",
"0.594934",
"0.594934",
"0.594934",
"0.594934",
"0.594934",
"0.594934",
"0.594934",
"0.59413767",
"0.59257287",
"0.59175366",
"0.590046",
"0.5866973",
"0.58... | 0.81165093 | 0 |
Test 5: User clicks "Show me how" links on Post and Profile pages, verify redirect | def test_05_1_show_me_how_TC_24406
profileLogin
$browser.goto($patch_note)
$help_post_note.when_present.click
sleep 4
$browser.window(:title, /Post a Note/).use do
begin
assert $browser.text.include?("Post a Note")
rescue => e
puts e
puts "J1_T5.1: FAILED! User unable to navigate to zendesk."
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_00090_homepage_open_q_conv_link\n @browser.wait_until { @home_page.open_questions_widget.present? }\n @browser.wait_until { @home_page.open_questions_widget.posts.size > 0 }\n\n # verify the title link would redirect to conversation page.\n q_title = @home_page.open_questions_widget.posts[0].t... | [
"0.68827313",
"0.68318945",
"0.6793401",
"0.6793401",
"0.6739242",
"0.67050105",
"0.6621171",
"0.6621171",
"0.66067725",
"0.6565344",
"0.6562046",
"0.6546416",
"0.64884603",
"0.6480746",
"0.6463968",
"0.6463968",
"0.6454605",
"0.6429782",
"0.6425806",
"0.6416103",
"0.64132535... | 0.65168864 | 12 |
Converts the string to a boolean "true".to_bool => true "false".to_bool => false | def to_bool
return false if self.downcase == "false"
return true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_bool(str)\n str = str.to_s.downcase\n return true if str == 'yes' or str == 'true' or str == 'on'\n return true if str.to_i > 0\n return false\n end",
"def to_boolean(string)\n string == 'true'\nend",
"def to_boolean(str)\n str == 'true'\nend",
"def to_bool(questionable_string... | [
"0.86649567",
"0.8543993",
"0.85295564",
"0.82630265",
"0.8242424",
"0.81943107",
"0.81917495",
"0.8149654",
"0.8077559",
"0.80358285",
"0.79957235",
"0.79891443",
"0.7987769",
"0.7974454",
"0.7953322",
"0.790496",
"0.7868229",
"0.78168315",
"0.7782671",
"0.77438676",
"0.7672... | 0.788407 | 16 |
Applies all configuration settings. This is done by the Auth system after it has been configured but before it processes any requests. | def configure!
begin
configuration.apply!
rescue NameError
puts
puts "WARNING: #{$!.message}"
puts
puts "This happened while trying to configure Sparkly Authentication."
puts "You should verify that /config/initializers/sparkly_authentication.rb"
puts "is set up properly. It could be that you just haven't created the"
puts "model yet. If so, this error will disappear when the model exists."
puts
if ENV['AUTH_BACKTRACE']
puts $!.backtrace
else
puts "(Run with AUTH_BACKTRACE=true to see a full bactrace.)"
end
puts
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def config_setup\n [\n Project,\n Affiliate,\n Employee,\n EmployeeSession,\n Ldaper,\n User,\n UserSession,\n Company,\n Admin\n ].each do |model|\n unless model.respond_to?(:original_acts_as_authentic_config)\n model.class_a... | [
"0.62537414",
"0.6008304",
"0.5816012",
"0.58047295",
"0.57726765",
"0.57332164",
"0.5732247",
"0.5719787",
"0.56987303",
"0.56964314",
"0.5689174",
"0.56471246",
"0.56466436",
"0.5646281",
"0.56186295",
"0.5608729",
"0.5585525",
"0.5585525",
"0.5585525",
"0.5547935",
"0.5543... | 0.58370614 | 2 |
Useful for cleaning up after tests, but probably not much else. | def reset_configuration!
@configuration = Auth::Configuration.new
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cleanup!; end",
"def cleanup!; end",
"def cleanup; end",
"def cleanup; end",
"def cleanup; end",
"def cleanup; end",
"def cleanup\n end",
"def cleanup\n end",
"def cleanup\n end",
"def cleanup\n end",
"def cleanup\n end",
"def cleanup\n end",
"def cleanup\n end",
"def c... | [
"0.8593671",
"0.8593671",
"0.85142034",
"0.85142034",
"0.85142034",
"0.85142034",
"0.84191006",
"0.84191006",
"0.84191006",
"0.84191006",
"0.8401564",
"0.8401564",
"0.8401564",
"0.81836903",
"0.817005",
"0.817005",
"0.8081445",
"0.79804903",
"0.7960377",
"0.7960377",
"0.78782... | 0.0 | -1 |
A Fibonacci sequence is a list of numbers that begins with 0 and 1, and each subsequent number is the sum of the previous two. For example, the first seven Fibonacci numbers are: 0 1 1 2 3 5 8 Write a method that will return the nth number of the sequence. The syntax is easy, getting your head around the algorithm is the challenge. Write the sequence on a piece of paper first and think about the steps you take for each number. Translate this to pseudocode and then to ruby. Difficulty: 6/10 Example: nthFibonacci(0) > 0 nthFibonacci(3) > 2 nthFibonacci(6) > 8 Check your solution by running the tests: ruby tests/11_fibonacci_test.rb | def nthFibonacci (n)
# Your code here
fArr = []
a = 0
b = 1
if n == 0
fArr << 0
elsif n == 1
fArr << 0
elsif n > 1
fArr << 0
while fArr.size < n+1 do
fArr << b
a,b = b,a+b
end
end
return fArr[n]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def nthFibonacci (n)\n \n if n == 0\n return 0\n end\n\n i = 0\n\n sequence = Array.new\n\n sequence.push(i)\n\n i += 1\n\n sequence.push(i)\n\n while i < n do\n sequence[i+1] = (sequence[-1]) + (sequence[-2])\n\n i += 1\n end\n\n sequence[-1]\nend",
"def nthFibonacci (n)\r\n num = n.to_i\r\... | [
"0.8714323",
"0.84712553",
"0.8459169",
"0.8453728",
"0.83955956",
"0.83687186",
"0.8356863",
"0.8319983",
"0.8306515",
"0.82503283",
"0.82440555",
"0.8229246",
"0.8225465",
"0.81880456",
"0.8179822",
"0.81740445",
"0.81654406",
"0.81647575",
"0.8158253",
"0.8151678",
"0.8151... | 0.81505847 | 21 |
Get list of dishes and their price. | def extract_menu(html_str: "")
doc = Nokogiri::HTML(html_str)
menu = []
name = nil
price = nil
doc.css(DISH_CONTAINER).each do |dish|
name = dish.css(DISH_NAME)&.text&.strip
price = dish.css(DISH_PRICE)&.text&.strip
unless name&.empty? || price&.empty? then
menu << [ name.dup, price.dup ]
end
end
menu.sort
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def prices(id, where)\n Price.find(:all, :conditions=>\"dish_id=#{id} and freezer='#{where}'\")\n end",
"def all_prices\n request :public, :get, :price\n end",
"def fetch\n Abacos.prices_available.map do |s|\n {\n id: s[:codigo_produto],\n code_abacos: s[:codig... | [
"0.65727437",
"0.62177855",
"0.620673",
"0.6099644",
"0.6045481",
"0.60226953",
"0.59932965",
"0.5928427",
"0.5899748",
"0.58992505",
"0.5818574",
"0.5818574",
"0.5818574",
"0.58117384",
"0.57902557",
"0.5782728",
"0.57309794",
"0.56644607",
"0.56474084",
"0.5611582",
"0.5608... | 0.0 | -1 |
Use callbacks to share common setup or constraints between actions. | def set_chart
@chart = Chart.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6165152",
"0.60463154",
"0.59467196",
"0.5917112",
"0.5890387",
"0.58345735",
"0.57773316",
"0.56991524",
"0.56991524",
"0.565454",
"0.5622282",
"0.54232633",
"0.54119074",
"0.54119074",
"0.54119074",
"0.53937256",
"0.53801376",
"0.5358599",
"0.53412294",
"0.5340814",
"0.5... | 0.0 | -1 |
Only allow a trusted parameter "white list" through. | def chart_params
params.require(:chart).permit(:name, :birth_date, :is_female)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allowed_params\n ALLOWED_PARAMS\n end",
"def expected_permitted_parameter_names; end",
"def param_whitelist\n [:role, :title]\n end",
"def default_param_whitelist\n [\"mode\"]\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def permitted_params\n []\n end",
... | [
"0.7121987",
"0.70541996",
"0.69483954",
"0.6902367",
"0.6733912",
"0.6717838",
"0.6687021",
"0.6676254",
"0.66612333",
"0.6555296",
"0.6527056",
"0.6456324",
"0.6450841",
"0.6450127",
"0.6447226",
"0.6434961",
"0.64121825",
"0.64121825",
"0.63913447",
"0.63804525",
"0.638045... | 0.0 | -1 |
Repo branches repo String Returns Array of String | def branches(repo)
api.branches(repo).index_by(&:name)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def branch_list\n raw_branches = `cd #{project_repo_path} && git branch -r`\n branches = raw_branches.split(/\\n/)\n return branches\n end",
"def all_branches\n %x( git branch ).gsub!('*', '').gsub!(' ', '').split(\"\\n\")\nend",
"def branches\n client.branches(repo)\n end",
"def git_bra... | [
"0.7788227",
"0.74197316",
"0.7348036",
"0.7294212",
"0.7220462",
"0.72154063",
"0.71461535",
"0.71119773",
"0.68253976",
"0.67720544",
"0.6686774",
"0.6686774",
"0.66657984",
"0.6659355",
"0.6600116",
"0.65570086",
"0.6509384",
"0.6502099",
"0.648939",
"0.648908",
"0.6470959... | 0.74186575 | 2 |
Repo default branch repo String Returns String | def default_branch(repo)
api.repository(repo).default_branch
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def default_branch(remote)\n remote_url = `git config remote.#{Shellwords.escape remote}.url`.chomp\n repo_name = begin\n URI.parse(remote_url).path[1..-5]\n rescue ::URI::InvalidURIError\n remote_url.split(':', 2).last[0..-5]\n end\n\n if File.basename(repo_name).end_with? '.github.io'\n ... | [
"0.75469035",
"0.7525122",
"0.7379428",
"0.7341523",
"0.7315713",
"0.7303584",
"0.7209377",
"0.70735836",
"0.7045799",
"0.703733",
"0.70351595",
"0.6949105",
"0.69330627",
"0.69186383",
"0.6903201",
"0.6899998",
"0.68956953",
"0.68951356",
"0.68821067",
"0.6851813",
"0.681878... | 0.7686027 | 0 |
Repo branch latest commit sha repo String branch String (optional) Returns String | def recent_revision(repo, branch = nil)
branch ||= default_branch(repo)
api.branch(repo, branch).commit.sha
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_branch_sha\n cmd = \"git ls-remote '#@repo_url' | awk '/#@branch/ {print $1}'\"\n puts cmd\n @branch_sha ||= %x[#{cmd}].chomp\n raise 'Could not get branch sha!' unless $?.success?\n @branch_sha\n end",
"def newest_svn_commit_on_branch(repo_path, branch)\n `(cd \"#{repo_path}\" && git ... | [
"0.7826191",
"0.7736685",
"0.75227183",
"0.74715585",
"0.74659103",
"0.71925575",
"0.70658815",
"0.7027959",
"0.7015534",
"0.6977012",
"0.6944701",
"0.6882885",
"0.68038183",
"0.67691964",
"0.67566174",
"0.67430663",
"0.67346936",
"0.67108744",
"0.67099273",
"0.6691325",
"0.6... | 0.70099175 | 9 |
Create repo hooks repo String endpoint String Yields hook_id Integer | def add_hooks(repo, endpoint)
hook = api.create_hook(
repo,
'web',
{
url: endpoint,
secret: ENV['GITHUB_SECRET_TOKEN']
},
{
events: %w(push pull_request), active: true,
}
)
yield hook.id
rescue Octokit::UnprocessableEntity => error
raise unless error.message.include? 'Hook already exists'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_hook!\n hook = client.create_hook(\n full_name,\n 'web',\n {\n url: Constants::HOOK_URL,\n content_type: 'json'\n },\n {\n events: ['release'],\n active: true\n }\n )\n\n self.github_hook_id = hook.id\n end",
"def create_hook... | [
"0.66037405",
"0.64660376",
"0.6086982",
"0.58305615",
"0.577721",
"0.57249194",
"0.5651576",
"0.55900484",
"0.55421305",
"0.545491",
"0.5410556",
"0.54031986",
"0.5331591",
"0.52813524",
"0.5265054",
"0.52487266",
"0.522663",
"0.5203098",
"0.51766807",
"0.5162217",
"0.512093... | 0.69875586 | 0 |
Remove repo hooks repo String hook_id Integer | def remove_hooks(repo, hook_id)
api.remove_hook(repo, hook_id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_hook!\n client.remove_hook(full_name, github_hook_id)\n\n self.github_hook_id = nil\n end",
"def delete_hook(id)\n delete(\"/hooks/#{id}\")\n end",
"def delete(user_name, repo_name, hook_id, params={})\n _update_user_repo_params(user_name, repo_name)\n _validate_user_repo_pa... | [
"0.7973188",
"0.7442817",
"0.7292757",
"0.6857257",
"0.6805585",
"0.6790555",
"0.6790454",
"0.6635315",
"0.6573217",
"0.64184344",
"0.6323295",
"0.63057613",
"0.629042",
"0.6259226",
"0.62513006",
"0.62237173",
"0.62119156",
"0.61896896",
"0.61869967",
"0.6150687",
"0.6077260... | 0.8837115 | 0 |
All repos for access_token Returns Array of Hash | def repos
api.repos.map(&:to_hash)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_repos\n # using oauth token to increase limit of request to github api to 5000\n client = Octokit::Client.new :access_token => self.github_token\n (client.repositories self.github_name, {:type => 'all'}).map do |repo|\n repo.full_name\n end\n end",
"def get_all_user_repos\n user = Us... | [
"0.72552896",
"0.7195828",
"0.7124684",
"0.71223515",
"0.7069559",
"0.700496",
"0.69649553",
"0.6962621",
"0.6920793",
"0.6894719",
"0.6890018",
"0.68424547",
"0.683883",
"0.68136215",
"0.6794929",
"0.67660946",
"0.6756994",
"0.67404073",
"0.670515",
"0.6693565",
"0.659786",
... | 0.7971248 | 0 |
Returns organizations where user is admin | def own_organizations
api.org_memberships.select { |org| org[:role] == "admin"}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def organizations_by_user(user)\n @organizations.values.select { |org| org.is_member?(user) }\n end",
"def active_organizations\n admin? ? Organization.all : organizations.map(&organization_mapper).flatten\n end",
"def admins\n app_users.select(&:admin?)\n end",
"def all_organizations\n ... | [
"0.73870474",
"0.7298261",
"0.72521496",
"0.7235908",
"0.72211736",
"0.71670115",
"0.71518266",
"0.70152676",
"0.69716513",
"0.69662064",
"0.69344085",
"0.6912834",
"0.68772995",
"0.6868512",
"0.68435663",
"0.67940855",
"0.6750358",
"0.6749135",
"0.6709109",
"0.66911966",
"0.... | 0.7852174 | 0 |
Computes the total value of all Bitcoin inputs | def total_input
@inputs.inject(:+)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def current_coin_total\n @coins.map(&:value).reduce { |sum, num| sum += num }\n end",
"def compute_total_value\n @value= @net_price * @count\n end",
"def total_in\n @total_in ||= self.in.inject(0){ |m, input|\n m + (input.coinbase? ? total_out : (input.get_prev_out.try(:value) || 0))\n ... | [
"0.7600391",
"0.7212935",
"0.7142149",
"0.7000208",
"0.697509",
"0.68985397",
"0.6883535",
"0.68800914",
"0.6854406",
"0.6835453",
"0.67933196",
"0.6783961",
"0.67829865",
"0.67808646",
"0.6757314",
"0.67529774",
"0.67269516",
"0.6686949",
"0.66571903",
"0.6654099",
"0.664368... | 0.7518649 | 1 |
Computes the total value of all Bitcoin outputs | def total_output
@outputs.inject(:+)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def current_coin_total\n @coins.map(&:value).reduce { |sum, num| sum += num }\n end",
"def compute_total_value\n @value= @net_price * @count\n end",
"def total_coins_value\n json_response({:total_coins_value => @total_coins_val, :status => true, :message => 'calculated'})\n end",
"def get_T... | [
"0.75860184",
"0.7155013",
"0.7079803",
"0.6996463",
"0.6787966",
"0.6787147",
"0.67832524",
"0.6652126",
"0.66318303",
"0.66152173",
"0.6614591",
"0.66003776",
"0.65509325",
"0.65509325",
"0.65394974",
"0.6536221",
"0.65268594",
"0.65208703",
"0.6513868",
"0.647227",
"0.6468... | 0.7608338 | 0 |
Computes the fees paid for the transaction | def fees
total_input - total_output
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def total_fee\n fee + fee2 + fee3 + fee4\n end",
"def fees\n @fees ||= {\n \"insurance_fee\" => (commission * ASSURANCE_SHARE).round(0),\n \"assistance_fee\" => (ASSISTANCE_COST * rental.duration).round(0)\n }.tap { |fees| fees[\"drivy_fee\"] = commission - fees.values.inject(:+) }\n ... | [
"0.7749463",
"0.74608964",
"0.7358724",
"0.7254256",
"0.7245168",
"0.7217393",
"0.7161691",
"0.7154761",
"0.70849466",
"0.70822394",
"0.7076584",
"0.7061791",
"0.7057174",
"0.696606",
"0.6962604",
"0.69495636",
"0.6942314",
"0.6904392",
"0.68831974",
"0.6873501",
"0.6846851",... | 0.78017414 | 0 |
Public: Provides all anagrams for a given word. === Parameter(s) +text+ +String+: The text to anagram. === Return Value +Array+: A list of anagrams. rubocop: disable MethodLength, UnderscorePrefixedVariableName | def anagram(text)
head, tail = [], text.split('')
stack = [[head, tail]]
result = []
while stack.size > 0
head, tail = stack.pop
if tail.size.zero?
result << head
else
tail.each_with_index do |_, i|
_tail = tail.dup
curr = _tail.delete_at(i)
_head = head.dup
_head << curr
stack << [_head, _tail]
end
end
end
result.tap { |r| r.map! { |p| p.join('') }.uniq! }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def anagrams\n word.anagram.words.pluck(:text) - [word.text]\n end",
"def anagrams(word)\n EpicAnagram.find_anagrams(word)\n end",
"def anagrams(word, words)\n # TODO: check if \"words\" has anagrams of \"word\" and return them in an array\nend",
"def find_anagrams( words )\r\n\tif words.empty?\r\n\... | [
"0.7665324",
"0.74199504",
"0.73068136",
"0.70580363",
"0.6995782",
"0.69932926",
"0.6961988",
"0.6936837",
"0.6928857",
"0.6917933",
"0.6877611",
"0.68688315",
"0.68575066",
"0.68531334",
"0.68476975",
"0.68437403",
"0.6835636",
"0.68129665",
"0.6806273",
"0.67977667",
"0.67... | 0.70724434 | 3 |
rubocop: enable MethodLength, UnderscorePrefixedVariableName Public: Checks whether one word or phrase is an anagram of another. === Parameter(s) +phrase_one+ +String+: A word or phrase. +phrase_two+ +String+: A word or phrase that may be an anagram of +phrase_one+. === Return Value +Boolean+: True if one phrase is an anagram of the other, false otherwise. | def anagram?(phrase_one, phrase_two)
phrase_one.split('').sort == phrase_two.split('').sort
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_anagram word1, word2\n \tpermute = permute_word(word1)\n \tpermute.each do |w|\n \t puts w.join\n \t if w.join.eql?(word2)\n \t \treturn true\n \t end\n \tend\n \treturn false\n end",
"def are_anagrams?(word1, word2)\n #si las palabras son anagramas regresa true de lo contrario regresa false... | [
"0.7999213",
"0.77452654",
"0.7714912",
"0.7682446",
"0.75966746",
"0.7537825",
"0.7522081",
"0.7510409",
"0.75014913",
"0.7491602",
"0.74911195",
"0.74911195",
"0.74685204",
"0.7464296",
"0.7457432",
"0.7457432",
"0.7457432",
"0.74527305",
"0.744779",
"0.74465615",
"0.744632... | 0.8612305 | 0 |
Public: Performs frequency analysis on the provided text. === Parameter(s) +text+ +String+: The text to analyze. === Return Value +Hash+: A hash representing the letter frequencies. | def frequency(text)
text = text.downcase.gsub(/\s*/, '')
chars = text.split('')
freqs = Hash[('a'..'z').to_a.zip([0] * 26)]
chars.each { |c| freqs[c] += 1 }
freqs
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def word_frequency(text)\n norm_array = normalize(text).to_a\n freq = { }\n norm_array.each_with_object(Hash.new(0)){|key,hash| hash[key] += 1}\nend",
"def word_freq(text)\n frequency = {}\n unique_words(text).each do |word|\n frequency[word] = 0\n end\n split_normalise(text).each do |word|\n freque... | [
"0.731779",
"0.72305524",
"0.7139432",
"0.70138705",
"0.688126",
"0.68060577",
"0.67000073",
"0.66217005",
"0.64838266",
"0.64221245",
"0.63893574",
"0.63296264",
"0.62854445",
"0.62699956",
"0.62413496",
"0.61716616",
"0.61622936",
"0.61328524",
"0.61181974",
"0.6044382",
"0... | 0.81292146 | 0 |
Public: Calculates the index of coincidence for the given text (see Index_of_coincidence). === Parameter(s) +text+ +String+: The text to analyze. === Return Value +Float+: The index of coincidence for the text. | def ioc(text)
c = 26.0
freqs = frequency(text)
n = text.length
f = freqs.values.reduce(0) { |a, e| a + (e * (e - 1)) }
f / ((n * (n - 1)) / c)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def affected(text)\n occurrences = lines.each_index.select do |i|\n lines[i].start_with?(\"+\") && text.any? { |t| lines[i].include? t }\n end\n occurrences.map do |occ|\n lines[2..occ].reverse.find { |l| l.start_with? \"Index: \" }[7..]\n end\n end",
"def text_... | [
"0.6151377",
"0.5956082",
"0.5904203",
"0.5904203",
"0.5789559",
"0.57890046",
"0.5551213",
"0.5531335",
"0.5522033",
"0.5488921",
"0.5447444",
"0.5418568",
"0.54172283",
"0.5332028",
"0.5323192",
"0.52985203",
"0.5290097",
"0.5173864",
"0.51621234",
"0.51189315",
"0.5078153"... | 0.5084836 | 20 |
Public: Calculates the percentage of text composed of vowels. (Y is not included as a vowel.) === Parameter(s) +text+ +String+: The text to analyze. === Return Value +Float+: The percentage comprising vowels. | def vowels(text)
vowels = %w(A E I O U)
chars = text.upcase.split('')
vowel_count = 0
chars.each { |c| vowel_count += 1 if vowels.include? c }
vowel_count.to_f / text.length
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def vowels(text)\n percent = text.vowels.length / text.length.to_f\n percent * @emphasis[:vowels]\n end",
"def score_text(txt)\n txt_length = txt.length.to_f\n total_score = 0\n\n e_ratio = txt.count('e') / txt_length\n t_ratio = txt.count('t') / txt_length\n a_ratio = txt.count('a') / txt_leng... | [
"0.7840416",
"0.6168757",
"0.5833714",
"0.5800462",
"0.579222",
"0.5754188",
"0.5731221",
"0.5709409",
"0.5648014",
"0.5631721",
"0.561774",
"0.5579635",
"0.54964375",
"0.54412633",
"0.54007244",
"0.5396063",
"0.5382628",
"0.5380566",
"0.53674144",
"0.5347461",
"0.53446966",
... | 0.71767694 | 1 |
Saves the incoming data report to be processed later | def create
data_report = DataReport.new(data_report_params)
# For now the worker is synchronous. Eventually it can be run asynchronously
if data_report.save && report_worker.perform(data_report.id)
render json: {}, status: :ok
elsif data_report.errors.present
render json: data_report.errors, status: :unprocessable_entity
else
render json: {}, status: :internal_server_error
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save_report\n Report.transaction do\n report = Report.create(name: @name,\n start_date: @start_date,\n end_date: @end_date,\n type: @type,\n creator: User.current.id,\... | [
"0.73499906",
"0.73174214",
"0.72133553",
"0.6940421",
"0.68900687",
"0.65710235",
"0.65710235",
"0.656499",
"0.65590143",
"0.6548167",
"0.64839125",
"0.64675695",
"0.64675695",
"0.6416997",
"0.6404166",
"0.6390809",
"0.62898964",
"0.6282825",
"0.62324363",
"0.6209965",
"0.62... | 0.0 | -1 |
The inline worker to migrate the data report | def report_worker
@report_worker ||= DataReportWorker.new
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def perform\n\t\tbegin\n\t\t\tnext_run_at = Time.now + 30.minutes\n\t\t\tDataImporterWorker.perform_at(next_run_at)\n\t\t\tqds = QueryDataSource.find_all_by_enabled(true)\n\t\t\tqds.each do |q|\n\t\t\t\tQueryDataSourceWorker.perform_async(q.id)\n\t\t\tend\n\n\t\t\t#spree data source importer\n\t\t \tspree_data_sou... | [
"0.5945893",
"0.57572097",
"0.5681698",
"0.5650164",
"0.5566229",
"0.556445",
"0.5547763",
"0.55165744",
"0.54743725",
"0.5434695",
"0.541954",
"0.5393376",
"0.5349002",
"0.5316676",
"0.530394",
"0.527761",
"0.52651745",
"0.5207843",
"0.5198338",
"0.5193809",
"0.51920885",
... | 0.61501044 | 0 |
Offset and scale vertice coordinates for map rendering | def map_vertices(mult = 1)
vertices.map do |v|
((v - game_map.offset) * game_map.zoom * mult).to_a
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_display_pos(x, y)\n @display_x = (x + @map.width * 256) % (@map.width * 256)\n @display_y = (y + @map.height * 256) % (@map.height * 256)\n @parallax_x = x\n @parallax_y = y\n end",
"def untransformed_vector(v)\r\n v.map{|x| x/@zoom }\r\n end",
"def cal_pos\n x, y = map_loca... | [
"0.6161229",
"0.60563916",
"0.60165495",
"0.6006493",
"0.59475714",
"0.59425133",
"0.5939935",
"0.593446",
"0.59197176",
"0.59090954",
"0.59085965",
"0.5879614",
"0.58218867",
"0.5818909",
"0.5802727",
"0.5795695",
"0.5779449",
"0.57459235",
"0.5739234",
"0.5736272",
"0.57298... | 0.60409784 | 2 |
Checks if a point is inside the polygon shape of the terrain, returns true if so | def contains? position
# If POI is given instead of location, get location first
position = position.location if PointOfInterest === position
x = position[0]
y = position[1]
# Use the raycasting technique to determine if point is inside polygon
# We are in 2D, which makes it easier.
# We can also choose the direction of the ray, which makes it almost trivial
# (Choose ray paralell to x-achis
intersections = 0
[vertices, vertices.first].flatten.each_cons(2) do |v1, v2|
# Check if we are inside bounding recangle of 2 vertices
v1x = v1[0]
v1y = v1[1]
v2x = v2[0]
v2y = v2[1]
if (v1y < y and y <= v2y) or (v1y >= y and y > v2y)
# check if we are LEFT of or onthe line from v1 to v2 is at this x coordinate
cp.polygon(*p.map_vertices.map{|v| v.to_a}.flatten)
vx = v2x - v1x
vy = v2y - v1y
if (x <= v1x and x < v2x)
intersections +=1
elsif x >= v1x and x > v2x
next
else
x_line = v1x + vx * (y - v1y) / vy
if vy == 0 or vx == 0 or x < x_line
intersections += 1
end
end
end
end
return intersections.odd?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def point_inside?(point)\n Geom.point_in_polygon_2D(point, hexagon(position, RADIUS), true)\n end",
"def inside?(zone)\n inPoly = false\n if zone == nil || zone.count == 0\n return false\n end\n\n lastPointData = Point.new(zone[zone.size-1])\n lastPoint = lastPointData.asMapPoint\n ... | [
"0.78786373",
"0.75921226",
"0.75572115",
"0.7374165",
"0.7271648",
"0.7168096",
"0.70395756",
"0.6995843",
"0.69282925",
"0.6861745",
"0.67810047",
"0.6733664",
"0.6679317",
"0.6673137",
"0.66147876",
"0.6575991",
"0.6575082",
"0.6569133",
"0.6556269",
"0.6550415",
"0.649445... | 0.68823504 | 9 |
Calculates the distance from self (polygon) to a vector or POI | def distance position
return -1 if contains? position
# If POI is given instead of location, get location first
position = position.location if PointOfInterest === position
# Set a ridiculous min distance. Any way around this?
min_dist = 999999999
# Iterate over every edge-point (vertex)
vertices.each_cons(2) do |vertices|
c_v = vertices[0]
o_v = vertices[1]
r = ((c_v - o_v) * (position - o_v)) / (position - o_v).magnitude
if r < 0 then dist = (position - o_v).magnitude
elsif r > 1 then dist = (c_v - position).magnitude
else dist = (position - o_v).magnitude ** 2 - r * (c_v - o_v).magnitude ** 2
end
min_dist = [dist, min_dist].min
end
min_dist
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def distance_to(pt)\n if pt.is_valid?\n vect = GeoFunctions.point_minus_point(pt,@origin)\n GeoFunctions.vector_dot_product(vect, @z_axis)\n else\n nil\n end\n end",
"def distance_to(other)\n pyth(self.x, self.y, other.x, other.y)\n \n# Math.sqrt((other.x - self.x) ** 2 + ... | [
"0.6710497",
"0.6653491",
"0.6636838",
"0.65885985",
"0.6560118",
"0.64400387",
"0.6377738",
"0.6374143",
"0.6362559",
"0.6303656",
"0.6293953",
"0.62795234",
"0.6207172",
"0.61964726",
"0.6186724",
"0.6179033",
"0.61749256",
"0.61479104",
"0.6121144",
"0.6088965",
"0.6088556... | 0.5557853 | 66 |
Offset Polygon Functions Get the orientation of a polygon Pick "bottom left" corner vertex (and adjacent oes) determine orientation matrix of this subpolygon (which is guaranteed to be convex) | def orientation
p1, p2, p3 = *convex_sub_polygon
det = (p2[0]-p1[0])*(p3[1]-p1[1]) - (p3[0]-p1[0])*(p2[1]-p1[1])
@orientation ||= (det < 0)? 1 : -1
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mill_polygon(mill, cent_x, cent_y, diam, \r\n no_sides, depth=nil, cutter_comp=false)\r\n#############################################\r\n if cutter_comp == true\r\n diam -= mill.bit_radius\r\n end #if\r\n #mill.retract()\r\n side_count = 0\r\n curr_angle = 0.0\r\n radius = diam / 2\r\n degre... | [
"0.5706218",
"0.5680307",
"0.55774313",
"0.5497918",
"0.5491631",
"0.54648197",
"0.5400046",
"0.53660953",
"0.53585744",
"0.53214765",
"0.53126967",
"0.528629",
"0.52474815",
"0.52182263",
"0.5201485",
"0.5201322",
"0.5177382",
"0.5163872",
"0.5160315",
"0.5154005",
"0.513752... | 0.73073494 | 0 |
Returns a set of 3 points along a convex subsection of the polygon | def convex_sub_polygon
subsets = []
vertices.each_cons(3) do |p1, p2, p3|
subsets << [p2, [p1, p2, p3]]
end
subsets.sort.first.last
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def polygon_vertices(sides, size)\n return [CP::Vec2.new(-size, size), CP::Vec2.new(size, size), CP::Vec2.new(size, -size), CP::Vec2.new(-size, -size)]\n end",
"def sample_polygon\n polygon(200, [[10.0, 10.0], [180.0, 20.0], [160.0, 150.0], [100.0, 50.0], [20.0,180.0]])\nend",
"def get_3d_polygon()\n ... | [
"0.66696864",
"0.6127653",
"0.59551084",
"0.5934988",
"0.58613807",
"0.58403933",
"0.5786485",
"0.5786485",
"0.5766312",
"0.57596177",
"0.5756885",
"0.5746187",
"0.573527",
"0.57215947",
"0.56538755",
"0.5618196",
"0.5618196",
"0.5618196",
"0.56045294",
"0.5539671",
"0.552242... | 0.8318579 | 0 |
delta: Integer Offset amount | def offset(delta, dist = 1.5)
# set delta according to polygon direction, set veriables for first and last p/l
delta = delta * orientation
p_first, p_last = nil; offset_lines = []
l_first, l_last = nil; offset_points = []
refined_points = []
# Offset lines between 2 consecutive vertices out by delta
vertices.each_cons(2) do |p1, p2|
p_first ||= p1; p_last = p2 # save first and last vector for final line
offset_lines << offset_line(p1, p2, delta)
end
offset_lines << offset_line(p_last, p_first, delta)
# Calculate intersections between adjacent lines for new vertices
offset_lines.each_cons(2) do |l1, l2|
l_first ||= l1; l_last = l2 # save first and last vector for final intersection
offset_points << line_intersection(l1, l2)
end
offset_points.insert(0, line_intersection(l_first, l_last))
# Smooth corners of very acute angles
offset_points.each_with_index do |p, key|
v = p - vertices[key]
if v.magnitude > (dist * delta).abs
p2 = vertices[key] + v.normalize * dist * delta.abs
# normal vector for 2 vertices through a point dist*delta away
cutoff_line = [p2, p2 + v.normal_vector]
[-1, 0].each do |i|
if key + i < 0
n = offset_lines.size - 1
elsif key + i >= offset_lines.size
n = 0
else
n = key + i
end
refined_points << line_intersection(cutoff_line, offset_lines[n])
end
else
refined_points << p
end
end
refined_points
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def offset(original, new)\n return 0 unless original && new\n relative = (new - original).abs\n relative = -relative if new < original\n relative\n end",
"def delta\n @end_point - @start_point\n rescue\n 0\n end",
"def default_offset_amount\n 50\n end",
"def... | [
"0.67868996",
"0.6737235",
"0.66251934",
"0.65755844",
"0.6481874",
"0.6390515",
"0.6336367",
"0.62968785",
"0.6202527",
"0.6200202",
"0.61609715",
"0.6159524",
"0.6131591",
"0.61085075",
"0.61085075",
"0.61085075",
"0.6083769",
"0.60678715",
"0.6055821",
"0.6011714",
"0.5997... | 0.0 | -1 |
calculate line intersections most likely used to calculate new points for an offset polygon | def line_intersection(l1, l2)
x1 = l1[0][0]; x2 = l1[1][0]; x3 = l2[0][0]; x4 = l2[1][0]
y1 = l1[0][1]; y2 = l1[1][1]; y3 = l2[0][1]; y4 = l2[1][1]
denominator = (x1-x2)*(y3-y4) - (y1-y2)*(x3-x4)
return false if denominator == 0
dxy12 = (x1*y2 - y1*x2)
dxy34 = (x3*y4 - y3*x4)
x = (dxy12*(x3-x4) - (x1-x2)*dxy34) / denominator
y = (dxy12*(y3-y4) - (y1-y2)*dxy34) / denominator
WorldGen::Vector[x.round, y.round]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def offset(delta, dist = 1.5)\n # set delta according to polygon direction, set veriables for first and last p/l\n delta = delta * orientation\n p_first, p_last = nil; offset_lines = []\n l_first, l_last = nil; offset_points = []\n refined_points = []\n\n # Offset lines between 2 cons... | [
"0.6644192",
"0.64605063",
"0.6391747",
"0.62180233",
"0.6208858",
"0.6077043",
"0.60586584",
"0.6040088",
"0.60101086",
"0.5901956",
"0.58002627",
"0.57811713",
"0.5762228",
"0.5760642",
"0.57589144",
"0.57589144",
"0.57589144",
"0.57577795",
"0.57391006",
"0.5735076",
"0.56... | 0.62808776 | 3 |
cost is stored in cents | def cost_in_dollars
self.cost / 100.to_f
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cents; end",
"def actual_cost\n self.cost/1000.to_f\n end",
"def calc_total_cost()\n\t\ttotal_cost = @cost.to_i * 0.9\n\tend",
"def total_cost\n # quantity * unit_cost_price\n unit_cost_price\n end",
"def cost\n # Todo pull this from the DB\n 1000\n end",
"def cost\n 1.99\n ... | [
"0.78827745",
"0.7859967",
"0.780307",
"0.7697984",
"0.76807725",
"0.76602143",
"0.76178896",
"0.7613016",
"0.760285",
"0.7590271",
"0.7590271",
"0.75808454",
"0.7573254",
"0.7571516",
"0.75292516",
"0.7527297",
"0.7527297",
"0.75215244",
"0.7510472",
"0.7501266",
"0.7489259"... | 0.79597855 | 0 |
GET /reunion_participantes GET /reunion_participantes.json | def index
@reunion_participantes = ReunionParticipante.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @participantes = Participante.all\n end",
"def get_participants\n user = self.load_user(params)\n meeting = self.load_meeting(params)\n\n if user != nil and meeting != nil\n users = meeting.participants\n send_json(users)\n else\n send_error 401\n end... | [
"0.65341324",
"0.6456688",
"0.6336768",
"0.6336768",
"0.6336768",
"0.6336768",
"0.6336768",
"0.6336768",
"0.6333179",
"0.60533345",
"0.60379845",
"0.6029556",
"0.59963757",
"0.5980109",
"0.59759647",
"0.59687454",
"0.5934961",
"0.59127",
"0.5909372",
"0.5897896",
"0.5856482",... | 0.77123106 | 0 |
GET /reunion_participantes/1 GET /reunion_participantes/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @reunion_participantes = ReunionParticipante.all\n end",
"def index\n @participantes = Participante.all\n end",
"def set_reunion_participante\n @reunion_participante = ReunionParticipante.find(params[:id])\n end",
"def index\n @participants = Participant.all\n end",
"def ind... | [
"0.7641155",
"0.6546381",
"0.6493932",
"0.64642495",
"0.64642495",
"0.64642495",
"0.64642495",
"0.64642495",
"0.64642495",
"0.6375387",
"0.62594587",
"0.6223182",
"0.6117733",
"0.6100213",
"0.60681844",
"0.6058876",
"0.6057905",
"0.6057905",
"0.6057905",
"0.6057905",
"0.60541... | 0.0 | -1 |
POST /reunion_participantes POST /reunion_participantes.json | def create
@reunion_participante = ReunionParticipante.new(reunion_participante_params)
respond_to do |format|
if @reunion_participante.save
format.html { redirect_to @reunion_participante, notice: 'Reunion participante was successfully created.' }
format.json { render :show, status: :created, location: @reunion_participante }
else
format.html { render :new }
format.json { render json: @reunion_participante.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @reunion_participantes = ReunionParticipante.all\n end",
"def create\n\n @reunion = Reunion.new(params[:reunion])\n asistente_ids = params[:asistente_ids]\n respond_to do |format|\n unless asistente_ids.nil? or asistente_ids.size < 2 then\n if @reunion.save\n\n asist... | [
"0.6766301",
"0.6517003",
"0.63479257",
"0.61971337",
"0.5998164",
"0.59765255",
"0.59743035",
"0.59365195",
"0.5928585",
"0.5899314",
"0.5885909",
"0.58291566",
"0.57847625",
"0.57826763",
"0.5775749",
"0.5775749",
"0.5760512",
"0.57528865",
"0.56993395",
"0.566833",
"0.5651... | 0.6457217 | 2 |
PATCH/PUT /reunion_participantes/1 PATCH/PUT /reunion_participantes/1.json | def update
respond_to do |format|
if @reunion_participante.update(reunion_participante_params)
format.html { redirect_to @reunion_participante, notice: 'Reunion participante was successfully updated.' }
format.json { render :show, status: :ok, location: @reunion_participante }
else
format.html { render :edit }
format.json { render json: @reunion_participante.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @participant.update(participant_update_params)\n respond_with(@participant)\n end",
"def update\n @participant = Participant.find(params[:id])\n respond_to do |format|\n if @participant.update_attributes(participant_params)\n format.html { redirect_to @participant, notice: '... | [
"0.6920191",
"0.688601",
"0.6833657",
"0.68277436",
"0.6800636",
"0.6793416",
"0.6737852",
"0.672295",
"0.6712521",
"0.66809267",
"0.6651818",
"0.6645737",
"0.65834254",
"0.6534882",
"0.6508849",
"0.64529866",
"0.63919836",
"0.6247253",
"0.62378466",
"0.6232123",
"0.6221505",... | 0.64498305 | 16 |
DELETE /reunion_participantes/1 DELETE /reunion_participantes/1.json | def destroy
@reunion_participante.destroy
respond_to do |format|
format.html { redirect_to reunion_participantes_url, notice: 'Reunion participante was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @participant.destroy\n respond_to do |format|\n format.html { redirect_to participants_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @participant.destroy\n respond_to do |format|\n format.html { redirect_to participants_url }\n format.json... | [
"0.7235546",
"0.7235546",
"0.72209346",
"0.72061276",
"0.72061276",
"0.7182637",
"0.7098842",
"0.70149934",
"0.6988022",
"0.6969382",
"0.6969382",
"0.6969382",
"0.6956189",
"0.6956189",
"0.6919971",
"0.69035554",
"0.6841168",
"0.68308055",
"0.6802261",
"0.67692906",
"0.676680... | 0.73164445 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_reunion_participante
@reunion_participante = ReunionParticipante.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6165152",
"0.60463154",
"0.59467196",
"0.5917112",
"0.5890387",
"0.58345735",
"0.57773316",
"0.56991524",
"0.56991524",
"0.565454",
"0.5622282",
"0.54232633",
"0.54119074",
"0.54119074",
"0.54119074",
"0.53937256",
"0.53801376",
"0.5358599",
"0.53412294",
"0.5340814",
"0.5... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def reunion_participante_params
params.require(:reunion_participante).permit(:reunion_id, :persona_id, :vendedor_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 |
Notifies everyone who has commented on the video as well as the video owner that someone has commented on that video | def notify_all_users_in_the_conversation(current_user, video, video_owner)
# send e-mail to the video owner unless the person commented on their own video
# or their notification settings say not to
unless (video.user_id == self.user_id)
# for whatever reason, delayed_job won't send the email unless you do it as a delayed_job
UserMailer.delay(:priority => 40).new_comment(self, video_owner, false) if video_owner.send_email_for_new_comments
# Add event to activity feed
UserEvent.delay(:priority => 40).create(:event_type => UserEvent.event_type_value(:comment),
:event_object_id => self.id,
:user_id => video_owner.id,
:event_creator_id => current_user.id)
end
# send e-mail to other people (except the video owner, or the person that just commented)
# that have commented on the video unless their notification settings say not to
users_we_will_not_notify = []
users_we_will_not_notify << video_owner.id << self.user_id
commenters = Comment.where('video_id = ? AND user_id NOT IN (?)', self.video_id, users_we_will_not_notify).group_by(&:user_id)
unless commenters.blank?
commenters.each do |comment_owner_id, comment|
the_commenter = User.find_by_id(comment_owner_id)
# for whatever reason, delayed_job won't send the email unless you do it as a delayed_job
UserMailer.delay(:priority => 40).new_comment(self, the_commenter, true) if the_commenter.send_email_for_replies_to_a_prior_comment
# Add event to activity feed
UserEvent.delay(:priority => 40).create(:event_type => UserEvent.event_type_value(:comment_response),
:event_object_id => self.id,
:user_id => the_commenter.id,
:event_creator_id => current_user.id)
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def notify_watchers(comment_id)\n comment = Comment.find comment_id\n\n article_id = comment.article_id\n favs = Favorite.where(favorable_id: article_id)\n uid = comment.user_id\n ids = []\n favs.each do |f|\n i = f.user_id\n next if uid == i or i == 0\n ids << i\n f.updated_a... | [
"0.6341719",
"0.61025774",
"0.60463345",
"0.60395116",
"0.5946618",
"0.58695436",
"0.5813978",
"0.57936853",
"0.57907104",
"0.5777171",
"0.5762344",
"0.57525826",
"0.5684363",
"0.5681352",
"0.56734",
"0.56484014",
"0.5639869",
"0.56309175",
"0.55900097",
"0.5585",
"0.5575286"... | 0.6805111 | 0 |
p sum_of_range([1, 4]) => 10 p sum_of_range([4, 1]) => 10 | def sum_of_range(arr)
arr[0] < arr[1] ? (arr[0]..arr[1]).reduce(:+) : arr[0].downto(arr[1]).reduce(:+)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sum_of_range(range)\n range.sort! # easiest way to max sure it's in min max order\n # range = [range[1], range[0]] if range[1] < range[0] # longer way to check min/max order\n (range[0]..range[1]).reduce(:+)\nend",
"def get_sum(a,b)\n\trange = b..a\n\trange = a..b if b > a\n\trange.inject(&:+)\nend",
"d... | [
"0.8308774",
"0.78453916",
"0.77965695",
"0.7785309",
"0.7745558",
"0.76876223",
"0.7679498",
"0.76598024",
"0.7606298",
"0.75951713",
"0.7544433",
"0.74849266",
"0.7481171",
"0.7476813",
"0.74693817",
"0.73276687",
"0.7308638",
"0.72997403",
"0.72878706",
"0.7277177",
"0.724... | 0.8161494 | 1 |
if ( str.length() ==0 ) puts s; return end ch = str[0,1] ros = str[1,str.length()1] print_Subsequence(ros,s) print_Subsequence(ros,s+ch) end print_Subsequence("abc","") | def print_Subsequence(str)
if(str.length() == 0 )
base = [];
base.push(".")
return base;
end
ch = str[0,1];
ros = str[1,str.length()-1]
recResult = print_Subsequence(ros)
res=[]
for i in (0..recResult.length-1)
res.push(recResult[i])
end
for i in (0..recResult.length-1)
res.push(ch+recResult[i])
end
return res
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_subs(str)\n result = []\n str.chars.each_index do |current_idx|\n (str.size - current_idx).times do |inner_idx|\n result << str[current_idx..(current_idx + inner_idx)]\n end\n end\n p result\nend",
"def find_subs(string)\n result = []\n arr = string.chars\n arr.each_index do |outer_idx... | [
"0.6843673",
"0.66567266",
"0.66509813",
"0.66106296",
"0.65680367",
"0.65555406",
"0.6536475",
"0.6367481",
"0.6352542",
"0.6348208",
"0.63473046",
"0.63333005",
"0.62908465",
"0.6268469",
"0.625752",
"0.62387353",
"0.6237308",
"0.6235232",
"0.62308496",
"0.6228356",
"0.6198... | 0.81107867 | 0 |
for direct access inner data from own instance | def _autonyms
@autonyms
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def internal_data # nodoc\n _data\n end",
"def data\n DataProxy.new(self)\n end",
"def data() @data ||= Data.new( self ); end",
"def data; end",
"def data; end",
"def data; end",
"def data; end",
"def data; end",
"def data; end",
"def data; end",
"def data; end",
"def data; ... | [
"0.6445963",
"0.6433098",
"0.6407438",
"0.6256322",
"0.6256322",
"0.6256322",
"0.6256322",
"0.6256322",
"0.6256322",
"0.6256322",
"0.6256322",
"0.6256322",
"0.6256322",
"0.6256322",
"0.6256322",
"0.6252811",
"0.62502134",
"0.61215353",
"0.6104824",
"0.60806066",
"0.6060683",
... | 0.0 | -1 |
scope :approved, where(:status_id => Status.where(:status => 'approved').first.id) | def temp_id
#reverting to just plain id, see issue #89
self.id
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def scope_by_status(status)\n case status\n when 'new', 'shipped', 'paid'\n with_scope(:find => { :conditions => {:status => status}}) do\n yield\n end\n else\n yield\n end\n end",
"def status\n \"approved\"\n end",
"def scope\n finder_or_run(:scope)\... | [
"0.6887195",
"0.5895217",
"0.57593375",
"0.5603671",
"0.55531305",
"0.5549762",
"0.5511161",
"0.5509308",
"0.5420376",
"0.5395787",
"0.53955",
"0.5380863",
"0.53639835",
"0.53508085",
"0.5317412",
"0.5298869",
"0.5285759",
"0.52837634",
"0.52837634",
"0.52837634",
"0.52837634... | 0.0 | -1 |
create new status change record on status change | def check_status_change
if self.status_id != @current_status
sc = StatusChange.new
sc.submission_id = self.id
sc.status_id = self.status_id
sc.changed_at = @current_time
sc.comments = status_comments
sc.save
#give sub a global id if approved
if self.status.eq?('approved')
self.guid = generate_guid(@current_time)
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_status(Status status)\n Status.create(group_id: @group_id, status: status)\n end",
"def handle_status_change\n return nil unless self.new_status.present?\n self.status = self.new_status\n if self.new_status == 'active'\n # the user wants to make the ad active now so push out the inac... | [
"0.66669685",
"0.6452245",
"0.6452151",
"0.63089436",
"0.61982274",
"0.61640203",
"0.61028206",
"0.60521525",
"0.60329837",
"0.5996082",
"0.59941417",
"0.5970475",
"0.5970475",
"0.5955967",
"0.59524834",
"0.5933079",
"0.5919985",
"0.5896049",
"0.5881074",
"0.587314",
"0.58672... | 0.70357925 | 0 |
mainmenu(companyname,user,client_hash) Returns option selected by user | def main_menu(companyname="Unknown",username="Unknown",client_hash)
prompt = TTY::Prompt.new(symbols: {marker: ">"})
input = ""
while input != "Exit"
system('clear')
Debug.show "Debug ON\ninput: #{input} | company_name: #{companyname} | username: #{username}"
menuoptions = ["Add new client","Search client","Exit"]
menuoptions.delete("Add new client") if username == "guest"
input = prompt.select("#{companyname} accounts\n\nLogged in as user #{username}\n\nTotal clients: #{client_hash[:clients].length}\n\n", menuoptions)
if input == "Add new client"
client_hash = add_new_client(client_hash)
end
if input == "Search client"
clientsearch(client_hash,username)
end
end
return input
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def booth_main_menu\n prompt.select(\"Welcome Booth Operator, what would you like to do today?\" ) do |menu|\n menu.choice \"View Merchandise\", -> {self.user.check_merchandise}\n menu.choice \"Update Inventory\", -> {self.user.add_to_inventory}\n menu.choice \"List of Custo... | [
"0.6683829",
"0.6619521",
"0.6475951",
"0.6423823",
"0.6411169",
"0.6322222",
"0.62314653",
"0.6187118",
"0.61712605",
"0.61637294",
"0.61376595",
"0.61367303",
"0.6131876",
"0.6098732",
"0.60840327",
"0.6078142",
"0.60523623",
"0.60432315",
"0.6037656",
"0.6008937",
"0.60054... | 0.6884344 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.