query stringlengths 7 6.41k | document stringlengths 12 28.8k | metadata dict | negatives listlengths 30 30 | negative_scores listlengths 30 30 | document_score stringlengths 5 10 | document_rank stringclasses 2
values |
|---|---|---|---|---|---|---|
Cancel an existing order Void/refund all associated payments Set order status to :canceled | def cancel status=:canceled
result = true
# Refund all transactions associated with order
self.select_order_transactions.payments.each do |t|
result = self.braintree_refund_transaction t
end
# Mark the order as canceled if all braintree refunds succeeded
if result
self.edit_mode = ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cancel_order\n if self.status.downcase == \"pending\"\n self.status = \"Canceled\"\n self.save\n self\n else \n \"Error in Order Model\"\n end\n end",
"def cancel_order(source_account, order_id)\n\tputs \"Canceling order: \" + order_id + \" ... | [
"0.78458303",
"0.7582877",
"0.7540186",
"0.7512472",
"0.74816763",
"0.7473918",
"0.7405878",
"0.73773605",
"0.7364883",
"0.7351844",
"0.7143407",
"0.7129811",
"0.7033592",
"0.7025931",
"0.6987079",
"0.69176793",
"0.6871031",
"0.681693",
"0.67890334",
"0.67761767",
"0.6776096"... | 0.764531 | 1 |
Get details of a stored procedure | def stored_procedure(name)
get "#{base_url}/storedprocedures/#{name}"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def inspect\n \"<#{self.class.name}/StoredProcedure name=#{@sproc_name}>\"\n end",
"def get_procedures\n connect_db.fetch(\"SELECT RDB$PROCEDURE_NAME, RDB$PROCEDURE_SOURCE FROM RDB$PROCEDURES\")\n end",
"def procedure_params\n params[:procedure]\n end",
"def to_s\n \"#<procedu... | [
"0.7388445",
"0.6818748",
"0.6778475",
"0.6400616",
"0.63053",
"0.60947293",
"0.60722625",
"0.600247",
"0.583012",
"0.5824742",
"0.58188593",
"0.5730571",
"0.57286793",
"0.56737804",
"0.5666101",
"0.56406224",
"0.55920875",
"0.55916184",
"0.5542823",
"0.55324805",
"0.54893684... | 0.7205838 | 1 |
DELETE /xmt/addons/1 DELETE /xmt/addons/1.json | def destroy
@addon.drop
@addon.save(isinstall: 0)
respond_to do |format|
format.html { redirect_to xmt_addons_url, notice: '卸载成功.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_aos_version(args = {}) \n delete(\"/aosversions.json/#{args[:aosVersionId]}\", args)\nend",
"def destroy\n @addons_combo.destroy\n respond_to do |format|\n format.html { redirect_to addons_combos_url, notice: 'Addons combo was successfully destroyed.' }\n format.json { head :no_content... | [
"0.6735214",
"0.67277354",
"0.6648859",
"0.65678364",
"0.6547034",
"0.6434617",
"0.6434617",
"0.6434617",
"0.6434617",
"0.6413081",
"0.6395515",
"0.6369724",
"0.6368613",
"0.6349269",
"0.6345683",
"0.6269185",
"0.6221252",
"0.6213265",
"0.6203898",
"0.6203898",
"0.6203589",
... | 0.7014161 | 0 |
GET /equipment_line_items GET /equipment_line_items.json | def index
@equipment_line_items = EquipmentLineItem.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @item_line = ItemLine.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @item_line }\n end\n end",
"def set_equipment_line_item\n @equipment_line_item = EquipmentLineItem.find(params[:id])\n end",
"def show\n puts p... | [
"0.6734687",
"0.66849494",
"0.66270417",
"0.65268165",
"0.6526566",
"0.6526566",
"0.6526566",
"0.6526566",
"0.6526566",
"0.6526566",
"0.6526566",
"0.6501052",
"0.6473452",
"0.64032495",
"0.6299003",
"0.62967956",
"0.62814134",
"0.61766535",
"0.61766535",
"0.61766535",
"0.6176... | 0.7343322 | 0 |
POST /equipment_line_items POST /equipment_line_items.json | def create
@equipment_move_buffer = current_equipment_buffer
equipment = Equipment.find(params[:equipment_id])
@equipment_line_item = @equipment_move_buffer.equipment_line_items.build(equipment_id: equipment.id)
respond_to do |format|
if @equipment_line_item.save
format.html { redirect_to... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def equipment_line_item_params\n params.require(:equipment_line_item).permit(:equipment_id, :equipment_move_buffer_id)\n end",
"def create\n @line_item = @order.line_items.new(line_item_params)\n\n if @line_item.save\n render json: @line_item, status: :created, location: [@order, @line_item]\n... | [
"0.715378",
"0.700165",
"0.6992175",
"0.6986218",
"0.69617456",
"0.68617606",
"0.66440517",
"0.6642671",
"0.6616322",
"0.65748125",
"0.65647274",
"0.6480147",
"0.64055717",
"0.63640094",
"0.63508433",
"0.6330478",
"0.63295215",
"0.6323234",
"0.63168323",
"0.63168323",
"0.6290... | 0.74162716 | 0 |
PATCH/PUT /equipment_line_items/1 PATCH/PUT /equipment_line_items/1.json | def update
respond_to do |format|
if @equipment_line_item.update(equipment_line_item_params)
format.html { redirect_to @equipment_line_item, notice: 'Equipment line item was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: 'edit' }
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @item_line = ItemLine.find(params[:id])\n\n respond_to do |format|\n if @item_line.update_attributes(params[:item_line])\n format.html { redirect_to @item_line, notice: 'Item line was successfully updated.' }\n format.json { head :no_content }\n else\n format.html ... | [
"0.72180456",
"0.7070916",
"0.7067693",
"0.7067693",
"0.7067693",
"0.7067693",
"0.7067693",
"0.7054382",
"0.6994966",
"0.6972458",
"0.69691306",
"0.69691306",
"0.69691306",
"0.69354904",
"0.69189715",
"0.68818164",
"0.68818164",
"0.68818164",
"0.68818164",
"0.68818164",
"0.68... | 0.7564775 | 0 |
DELETE /equipment_line_items/1 DELETE /equipment_line_items/1.json | def destroy
@equipment_line_item.destroy
respond_to do |format|
format.html { redirect_to equipment_line_items_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @item_line = ItemLine.find(params[:id])\n @item_line.destroy\n\n respond_to do |format|\n format.html { redirect_to item_lines_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @line_item = LineItem.find(params[:id])\n @line_item.destroy\n\n respo... | [
"0.74537766",
"0.73998326",
"0.73998326",
"0.73998326",
"0.73998326",
"0.7398179",
"0.73776263",
"0.7330342",
"0.7322835",
"0.7316112",
"0.7316112",
"0.7315366",
"0.7294381",
"0.7266991",
"0.72234195",
"0.7218495",
"0.7183648",
"0.7183648",
"0.7183648",
"0.7183648",
"0.718364... | 0.7829396 | 0 |
Returns the UCB::LDAP::Person for this User | def ldap_person
@person ||= UCB::LDAP::Person.find_by_uid(self.login) if self.login
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_user\n results = @ldap.search( :base => options[:ldap][:base], :filter => user_filter)\n return results.first\n end",
"def get_active_directory_user(username, is_registered=false)\n user_attributes = get_ad_user_attributes(username, is_registered)\n return nil if user_attributes.nil?\... | [
"0.6858983",
"0.6063733",
"0.6018299",
"0.59120214",
"0.58487386",
"0.58237636",
"0.58237636",
"0.58237636",
"0.5784712",
"0.57712716",
"0.57703793",
"0.5739711",
"0.56722015",
"0.5615683",
"0.56151265",
"0.56083846",
"0.55936754",
"0.5590984",
"0.554399",
"0.5537872",
"0.552... | 0.7637795 | 0 |
Parses the textbox list of proglangs from "c++,python" etc. to an enumerable object proglangs | def handle_proglangs(proglang_names)
return if !self.undergrad? || proglang_names.nil?
self.proglangs = [] # eliminates any previous proficiencies so as to avoid duplicates
proglang_array = []
proglang_array = proglang_names.split(',').uniq if proglang_names
proglang_array.each do |pl|
self.p... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_command_list\n @list = SES::ExternalText::Languages\n end",
"def index\n words = params[:q] && Shellwords.split(params[:q]).map(&:squish)\n if words.present?\n @with = words.reject{|word| word.first == '-'}\n @without = words.select{|word| word.first == '-'}.map do |word|\n wo... | [
"0.5590375",
"0.5548614",
"0.5345294",
"0.5265395",
"0.52183896",
"0.5173649",
"0.5158272",
"0.51535046",
"0.5131342",
"0.5125924",
"0.51000714",
"0.50984925",
"0.50802815",
"0.50586385",
"0.5038667",
"0.50186735",
"0.49839416",
"0.49807596",
"0.49715447",
"0.49663463",
"0.49... | 0.58714145 | 0 |
Does its best to convert the input into a Boolean. | def convert_to_boolean(input)
case input
when false, 0, '0', 'false', 'no', nil then false
else
true
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_boolean\n # SECURE: BNS 2012-10-09: But may behave oddly for multi-line input\n return true if self == true || self =~ (/^(true|t|yes|y|1)$/i)\n return false if self == false || self.nil? || self =~ (/^(false|f|no|n|0)$/i)\n fail ArgumentError, \"invalid value for Boolean: \\\"#{self}\\\"\"\n e... | [
"0.8342446",
"0.82365483",
"0.81131643",
"0.8107313",
"0.8014266",
"0.79928374",
"0.7984583",
"0.79372895",
"0.78685623",
"0.7838493",
"0.7763114",
"0.77619374",
"0.775726",
"0.7747159",
"0.77257603",
"0.7721171",
"0.7718274",
"0.7699234",
"0.7691891",
"0.7691891",
"0.7674086... | 0.8309957 | 1 |
GET /alternativas GET /alternativas.json | def index
@alternativas = Alternativa.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @alternativos = Alternativo.all\n end",
"def set_alternativa\n @alternativa = Alternativa.find(params[:id])\n end",
"def set_alternativa\n @alternativa = Alternativa.find(params[:id])\n end",
"def set_alternativo\n @alternativo = Alternativo.find(params[:id])\n end",
... | [
"0.69971466",
"0.6498366",
"0.6498366",
"0.64737713",
"0.6409124",
"0.62824976",
"0.61535627",
"0.6129971",
"0.6121928",
"0.60777694",
"0.60193807",
"0.60155755",
"0.59702927",
"0.58695287",
"0.57263297",
"0.5691227",
"0.5677521",
"0.56592166",
"0.56570584",
"0.56557494",
"0.... | 0.7347227 | 0 |
POST /alternativas POST /alternativas.json | def create
@alternativa = Alternativa.new(alternativa_params)
respond_to do |format|
if @alternativa.save
format.html { redirect_to @alternativa, notice: 'Alternativa was successfully created.' }
format.json { render :show, status: :created, location: @alternativa }
else
for... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @alternativo = Alternativo.new(alternativo_params)\n\n respond_to do |format|\n if @alternativo.save\n format.html { redirect_to @alternativo, notice: 'Alternativo was successfully created.' }\n format.json { render :show, status: :created, location: @alternativo }\n else... | [
"0.7301132",
"0.68833977",
"0.6863226",
"0.6854097",
"0.64734524",
"0.64412075",
"0.6407407",
"0.6292914",
"0.62471664",
"0.6233773",
"0.6233773",
"0.59148645",
"0.5905892",
"0.5817316",
"0.58154386",
"0.5765965",
"0.57640475",
"0.56542134",
"0.5650958",
"0.5562129",
"0.55086... | 0.72534 | 1 |
PATCH/PUT /alternativas/1 PATCH/PUT /alternativas/1.json | def update
respond_to do |format|
if @alternativa.update(alternativa_params)
format.html { redirect_to @alternativa, notice: 'Alternativa was successfully updated.' }
format.json { render :show, status: :ok, location: @alternativa }
else
format.html { render :edit }
forma... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n respond_to do |format|\n if @alternativo.update(alternativo_params)\n format.html { redirect_to @alternativo, notice: 'Alternativo was successfully updated.' }\n format.json { render :show, status: :ok, location: @alternativo }\n else\n format.html { render :edit }\n ... | [
"0.6872784",
"0.6501358",
"0.633831",
"0.61324465",
"0.61103684",
"0.6082221",
"0.6075222",
"0.6063081",
"0.60572714",
"0.60572714",
"0.6054513",
"0.6046305",
"0.60377055",
"0.60355407",
"0.60310507",
"0.60140586",
"0.60007405",
"0.59981537",
"0.5982089",
"0.5976963",
"0.5976... | 0.686758 | 1 |
DELETE /alternativas/1 DELETE /alternativas/1.json | def destroy
@alternativa.destroy
respond_to do |format|
format.html { redirect_to alternativas_url, notice: 'Alternativa was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @alternativo.destroy\n respond_to do |format|\n format.html { redirect_to alternativos_url, notice: 'Alternativo was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete\n render json: Alien.delete(params[\"id\"])\n end",
"def delete\n ... | [
"0.73670256",
"0.706965",
"0.69742775",
"0.6925704",
"0.68907547",
"0.6864281",
"0.68156344",
"0.679814",
"0.67820907",
"0.676412",
"0.6752453",
"0.6752453",
"0.67454946",
"0.67203236",
"0.67168784",
"0.67168784",
"0.67168784",
"0.6705388",
"0.66898257",
"0.6679441",
"0.66747... | 0.7395869 | 0 |
operation a +Roomorama::Client::Operations::Diff+ instance client a +Roomorama::Client+ instance properly configured | def initialize(operation, client)
@operation = operation
@roomorama_client = client
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def diff\n @diff ||= instance.client.createDiffHTML(padID: pad.id, startRev: start_rev, endRev: end_rev)\n end",
"def differ\n @differ ||= Differ.new(externals)\n end",
"def diff(from, to=nil)\n scm :diff, repository, authentication, \"-r#{from}:#{to || head}\"\n end",
"def call\n... | [
"0.60112506",
"0.5681368",
"0.5672869",
"0.56727904",
"0.5665033",
"0.56148654",
"0.5597679",
"0.55949694",
"0.5545563",
"0.5542509",
"0.55396247",
"0.55098134",
"0.54937327",
"0.54937327",
"0.5407725",
"0.5405259",
"0.5381243",
"0.5359567",
"0.5359567",
"0.529869",
"0.528405... | 0.6126598 | 0 |
calendar a +Roomorama::Calendar+ instance representing the changes to be applied to a property's availability calendar. Returns a +Result+ that, when successful, wraps the given calendar instance. | def perform(calendar)
result = roomorama_client.perform(operation)
return result unless result.success?
Result.new(calendar)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def process(calendar)\n # if the property trying to have its calendar synchronised was not\n # synchronised by Concierge, then do not attempt to update its calendar,\n # since the API call to Roomorama is going to fail (the +identifier+\n # will not be recognised.)\n return unless synchron... | [
"0.576668",
"0.561302",
"0.5449672",
"0.53009444",
"0.52841675",
"0.52841675",
"0.52841675",
"0.52841675",
"0.52841675",
"0.52841675",
"0.52441454",
"0.52355796",
"0.52255195",
"0.5224125",
"0.52055943",
"0.5170357",
"0.5111265",
"0.50909257",
"0.50413096",
"0.5038781",
"0.49... | 0.59264374 | 0 |
Build an instance of BrandRegistrationOtpInstance | def get_instance(payload)
BrandRegistrationOtpInstance.new(@version, payload, brand_registration_sid: @solution[:brand_registration_sid])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def inspect\n \"<Twilio.Messaging.V1.BrandRegistrationOtpInstance>\"\n end",
"def to_s\n \"<Twilio.Messaging.V1.BrandRegistrationOtpInstance>\"\n end",
"def to_s\n '#<Twilio.Messaging.V1.BrandRegistration... | [
"0.7384454",
"0.67743194",
"0.5816949",
"0.5563608",
"0.5242484",
"0.5218351",
"0.5096465",
"0.50843716",
"0.50616604",
"0.5013985",
"0.49961314",
"0.49814317",
"0.49792665",
"0.49792665",
"0.4971616",
"0.49658054",
"0.49262452",
"0.4915125",
"0.49097523",
"0.48610842",
"0.48... | 0.79249465 | 0 |
create a session for the messaging user and try to authenticate them with the password | def auth(m, password)
user = Justbot::Models::User.first(:name => m.user.nick)
if user.nil? or not user.authenticates? password
sleep 1 # prevent timing attacks?
m.reply(INVALID_USER_OR_PASSWORD, true)
return
end
s = Justbot::Session.new(user, m.u... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_session\n login, password = get_login_and_password\n create_session_with authenticate_user(login, password, :trace => true)\n end",
"def create_session\n req_params = params[:user]\n unless req_params\n @msg = \"Login details not found\"\n render \"objects/msg.json\", status: :u... | [
"0.68972",
"0.6805464",
"0.6733524",
"0.6666626",
"0.6645078",
"0.6594873",
"0.6549482",
"0.65463686",
"0.6469449",
"0.6467599",
"0.6384241",
"0.63797206",
"0.6375418",
"0.6369394",
"0.63602734",
"0.635577",
"0.6317938",
"0.63097334",
"0.6300138",
"0.628385",
"0.6264617",
"... | 0.7019801 | 0 |
start a session and set up a timer to stop it, too | def start_session(s)
# callback to remove the session from play
end_session_timer = Timer(
Justbot::Session::DURATION,
:stop_automatically => false,
:shots => 1,
:threaded => true
) do
s.stop!
end
end_session_t... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def start_timer\n Thread.new do\n loop {\n sleep @session_ttl\n reap_expired_sessions\n } \n end \n end",
"def start_session\n generate_token(:token)\n setup_session\n update_last_session\n end",
"def start_session\n session_tracker.start_session\n ... | [
"0.7459779",
"0.7091194",
"0.7028706",
"0.662788",
"0.65835184",
"0.6501576",
"0.6431445",
"0.635446",
"0.6350405",
"0.62872934",
"0.62767124",
"0.615367",
"0.60600543",
"0.60576093",
"0.6052897",
"0.6034506",
"0.6018608",
"0.60170615",
"0.5985841",
"0.5985428",
"0.5923099",
... | 0.81947666 | 0 |
Reads file from a folder and returns array of content lines. Strips leading and trailing whitespace, including newlines. | def read_file(file)
lines = []
IO.foreach(find(file)) do |line|
lines << line.strip unless line.strip == ''
end
lines
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getFileContent(dir, file):Array\n arr = Array.new\n File.open(\"#{dir}/#{file}\", \"r\").each do |line|\n arr.push line\n end\n arr\n end",
"def get_from_file(path)\n\n array = []\n file = File.open(path)\n if file != nil\n array = file.readlines.map(&:chomp) # Discard the fin... | [
"0.6945614",
"0.6840127",
"0.672195",
"0.6704331",
"0.6659768",
"0.65465933",
"0.65057945",
"0.63903075",
"0.6358061",
"0.6334009",
"0.632364",
"0.63061744",
"0.62727046",
"0.6143623",
"0.6139557",
"0.6111584",
"0.61075675",
"0.6101849",
"0.6100708",
"0.6100708",
"0.6100708",... | 0.70520884 | 0 |
GET /prioridades/1 GET /prioridades/1.json | def show
@prioridade = Prioridade.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @prioridade }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_prioridad\n @prioridad = Prioridad.find(params[:id])\n end",
"def priorities\n Sifter.\n get(\"/api/priorities\").\n parsed_response[\"priorities\"]\n end",
"def index\n @prioridads = Prioridad.all\n end",
"def show\n @prioridade_adocao = PrioridadeAdocao.find(params[:id]... | [
"0.68602914",
"0.6778299",
"0.6587319",
"0.63708174",
"0.635255",
"0.6246057",
"0.6198486",
"0.57488686",
"0.5736397",
"0.5710488",
"0.56294835",
"0.56272113",
"0.5626058",
"0.55687815",
"0.5524008",
"0.543677",
"0.53907895",
"0.5309862",
"0.5302487",
"0.5298157",
"0.5276758"... | 0.7228111 | 0 |
GET /prioridades/new GET /prioridades/new.json | def new
@prioridade = Prioridade.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @prioridade }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @prioridade = Prioridade.new(params[:prioridade])\n\n respond_to do |format|\n if @prioridade.save\n format.html { redirect_to @prioridade, notice: 'Prioridade was successfully created.' }\n format.json { render json: @prioridade, status: :created, location: @prioridade }\n ... | [
"0.7742832",
"0.7336337",
"0.725823",
"0.67994136",
"0.64959276",
"0.64771926",
"0.6462122",
"0.64571977",
"0.63699126",
"0.6359396",
"0.63409084",
"0.63339895",
"0.63205266",
"0.6320355",
"0.6302525",
"0.6287897",
"0.6266362",
"0.623412",
"0.62078196",
"0.6200844",
"0.619619... | 0.8134788 | 0 |
POST /prioridades POST /prioridades.json | def create
@prioridade = Prioridade.new(params[:prioridade])
respond_to do |format|
if @prioridade.save
format.html { redirect_to @prioridade, notice: 'Prioridade was successfully created.' }
format.json { render json: @prioridade, status: :created, location: @prioridade }
else
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @prioridad = Prioridad.new(prioridad_params)\n\n respond_to do |format|\n if @prioridad.save\n format.html { redirect_to @prioridad, notice: 'Se ha creado una nueva Prioridad.' }\n format.json { render :show, status: :created, location: @prioridad }\n else\n format... | [
"0.70679057",
"0.6845849",
"0.6630831",
"0.62737477",
"0.5998517",
"0.58468163",
"0.5691621",
"0.56160337",
"0.5428785",
"0.5353195",
"0.53161705",
"0.5243606",
"0.5241518",
"0.52350783",
"0.5193632",
"0.5176723",
"0.51413196",
"0.5127833",
"0.51077884",
"0.5103316",
"0.50906... | 0.7365912 | 0 |
PUT /prioridades/1 PUT /prioridades/1.json | def update
@prioridade = Prioridade.find(params[:id])
respond_to do |format|
if @prioridade.update_attributes(params[:prioridade])
format.html { redirect_to @prioridade, notice: 'Prioridade was successfully updated.' }
format.json { head :no_content }
else
format.html { rend... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_prioridad\n @prioridad = Prioridad.find(params[:id])\n end",
"def update\n respond_to do |format|\n if @prioridad.update(prioridad_params)\n format.html { redirect_to @prioridad, notice: 'Se ha actualizado la Prioridad.' }\n format.json { render :show, status: :ok, location:... | [
"0.7031581",
"0.7014665",
"0.6580757",
"0.6563585",
"0.63650113",
"0.6196224",
"0.6007768",
"0.5863597",
"0.5685698",
"0.563704",
"0.56051916",
"0.55289173",
"0.53719133",
"0.5347442",
"0.5304482",
"0.52856016",
"0.52787614",
"0.5269795",
"0.52475905",
"0.52205443",
"0.520637... | 0.71978825 | 0 |
DELETE /prioridades/1 DELETE /prioridades/1.json | def destroy
@prioridade = Prioridade.find(params[:id])
@prioridade.destroy
respond_to do |format|
format.html { redirect_to prioridades_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @prioridad.destroy\n respond_to do |format|\n format.html { redirect_to prioridads_url, notice: 'Se ha eliminado la Prioridad.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @prioridade_adocao = PrioridadeAdocao.find(params[:id])\n @prioridade_adocao.de... | [
"0.7238399",
"0.7114864",
"0.6559257",
"0.6489752",
"0.64694107",
"0.63929635",
"0.6392403",
"0.63845396",
"0.6342004",
"0.63398266",
"0.63263386",
"0.63185185",
"0.63168615",
"0.6315532",
"0.6315532",
"0.6311681",
"0.63079846",
"0.63011056",
"0.63003945",
"0.62871087",
"0.62... | 0.7494435 | 0 |
Returns a pointer from a certain position. | def get_pointer_at(index)
IO.binread(@path, POINTER_SIZE, HEADER_SIZE + POINTER_SIZE * index).unpack("N").first
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def at(pos)\n pos = pos.to_int\n\n if 0 <= pos && !has_size?\n return read_access(pos)\n elsif 0 <= pos && pos < size\n return read_access(pos)\n elsif -size <= pos && pos < 0\n return read_access(size + pos)\n else\n return nil\n end\n end",
"def at(position)\n self[pos... | [
"0.6970928",
"0.6819975",
"0.66309315",
"0.6619104",
"0.6619104",
"0.64606345",
"0.63734245",
"0.6283717",
"0.6283717",
"0.6274268",
"0.62027806",
"0.6160391",
"0.6130122",
"0.604367",
"0.6026829",
"0.60121626",
"0.599911",
"0.59691626",
"0.5967498",
"0.596382",
"0.5949572",
... | 0.717713 | 0 |
generate upper quartile value | def upper_quartile
return nil if self.empty?
sorted_array = self.sort
u = (0.25*(3*sorted_array.length))
if (u-u.truncate).is_a?(Integer)
return sorted_array[(u-u.truncate)-1]
else
sample = sorted_array[u.truncate.abs-1]
sample1 = sorted_array[(u.truncate.abs)]
return sample+... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def upperQuartile(node)\n\t\t# Max humidity value from the node in the past day\n\t\tmax_hum = Reading.select(:humidty, :recorded_at).where(node_id: node, recorded_at: Time.zone.now.beginning_of_day..Time.zone.now.end_of_day).maximum(:humidity)\n\t\t# Max temperature value from the node in the past day\n\t\tmax_te... | [
"0.76547885",
"0.75556237",
"0.74556005",
"0.73508096",
"0.72094834",
"0.71289724",
"0.69251245",
"0.68558437",
"0.68357986",
"0.6714768",
"0.6644293",
"0.6552409",
"0.6528319",
"0.65141267",
"0.64158475",
"0.6297665",
"0.6293136",
"0.6206528",
"0.6144667",
"0.6133184",
"0.58... | 0.8381107 | 0 |
generate lower quartile value | def lower_quartile
return nil if self.empty?
sorted_array = self.sort
u = 0.25*sorted_array.length + 1
if (u-u.truncate).is_a?(Integer)
return sorted_array[(u-u.truncate)-1]
else
sample = sorted_array[u.truncate.abs-1]
sample1 = sorted_array[(u.truncate.abs)]
return sample+((... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def upper_quartile\n return nil if self.empty?\n sorted_array = self.sort\n u = (0.25*(3*sorted_array.length))\n if (u-u.truncate).is_a?(Integer)\n return sorted_array[(u-u.truncate)-1]\n else\n sample = sorted_array[u.truncate.abs-1]\n sample1 = sorted_array[(u.truncate.abs)]\n ... | [
"0.7934418",
"0.73654604",
"0.72243565",
"0.7124244",
"0.71010566",
"0.70272595",
"0.6925963",
"0.6925916",
"0.68456227",
"0.68196166",
"0.68000853",
"0.65981805",
"0.6504334",
"0.64692694",
"0.6363976",
"0.63264924",
"0.6234617",
"0.6131828",
"0.6009446",
"0.6008697",
"0.584... | 0.8052058 | 0 |
tabulate elements and frequencies of an Enumerable return [Hash] return a hash of :element => :freq_count | def count_freq
hash = Hash.new(0)
self.each do |element|
hash[element] +=1
end
return hash
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def element_frequency_count\n collection.each_with_object(Hash.new(0)) {|element, occurrence| occurrence[element] += 1}\n end",
"def frequencies\n inject(Hash.new(0)) { |h,v| h[v] += 1; h }\n end",
"def frequency(a)\r\n a.group_by do |e|\r\n e\r\n end.map do |key, values|\r\n [values.size]\r\n ... | [
"0.78163415",
"0.73577553",
"0.71876377",
"0.7151512",
"0.70271146",
"0.69654363",
"0.67742014",
"0.6757071",
"0.6754002",
"0.6748162",
"0.67333263",
"0.6732251",
"0.67198086",
"0.65939933",
"0.6572978",
"0.65581775",
"0.6548955",
"0.6539481",
"0.6493705",
"0.64782935",
"0.64... | 0.80565524 | 0 |
Process for moving any binders | def moveitem
errors = []
@binder = Binder.find(params[:id])
if params[:target] != params[:id]
src = Mongo.log(current_teacher.id.to_s,
__method__.to_s,
params[:controller].to_s,
@binder.id.to_s,
params)
@binder.sift_siblings()
@inherited = inherit_from(params[:target])
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def process_moves\n @delta[:moves].each do |move| process_move(move) end\n end",
"def move\n super\n gravitize\n end",
"def apply\n\t\tunless @already_added\n\t\t\t@space.entities.add @clone\n\t\t\t@already_added = true\n\t\tend\n\t\t\n\t\t@move_action.apply\n\tend",
"def move; end... | [
"0.580114",
"0.57578623",
"0.57086825",
"0.5699426",
"0.5699426",
"0.5660415",
"0.56019205",
"0.5526858",
"0.54920816",
"0.5490215",
"0.547453",
"0.54599464",
"0.5456849",
"0.54387",
"0.54387",
"0.54183704",
"0.5387154",
"0.5384284",
"0.5384211",
"0.5324632",
"0.5316352",
"... | 0.5851964 | 0 |
Because named_binder_route can accept an id or object, so can this check | def binder_routing_ok?(binder, action)
return request.path[0..named_binder_route(binder, action).size - 1] == named_binder_route(binder, action)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has_named_route?(name); end",
"def named_route; end",
"def has_named_route?(name)\n @set.named_routes.key?(name)\n end",
"def route_for(name, *args); end",
"def is_route?\n self.object_type.downcase.to_s == \"route\"\n end",
"def named?\n id.kind_of?(String)\n end",
"def... | [
"0.6605092",
"0.6031678",
"0.57937485",
"0.5731123",
"0.5641658",
"0.55204034",
"0.5489443",
"0.54461247",
"0.54316014",
"0.53647286",
"0.5362761",
"0.53321683",
"0.5304792",
"0.5274534",
"0.5248143",
"0.52430207",
"0.52430207",
"0.5232731",
"0.521501",
"0.5214525",
"0.521433... | 0.60411155 | 1 |
Function that returns routing given a binder object and action Only works for routes in the format of: /username/portfolio(/root)/title/id/action(s) Binder objects preferred over ids | def named_binder_route(binder, action = "show")
if binder.class == Binder
retstr = "/#{binder.handle}/portfolio"
if binder.parents.length != 1
retstr += "/#{CGI.escape(binder.root.gsub(" ", "-"))}"
end
retstr += "/#{CGI.escape(binder.title.gsub(" ", "-"))}/#{binder.id}"
if action != "show"
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def binder_routing_ok?(binder, action)\n\n\t\treturn request.path[0..named_binder_route(binder, action).size - 1] == named_binder_route(binder, action)\n\n\tend",
"def action_routes action\n request_methods, route = REQUEST_METHODS, action.to_s\n REQUEST_METHODS.each do |m|\n regex = /\\A#{m}_/i\n ... | [
"0.65662134",
"0.6253663",
"0.5874944",
"0.5801643",
"0.5786832",
"0.5749082",
"0.5690723",
"0.5687544",
"0.5634518",
"0.5545291",
"0.55431104",
"0.54987216",
"0.54775435",
"0.54440445",
"0.543826",
"0.543826",
"0.54113626",
"0.5399569",
"0.53967315",
"0.53641367",
"0.5351828... | 0.76712173 | 0 |
Creates a task that uses the various template wrappers to make a wrapped output file. There is some extra complexity because Dojo and YUI use different final locations. | def templated_build(name, opts={})
short = name.downcase
source = File.join("wrappers", short)
dependencies = ["mustache.js"] + Dir.glob("#{source}/*.tpl.*")
target_js = opts[:location] ? "mustache.js" : "#{short}.mustache.js"
CLEAN.include(opts[:location] ? opts[:location] : target_js)
desc "Pack... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def templated_build(name, opts={})\n short = name.downcase\n source = File.join(\"wrappers\", short)\n dependencies = [\"mustache.js\"] + Dir.glob(\"#{source}/*.tpl.*\")\n target_js = opts[:location] ? \"mustache.js\" : \"#{short}.mustache.js\"\n\n CLEAN.include(opts[:location] ? opts[:location] : target_js)\... | [
"0.7126494",
"0.69910395",
"0.6898831",
"0.6480727",
"0.63670325",
"0.6307068",
"0.6190587",
"0.611787",
"0.61012465",
"0.60927254",
"0.6072367",
"0.6064941",
"0.60631496",
"0.6052278",
"0.60421336",
"0.6000204",
"0.5987774",
"0.5936244",
"0.5930975",
"0.58978635",
"0.5897863... | 0.7240311 | 0 |
Provides either the passed in HTML, or uses the doc to generate the HTML | def html
@html ||= args.dig(:html) || doc.to_html
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def html_markup_rdoc(text); end",
"def html_markup_asciidoc(text); end",
"def documentation_html\n @documentation_html ||= generate_documentation_html\n end",
"def doc\n # get_html beforehand for good output messages\n html = get_html\n print \"Parsing doc...\"\n doc = Nokogiri::H... | [
"0.7058627",
"0.69723195",
"0.6849613",
"0.6786844",
"0.6728627",
"0.6704008",
"0.6704008",
"0.6662671",
"0.65805125",
"0.65707463",
"0.65493983",
"0.65493983",
"0.65206885",
"0.6505184",
"0.6505184",
"0.64965785",
"0.6481695",
"0.64762354",
"0.646726",
"0.6440871",
"0.641434... | 0.76175046 | 0 |
GET /file_list_items GET /file_list_items.xml | def index
@file_list = UploadedFileList.find(params[:uploaded_file_list_id])
@file_list_items = @file_list.file_list_items.find(:all)
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @file_list_items }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @file_list = UploadedFileList.find(params[:uploaded_file_list_id])\n @file_list_item = @file_list.file_list_items.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @file_list_item }\n end\n end",
"def index\n @list = Lis... | [
"0.7253695",
"0.6748305",
"0.67117727",
"0.66492766",
"0.6624679",
"0.65968746",
"0.6535257",
"0.6501938",
"0.6490047",
"0.6489521",
"0.64878076",
"0.6463209",
"0.6425785",
"0.6424752",
"0.6408849",
"0.6391161",
"0.63708115",
"0.6358394",
"0.6340381",
"0.6295728",
"0.62831795... | 0.7786718 | 0 |
GET /file_list_items/1 GET /file_list_items/1.xml | def show
@file_list = UploadedFileList.find(params[:uploaded_file_list_id])
@file_list_item = @file_list.file_list_items.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @file_list_item }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @file_list = UploadedFileList.find(params[:uploaded_file_list_id])\n @file_list_items = @file_list.file_list_items.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @file_list_items }\n end\n end",
"def index\n @list = List.f... | [
"0.7619156",
"0.6602612",
"0.65204906",
"0.6315112",
"0.6245342",
"0.6236728",
"0.62221396",
"0.62152797",
"0.6211031",
"0.6197166",
"0.61592674",
"0.6158384",
"0.6156805",
"0.6125392",
"0.61249447",
"0.60979193",
"0.60489106",
"0.6044213",
"0.6033936",
"0.60173285",
"0.60010... | 0.73082405 | 1 |
start random generator threads and writer thread | def start
@running = true
gen_threads = start_generators
writer = start_writer
gen_threads.each(&:join)
kill_proccess
writer.join
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def start_generators\n threads = []\n 5.times do |idx|\n thread = Thread.new { contious_generation }\n thread[:id] = idx\n threads << thread\n end\n threads\n end",
"def run\r\n @cordinators.each do |c|\r\n @threads << Thread.new do\r\n c.run\r\n end\r\n ... | [
"0.6912321",
"0.5610358",
"0.55341935",
"0.53992677",
"0.5355878",
"0.528509",
"0.5261756",
"0.5258786",
"0.52472353",
"0.5246438",
"0.52297103",
"0.52289003",
"0.52289003",
"0.52289003",
"0.5208914",
"0.5201603",
"0.51988566",
"0.51877767",
"0.51774836",
"0.51246893",
"0.509... | 0.66465956 | 1 |
returns frequency for last hundred outputs | def get_freq
#instantiate with values to ensure consistent ordering
freq = { 1 => 0, 2 => 0, 3 => 0, 4 => 0, 5 => 0 }
#sum up freqencies of each number
last_100 = get_last_100
last_100.each do |item|
freq[item.to_i] += 1
end
# convert to percentage
freq.each do |key, val|
#di... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def frequency\n growth_rate = 2 ** (1.0 / 12)\n frequency = 440 * (growth_rate ** semitones_from_A4)\n frequency.round(3)\n end",
"def get_frequency()\n return(get_cmd('FA;',0.1,0.5,3).gsub(/^FA/,'').gsub(/;$/,'').to_i)\nend",
"def frequency\n \n end",
"def frequency\n FREQUENCY\n ... | [
"0.6677098",
"0.66134214",
"0.65858567",
"0.6584553",
"0.6405751",
"0.6396108",
"0.63465613",
"0.6335369",
"0.6193089",
"0.616515",
"0.61158615",
"0.6107291",
"0.6054452",
"0.5971618",
"0.5827842",
"0.5822521",
"0.5798948",
"0.5795328",
"0.577622",
"0.5763896",
"0.5726173",
... | 0.7998869 | 0 |
helper method to return last 100 outputs | def get_last_100
last_100 = []
lines = File.readlines('./output.txt').reverse[0...100]
lines.each do |line|
last_100 << line.chomp.split(", ")[0]
end
last_100
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def last_output\n return @output_array[-1]\n end",
"def last_output\n return @output_array[-1]\n end",
"def last_output\n return @output_array[-1]\n end",
"def last_output\n return @output_array[-1]\n end",
"def get_output(num)\n messages = @messages.last(num)\n messages.count < 2... | [
"0.6402576",
"0.6402576",
"0.6402576",
"0.6402576",
"0.61115795",
"0.5949863",
"0.5949863",
"0.5949863",
"0.5949863",
"0.5788936",
"0.5780951",
"0.5760885",
"0.5760885",
"0.5760885",
"0.5760885",
"0.5760885",
"0.5760885",
"0.5760885",
"0.5760885",
"0.5760885",
"0.5760885",
... | 0.73927873 | 0 |
ensure all queues remain filled until the generators are done generating and and the output queue has been emmptied | def fill_queues
while @thread_queues.any?(&:empty?) && (@running || !@output_queue.empty?)
el = @output_queue.shift
@thread_queues[el[:thread]] << el if el
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def flusher_loop\n loop do\n # Blocks waiting for the flusher to be kicked...\n @flush_queue.pop\n\n should_bail = synchronize do\n @status != CONNECTED || @status == CONNECTING\n end\n return if should_bail\n\n # Skip in case nothing remains ... | [
"0.6355712",
"0.624103",
"0.6221606",
"0.6195629",
"0.6195026",
"0.6186957",
"0.61763436",
"0.61226183",
"0.60938627",
"0.6083213",
"0.60723025",
"0.6056801",
"0.60308313",
"0.6007526",
"0.6001148",
"0.6000283",
"0.59885955",
"0.5984256",
"0.5965351",
"0.58838326",
"0.5879026... | 0.7514605 | 0 |
uses a minheap to ensure ordered data output before writing to disc | def ensure_order_and_write
fill_queues
unless @heap.empty?
#extract the minimum element from the heap
extracted_el = @heap.extract
write_to_disk(extracted_el)
#add the next element from the same thread to the heap
from_queue = extracted_el[:thread]
fill_queues
next_el ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_minheap\n\t\ti = @heap.length/2\n\t\twhile i >= 0\n\t\t\tminheapify(i)\n\t\t\ti -= 1\n\t\tend\n\tend",
"def heapsort(list)\n array = []\n myHeap = MinHeap.new()\n #return myHeap.store\n list.each do |item|\n myHeap.add(item)\n puts item \n end\n\n until myHeap.empty?\n array << myHeap.r... | [
"0.6689746",
"0.6371679",
"0.6280897",
"0.6259608",
"0.62022924",
"0.61617696",
"0.58815265",
"0.58796775",
"0.586939",
"0.58582425",
"0.5832433",
"0.58265454",
"0.57960653",
"0.5789457",
"0.57412255",
"0.5741173",
"0.5735473",
"0.5730162",
"0.5729206",
"0.5724106",
"0.570662... | 0.73906064 | 0 |
Generator Methods Creats 5 seperate writer generator threads | def start_generators
threads = []
5.times do |idx|
thread = Thread.new { contious_generation }
thread[:id] = idx
threads << thread
end
threads
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_intelligent_generator(jobs)\n jobs_gen = jobs.lazy.each\n Fiber.new do\n (jobs.length-1).times do\n Fiber.yield jobs_gen.next\n end\n jobs_gen.next\n end\n end",
"def start\n @running = true\n gen_threads = start_generators\n writer = start_writer\n gen_thre... | [
"0.6066507",
"0.5867134",
"0.5854366",
"0.5854366",
"0.5746162",
"0.5625355",
"0.5625355",
"0.5599094",
"0.55290556",
"0.55165744",
"0.5508261",
"0.54867053",
"0.5431468",
"0.5417689",
"0.54154974",
"0.5393715",
"0.5393553",
"0.53817165",
"0.5380286",
"0.53742003",
"0.5369251... | 0.76342887 | 0 |
DELETE /children/1 DELETE /children/1.json | def destroy
@child.destroy
respond_to do |format|
format.html { redirect_to children_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @children = Children.find(params[:id])\n @children.destroy\n\n respond_to do |format|\n format.html { redirect_to(childrens_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @child = Child.find(params[:id])\n @child.destroy\n\n respond_to do |format|\n ... | [
"0.7690423",
"0.754166",
"0.7339654",
"0.7039886",
"0.7039886",
"0.70389456",
"0.70389456",
"0.68095887",
"0.67939544",
"0.6781426",
"0.6747409",
"0.67131644",
"0.67131644",
"0.6713039",
"0.6677913",
"0.667762",
"0.667456",
"0.66403186",
"0.6628512",
"0.6609712",
"0.660891",
... | 0.7553778 | 1 |
Generates a random query | def random_query
# Use a fake query
# TODO: better random queries
'query ' + (rand*5000).to_i.to_s
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_random_quick_queries(types)\n allTypes = types.collect {|type| type.get_quick_queries}.flatten\n prng = Random.new\n random_qq = allTypes.sort {|item1, item2| prng.rand(-1 .. 1) }.slice(0, 5)\n random_qq.collect {|qq| render_quick_query(qq)}\n end",
"def random\n db = ActiveRecord::Bas... | [
"0.67428267",
"0.6579714",
"0.65100694",
"0.6459899",
"0.61614513",
"0.61167294",
"0.59826595",
"0.5957069",
"0.5907958",
"0.58903813",
"0.58845556",
"0.58440024",
"0.58408374",
"0.58172655",
"0.5815573",
"0.580951",
"0.5803809",
"0.5801294",
"0.5801294",
"0.5800222",
"0.5792... | 0.8608336 | 0 |
Generates a random (category, action) pair for an event | def random_category_action
category = (QuickSearch::Engine::APP_CONFIG['searchers'] + ['spelling-suggestion', 'result-types', 'doi-trap', 'more-options']).sample.dasherize
# Default action is a click
action = 'click'
# Typically, serves only happen for these categories
if category == 'best-bets' || category ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def random_event\n clear\n center \"Random Event\"\n new_line\n display_event(Event.all.sample)\n wait_and_clear\n end",
"def random_act *acts\n act acts[rand(acts.length)]\n end",
"def generateEventID\n Random.rand(10000)\n end",
"def random_event_by_tag_menu\n clear\n while @i... | [
"0.63106525",
"0.5994892",
"0.59504735",
"0.57473546",
"0.57009965",
"0.5692117",
"0.561502",
"0.5579096",
"0.5573902",
"0.5560656",
"0.5553878",
"0.55440325",
"0.5471812",
"0.5457403",
"0.5446332",
"0.5434204",
"0.54228395",
"0.531166",
"0.5303271",
"0.5282809",
"0.5277814",... | 0.7117247 | 0 |
Generates a random item for an event, based on the category | def random_item(category)
if category == 'best-bets'
# Sample a random Best Bet type from a static list
['webofscience', 'googlescholar', 'ieee', 'pubmed', 'morningstar', 'wgsn', 'standards', 'dissertation', 'refworks', 'ibis', 'proquest',
'psychinfo', 'sciencemagazine', 'sciencedirect', 'petition', 'com... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def random_item\n items.to_a.sample\n end",
"def random_item\n return @items[rand(@items.length)]\n end",
"def random_event\n clear\n center \"Random Event\"\n new_line\n display_event(Event.all.sample)\n wait_and_clear\n end",
"def random_item(electives)\n electives[rand(electiv... | [
"0.67726845",
"0.6486088",
"0.6484776",
"0.6410702",
"0.63882387",
"0.63415533",
"0.6227323",
"0.60879976",
"0.60795176",
"0.60710055",
"0.6042241",
"0.59937316",
"0.5938571",
"0.59200454",
"0.5870675",
"0.5853965",
"0.58490855",
"0.581952",
"0.58074826",
"0.5737065",
"0.5710... | 0.7389499 | 0 |
Raise error if no such block | def check_block name
raise "No such block: #{name}" unless @source.key? name
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has_block(blk_hash)\n raise \"Not implemented\"\n end",
"def raise_if_block(obj, name, has_block, type)\n return unless has_block\n\n puts \"Type passed in: #{type}\"\n puts \"#{obj.class}##{name} does not accept blocks\"\n\n raise Appom::UnsupportedBlockError\n end",
"de... | [
"0.7198107",
"0.7087166",
"0.68876505",
"0.6871596",
"0.6851032",
"0.6637109",
"0.6561613",
"0.654849",
"0.6518731",
"0.6463298",
"0.64455473",
"0.6403784",
"0.63923097",
"0.6387925",
"0.6384271",
"0.63789093",
"0.63658184",
"0.6271281",
"0.62580335",
"0.62580335",
"0.6258033... | 0.7525429 | 0 |
Save pem encoded content to a file. If the file doesn't exist, it will be created. Otherwise, the file will be overwritten. In both cases the contents will be overwritten atomically so other processes don't see a partially written file. | def save_pem(pem, path, owner: nil, group: nil, mode: 0644)
Puppet::FileSystem.replace_file(path, mode) do |f|
f.set_encoding('UTF-8')
f.write(pem.encode('UTF-8'))
end
if !Puppet::Util::Platform.windows? && Puppet.features.root? && (owner || group)
FileUtils.chown(owner, group, path)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write_pem(filename_or_io)\n write_data(filename_or_io, @cert.to_pem)\n end",
"def write_pem(filename_or_io)\n write_data(filename_or_io, @spki.to_pem)\n end",
"def write\n File.open(path, 'w') { |file|\n file.write(FILE_HEADER + \"\\n\")\n file.write(encod... | [
"0.63669235",
"0.6342067",
"0.58729726",
"0.5854523",
"0.5818254",
"0.5799773",
"0.578276",
"0.57702744",
"0.576625",
"0.57602286",
"0.5708695",
"0.5687255",
"0.5687134",
"0.5685794",
"0.56578064",
"0.56578064",
"0.5649476",
"0.56432116",
"0.56415886",
"0.5636437",
"0.5625253... | 0.71479607 | 0 |
Delete a pem encoded object, if it exists. | def delete_pem(path)
Puppet::FileSystem.unlink(path)
true
rescue Errno::ENOENT
false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @pem = Pem.find(params[:id])\n @pem.destroy\n\n respond_to do |format|\n format.html { redirect_to pems_url }\n format.json { head :no_content }\n end\n end",
"def delete\n result = exists\n raise RubyAem::Error.new('Certificate chain not found', result) if resu... | [
"0.6298715",
"0.62234724",
"0.6163683",
"0.601336",
"0.5942083",
"0.5860491",
"0.5818211",
"0.5764124",
"0.5761303",
"0.5738464",
"0.5720538",
"0.5691599",
"0.5683437",
"0.5671624",
"0.5642392",
"0.5637462",
"0.5621646",
"0.56120807",
"0.5608047",
"0.5607176",
"0.559704",
"... | 0.7268935 | 0 |
GET /academic_informations GET /academic_informations.json | def index
@academic_informations = AcademicInformation.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\r\n @academic_work = AcademicWork.find(params[:id])\r\n\r\n respond_to do |format|\r\n format.html # show.html.erb\r\n format.json { render json: @academic_work }\r\n end\r\n end",
"def index\n @educations = Education.all\n render json: @educations\n end",
"def show\n @an... | [
"0.6775217",
"0.65797335",
"0.65763885",
"0.6488956",
"0.64393044",
"0.63317746",
"0.631652",
"0.6284111",
"0.6239812",
"0.6193898",
"0.61796737",
"0.61765236",
"0.61765236",
"0.6160649",
"0.61407167",
"0.6119435",
"0.6099538",
"0.60833544",
"0.608291",
"0.6081734",
"0.607775... | 0.74520576 | 0 |
PATCH/PUT /academic_informations/1 PATCH/PUT /academic_informations/1.json | def update
respond_to do |format|
if @academic_information.update(academic_information_params)
format.html { redirect_to @academic_information, notice: 'Academic information was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: 'edit' }
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @initiative = Initiative.find(params[:id])\n \n respond_to do |format|\n if @initiative.update_attributes(params[:initiative])\n \n format.html { redirect_to @initiative, notice: 'Initiative was successfully updated.' }\n format.json { head :no_content }\n else\... | [
"0.67717165",
"0.67710716",
"0.6747215",
"0.6719126",
"0.66927475",
"0.66288173",
"0.66251254",
"0.66123307",
"0.6592651",
"0.65728956",
"0.6527749",
"0.65249974",
"0.6524159",
"0.6519908",
"0.6508089",
"0.65058064",
"0.6497485",
"0.64962745",
"0.64820474",
"0.64405894",
"0.6... | 0.71921223 | 0 |
DELETE /academic_informations/1 DELETE /academic_informations/1.json | def destroy
@academic_information.destroy
respond_to do |format|
format.html { redirect_to academic_informations_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @education_entry.destroy\n respond_to do |format|\n format.html { redirect_to education_entries_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @academic_degree.destroy\n respond_to do |format|\n format.html { redirect_to '/maestricos/prueba?titu... | [
"0.716151",
"0.7134487",
"0.71005076",
"0.7094043",
"0.7063016",
"0.69871086",
"0.69762254",
"0.6955557",
"0.69534886",
"0.69499236",
"0.6947348",
"0.6929999",
"0.6906631",
"0.68977445",
"0.6897173",
"0.68924636",
"0.68924636",
"0.68848974",
"0.68766606",
"0.68683016",
"0.686... | 0.78330463 | 0 |
GET /repondres GET /repondres.json | def index
@repondres = Repondre.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @repas = Repa.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @repas }\n end\n end",
"def show\n @repuesto = Repuesto.find(params[:id])\n respond_to do |format|\n format.html { render :show }\n format.json { render json: @... | [
"0.66810554",
"0.66384983",
"0.65938544",
"0.65374804",
"0.63630056",
"0.6361198",
"0.6354697",
"0.63461787",
"0.6306491",
"0.629827",
"0.6254358",
"0.6228207",
"0.6131714",
"0.6119192",
"0.60912645",
"0.6084219",
"0.6056029",
"0.60557944",
"0.60557836",
"0.6034126",
"0.60206... | 0.69111854 | 0 |
POST /repondres POST /repondres.json | def create
@repondre = Repondre.new(repondre_params)
respond_to do |format|
if @repondre.save
format.html { redirect_to @repondre, notice: 'Repondre was successfully created.' }
format.json { render :show, status: :created, location: @repondre }
else
format.html { render :ne... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @respuesta = Respuesta.new(params[:respuesta])\n\n if @respuesta.save\n render json: @respuesta, status: :created, location: @respuesta\n else\n render json: @respuesta.errors, status: :unprocessable_entity\n end\n end",
"def create\n @repuesto = Repuesto.new(repuesto_param... | [
"0.67486906",
"0.64910513",
"0.6474885",
"0.63194746",
"0.63150126",
"0.6292258",
"0.6246537",
"0.62076414",
"0.6195743",
"0.61589086",
"0.6140582",
"0.60337466",
"0.5992653",
"0.5990383",
"0.5952739",
"0.59474397",
"0.58888096",
"0.58568925",
"0.58505213",
"0.58457494",
"0.5... | 0.7267646 | 0 |
PATCH/PUT /repondres/1 PATCH/PUT /repondres/1.json | def update
respond_to do |format|
if @repondre.update(repondre_params)
format.html { redirect_to @repondre, notice: 'Repondre was successfully updated.' }
format.json { render :show, status: :ok, location: @repondre }
else
format.html { render :edit }
format.json { render... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def patch!\n request! :patch\n end",
"def api_patch(path, data = {})\n api_request(:patch, path, :data => data)\n end",
"def patch\n headers = {\"If-Match\" => @version}\n response = @context.request :patch, \"#{@path}/#{@id}\", @data.to_json, headers\n @version += 1\n response\... | [
"0.6501582",
"0.6449516",
"0.64425606",
"0.64194584",
"0.64194584",
"0.6331684",
"0.63238007",
"0.6316814",
"0.6294377",
"0.6283186",
"0.62355757",
"0.6211169",
"0.6210132",
"0.6210132",
"0.6201105",
"0.61946887",
"0.6174476",
"0.6165434",
"0.61550134",
"0.6143365",
"0.614154... | 0.6540675 | 0 |
DELETE /repondres/1 DELETE /repondres/1.json | def destroy
@repondre.destroy
respond_to do |format|
format.html { redirect_to repondres_url, notice: 'Repondre was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete\n client.delete(\"/#{id}\")\n end",
"def destroy\n @relogio = Relogio.find(params[:id])\n @relogio.destroy\n\n respond_to do |format|\n format.html { redirect_to relogios_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @repuestum = Repuestum.find(param... | [
"0.71015644",
"0.69831276",
"0.69712216",
"0.6917839",
"0.6917161",
"0.68178993",
"0.68178993",
"0.6794902",
"0.6757411",
"0.6756695",
"0.6751125",
"0.67044115",
"0.67030483",
"0.66971534",
"0.66971534",
"0.668791",
"0.6687842",
"0.6682473",
"0.6671442",
"0.6653417",
"0.66471... | 0.7078386 | 1 |
Trains the ANN with the training data (Don't forget to call prepare first) The desired error is divided by the normalizaion factor to respect data normalization. | def train(options = {})
options.reverse_merge!({ :max_epochs => 100000, :epochs_between_reports => 500, :desired_error => 0.0001 })
#fann.train_on_data(train_data, 10000, 100, 0.00001)
fann.train_on_data(train_data, options[:max_epochs], options[:epochs_between_reports], options[:desired_error] * normalizat... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def train(iterations=1)\n all_errors = []\n\n 1.upto(iterations) do |iteration|\n arguments = input_proc.call\n target_outputs = target_proc.call(*arguments)\n inputs = inputs_with_bias(arguments)\n actual_outputs = compute(*inputs)\n errors = actual_outputs.zip(target_outputs).map {... | [
"0.62786293",
"0.5942058",
"0.59141207",
"0.58798444",
"0.5814036",
"0.58032566",
"0.5654799",
"0.55475736",
"0.55252194",
"0.5481473",
"0.5470412",
"0.5452019",
"0.5338243",
"0.5287792",
"0.52805334",
"0.5244875",
"0.52251166",
"0.52147555",
"0.5177056",
"0.5149112",
"0.5120... | 0.6087506 | 1 |
Reinits the ANN and forgets learned stuff | def reset
init_fann
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reset\n @fann = RubyFann::Standard.new fann_opts\n if algo && algo != :rwg\n fann.set_training_algorithm(algo)\n end\n if actfn\n fann.set_activation_function_hidden(actfn)\n fann.set_activation_function_output(actfn)\n end\n if init_weights_range\n fann.randomize_weights(... | [
"0.7521403",
"0.6686727",
"0.65604556",
"0.6288221",
"0.6282612",
"0.6225561",
"0.6075317",
"0.5897425",
"0.5828759",
"0.58217466",
"0.5800422",
"0.579044",
"0.57703185",
"0.57560396",
"0.5717115",
"0.57141227",
"0.57123655",
"0.57012695",
"0.5661192",
"0.5656705",
"0.5639851... | 0.703791 | 1 |
Runs fann on real inputs | def run(inputs, normalize_outputs = true)
outputs = fann.run(inputs)
if normalize_outputs
return outputs.map { |value| value / normalization_factor }
else
return outputs
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def train(options = {})\n options.reverse_merge!({ :max_epochs => 100000, :epochs_between_reports => 500, :desired_error => 0.0001 })\n #fann.train_on_data(train_data, 10000, 100, 0.00001)\n fann.train_on_data(train_data, options[:max_epochs], options[:epochs_between_reports], options[:desired_error] * no... | [
"0.61476433",
"0.5915051",
"0.58816946",
"0.5364278",
"0.5209733",
"0.5180717",
"0.517215",
"0.51483524",
"0.50332147",
"0.5018713",
"0.49074113",
"0.4829197",
"0.47957715",
"0.47709677",
"0.46796986",
"0.4667795",
"0.46353972",
"0.46081483",
"0.45909443",
"0.45753038",
"0.45... | 0.66603 | 0 |
Creates a train data object | def train_data
::RubyFann::TrainData.new(
:inputs => inputs,
:desired_outputs=> desired_outputs)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_train(train_type)\n Train.new(\n @train_types.find do |type|\n type.to_s.eql? \"#{train_type.fetch('type')}T\"\n end\n )\n end",
"def get_data\n\t\tdata_hash = {path: @data_file_path, training: @training_file_name, testing: @testing_file_name}\n\t\tDataLoader.new(da... | [
"0.6902376",
"0.6741095",
"0.66243464",
"0.6612536",
"0.66034895",
"0.6421533",
"0.63924855",
"0.6388731",
"0.6362683",
"0.63475466",
"0.633105",
"0.6317757",
"0.6254829",
"0.62411696",
"0.62387985",
"0.6237182",
"0.62371397",
"0.6182625",
"0.61688024",
"0.6128827",
"0.611282... | 0.7517891 | 0 |
GET /post_parts GET /post_parts.json | def index
@post_parts = PostPart.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parts\n body.parts\n end",
"def parts\n @audio_file = AudioFile.find(params[:id])\n @parts = @audio_file.parts\n\n respond_to do |format|\n format.html # parts.html.erb\n format.xml { render :xml => @parts }\n format.json { render :json => @parts }\n end\n end",
"def sho... | [
"0.64217854",
"0.6355506",
"0.6234015",
"0.61558855",
"0.61489296",
"0.61131287",
"0.6068686",
"0.6002622",
"0.598498",
"0.59259564",
"0.59259564",
"0.59259564",
"0.5896",
"0.58364743",
"0.5834151",
"0.5834151",
"0.5785025",
"0.57775843",
"0.5747439",
"0.57305986",
"0.5730596... | 0.6966223 | 0 |
POST /post_parts POST /post_parts.json | def create
@post_part = PostPart.new(post_part_params)
respond_to do |format|
if @post_part.save
format.html { redirect_to @post_part, notice: 'Post part was successfully created.' }
format.json { render :show, status: :created, location: @post_part }
else
format.html { rend... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def post_part_params\n params.require(:post_part).permit(:heading, :body, :price, :neighborhood, :external_url, :timestamp)\n end",
"def create\n @part = Part.new(params[:part])\n\n respond_to do |format|\n if @part.save\n format.html { redirect_to @part, :notice => 'Part was successful... | [
"0.65953344",
"0.6349316",
"0.6316498",
"0.62887037",
"0.6256853",
"0.6085176",
"0.6083",
"0.5998084",
"0.59869564",
"0.5984582",
"0.5923192",
"0.5888448",
"0.58645827",
"0.58626896",
"0.5847761",
"0.5845177",
"0.5843476",
"0.57635933",
"0.5706779",
"0.56969863",
"0.56921834"... | 0.7007685 | 0 |
PATCH/PUT /post_parts/1 PATCH/PUT /post_parts/1.json | def update
respond_to do |format|
if @post_part.update(post_part_params)
format.html { redirect_to @post_part, notice: 'Post part was successfully updated.' }
format.json { render :show, status: :ok, location: @post_part }
else
format.html { render :edit }
format.json { r... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @part = Part.find(params[:id])\n\n respond_to do |format|\n if @part.update_attributes(params[:part])\n format.html { redirect_to @part, :notice => 'Part was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n ... | [
"0.63045335",
"0.62945646",
"0.62745637",
"0.6199231",
"0.6176063",
"0.614541",
"0.6142998",
"0.6119238",
"0.6098641",
"0.6059295",
"0.60423285",
"0.6035777",
"0.5911059",
"0.59043455",
"0.5902983",
"0.5900299",
"0.5880431",
"0.58686185",
"0.58664715",
"0.5860878",
"0.5857453... | 0.68431634 | 0 |
DELETE /post_parts/1 DELETE /post_parts/1.json | def destroy
@post_part.destroy
respond_to do |format|
format.html { redirect_to post_parts_url, notice: 'Post part was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @medium_body_part = MediumBodyPart.find(params[:id])\n @medium_body_part.destroy\n\n respond_to do |format|\n format.html { redirect_to medium_body_parts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @part = Part.find(params[:id])\n @part.destroy... | [
"0.7135184",
"0.7089026",
"0.7049856",
"0.7041977",
"0.69963825",
"0.69424635",
"0.6924231",
"0.689641",
"0.6895302",
"0.6895302",
"0.6882251",
"0.6858963",
"0.6845252",
"0.6836659",
"0.6821784",
"0.675517",
"0.6708233",
"0.6667735",
"0.66397136",
"0.6577632",
"0.6572953",
... | 0.75699514 | 0 |
GET /pricing_sections or /pricing_sections.json | def index
@pricing_sections = PricingSection.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @sections = params[:path].nil? ? Section.all : Section.where(path: params[:path])\n\n respond_to do |format|\n format.html { render html: @sections }\n format.json { render json: @sections }\n end\n end",
"def pricing\n request('pricing', :get)\n end",
"def sell_shop_se... | [
"0.650615",
"0.64592797",
"0.6401837",
"0.63283855",
"0.6098201",
"0.6098201",
"0.60506755",
"0.6044163",
"0.59810024",
"0.59753543",
"0.58807594",
"0.58678555",
"0.57875943",
"0.57875943",
"0.57875943",
"0.5787582",
"0.57462263",
"0.5741422",
"0.56877404",
"0.56698936",
"0.5... | 0.709728 | 0 |
POST /pricing_sections or /pricing_sections.json | def create
@pricing_section = PricingSection.new(pricing_section_params)
respond_to do |format|
if @pricing_section.save
format.html { redirect_to @pricing_section, notice: "Pricing section was successfully created." }
format.json { render :show, status: :created, location: @pricing_secti... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pricing_section_params\n params.require(:pricing_section).permit(:section_id, :description)\n end",
"def set_pricing_section\n @pricing_section = PricingSection.find(params[:id])\n end",
"def update\n respond_to do |format|\n if @pricing_section.update(pricing_section_params)\n ... | [
"0.6557482",
"0.6444953",
"0.6319671",
"0.6223495",
"0.6102098",
"0.6065209",
"0.59367275",
"0.59097797",
"0.57917225",
"0.5772799",
"0.5720925",
"0.5674241",
"0.5656817",
"0.5643312",
"0.5618706",
"0.5611128",
"0.55987465",
"0.55884993",
"0.55769545",
"0.5563262",
"0.5562858... | 0.7201398 | 0 |
PATCH/PUT /pricing_sections/1 or /pricing_sections/1.json | def update
respond_to do |format|
if @pricing_section.update(pricing_section_params)
format.html { redirect_to @pricing_section, notice: "Pricing section was successfully updated." }
format.json { render :show, status: :ok, location: @pricing_section }
else
format.html { render :... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_pricing_section\n @pricing_section = PricingSection.find(params[:id])\n end",
"def update\n respond_to do |format|\n if @pricing.update(pricing_params)\n format.html { redirect_to @pricing, notice: 'Pricing was successfully updated.' }\n format.json { render :show, status: :... | [
"0.70158684",
"0.67984235",
"0.6566068",
"0.6531886",
"0.6475",
"0.6372816",
"0.63443524",
"0.6183952",
"0.6149243",
"0.6140965",
"0.6136654",
"0.6130516",
"0.61077875",
"0.60778105",
"0.6011418",
"0.59976536",
"0.59958106",
"0.599171",
"0.59874487",
"0.5952463",
"0.5949511",... | 0.7647509 | 0 |
DELETE /pricing_sections/1 or /pricing_sections/1.json | def destroy
@pricing_section.destroy
respond_to do |format|
format.html { redirect_to pricing_sections_url, notice: "Pricing section was successfully destroyed." }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @pricing.destroy\n\n head :no_content\n end",
"def destroy\n @section = Section.find(params[:id])\n @section.destroy\n\n respond_to do |format|\n format.html { redirect_to sections_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @section = Se... | [
"0.6980797",
"0.67241883",
"0.67241883",
"0.6705014",
"0.6673571",
"0.667",
"0.66619635",
"0.66590655",
"0.66590655",
"0.6596321",
"0.6587576",
"0.6576339",
"0.6574573",
"0.64880896",
"0.64826775",
"0.64783835",
"0.64728045",
"0.6459528",
"0.6452271",
"0.6452271",
"0.6437279"... | 0.7631115 | 0 |
projects:delete PROJECTNAME Delete the Mortar project PROJECTNAME. | def delete
name = shift_argument
unless name
error("Usage: mortar projects:delete PROJECTNAME\nMust specify PROJECTNAME.")
end
validate_arguments!
projects = api.get_projects().body['projects']
project_id = nil
if projects.any?
projects.each do |project|
if project['name'... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete(projects)\n project_ids = projects.collect { |project| project.id } \n args = {ids: project_ids.to_json}\n return @client.api_helper.command(args, \"project_delete\")\n end",
"def delete_project(project)\n handle_action_exceptions(__method__) do\n cmd_line = [\"dele... | [
"0.7917102",
"0.78557205",
"0.7784202",
"0.7671753",
"0.76519525",
"0.7615767",
"0.76097095",
"0.75473964",
"0.75473964",
"0.75473964",
"0.75473964",
"0.75473964",
"0.7539417",
"0.7506018",
"0.74974936",
"0.7480534",
"0.7477606",
"0.74680436",
"0.7467646",
"0.7435846",
"0.743... | 0.86508876 | 0 |
projects:create PROJECTNAME Used when you want to start a new Mortar project using Mortar generated code. embedded Create a Mortar project that is not its own git repo. Your code will still be synced with a git repo in the cloud. public Register a public project, which can be viewed and forked by anyone. | def create
name = shift_argument
unless name
error("Usage: mortar projects:create PROJECTNAME\nMust specify PROJECTNAME")
end
args = [name,]
is_public = false
if options[:public]
is_public= true
ask_public(is_public)
end
validate_project_name(name)
project_id = r... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n name = shift_argument\n unless name\n error(\"Usage: mortar projects:create PROJECT\\nMust specify PROJECT.\")\n end\n validate_arguments!\n \n unless git.has_dot_git?\n error(\"Can only create a mortar project for an existing git project. Please run:\\n\\ngit init\\ngit a... | [
"0.82168484",
"0.7927701",
"0.777378",
"0.7650788",
"0.75814563",
"0.7567293",
"0.7528929",
"0.7468335",
"0.74408036",
"0.73494047",
"0.72913575",
"0.72911626",
"0.7288899",
"0.72506505",
"0.7239542",
"0.72060895",
"0.71818537",
"0.71660745",
"0.7132836",
"0.70833194",
"0.707... | 0.8602962 | 0 |
projects:register PROJECTNAME Used when you want to start a new Mortar project using your existing code in the current directory. embedded Register code that is not its own git repo as a Mortar project. Your code will still be synced with a git repo in the cloud. public Register a public project, which can be viewed an... | def register
name = shift_argument
unless name
error("Usage: mortar projects:register PROJECT\nMust specify PROJECT.")
end
validate_arguments!
ask_public(options[:public])
#nil is non existant project_id because it hasn't been posted yet
register_do(name, options[:public], options[:emb... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def register_do(name, is_public, is_embedded, project_id)\n if is_embedded\n validate_project_structure()\n\n register_project(name, is_public, project_id) do |project_result|\n initialize_embedded_project(project_result)\n end\n else\n unless git.has_dot_git?\n # check if we'... | [
"0.78097445",
"0.66672343",
"0.6485799",
"0.6364393",
"0.6080523",
"0.6046141",
"0.6040116",
"0.601036",
"0.5999332",
"0.5999332",
"0.59859055",
"0.59563434",
"0.59516287",
"0.59289443",
"0.58608466",
"0.58344203",
"0.5823962",
"0.57886815",
"0.57801175",
"0.5723978",
"0.5723... | 0.831978 | 0 |
projects:set_remote PROJECTNAME Used after you checkout code for an existing Mortar project from a nonMortar git repository. Adds a remote to your local git repository to the Mortar git repository. For example if a coworker creates a Mortar project from an internal repository you would clone the internal repository and... | def set_remote
project_name = shift_argument
unless project_name
error("Usage: mortar projects:set_remote PROJECT\nMust specify PROJECT.")
end
unless options[:embedded]
unless git.has_dot_git?
error("Can only set the remote for an existing git project. Please run:\n\ngit init\ngit... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_remote\n project_name = shift_argument\n\n unless project_name\n error(\"Usage: mortar projects:set_remote PROJECT\\nMust specify PROJECT.\")\n end\n\n unless git.has_dot_git?\n error(\"Can only set the remote for an existing git project. Please run:\\n\\ngit init\\ngit add .\\ngit c... | [
"0.87974554",
"0.67510116",
"0.6679692",
"0.6569934",
"0.6522725",
"0.64648604",
"0.6442583",
"0.6284816",
"0.62839985",
"0.62839985",
"0.62299085",
"0.6183519",
"0.61738694",
"0.6101672",
"0.59710914",
"0.5843516",
"0.58231604",
"0.58125013",
"0.58071613",
"0.5791443",
"0.57... | 0.896468 | 0 |
projects:clone PROJECTNAME Used when you want to clone an existing Mortar project into the current directory. | def clone
name = shift_argument
unless name
error("Usage: mortar projects:clone PROJECT\nMust specify PROJECT.")
end
validate_arguments!
projects = api.get_projects().body["projects"]
project = projects.find{|p| p['name'] == name}
unless project
error("No project named: #{name} e... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clone\n\t\t did_clone = system \"git clone #{remote_path} projects/#{name}\"\n\t\t\tsystem \"cd projects/#{name} && git pull origin\" if !did_clone\n\t\tend",
"def copy\n project_to_clone = Project.find(params[:id])\n @project = project_to_clone.clone\n\n # FIXME add copying of project team members... | [
"0.7456945",
"0.67859703",
"0.65468585",
"0.64820933",
"0.64382607",
"0.63885105",
"0.6360722",
"0.6315655",
"0.60633355",
"0.60182697",
"0.5974519",
"0.5917901",
"0.5908996",
"0.5905753",
"0.5873216",
"0.58126414",
"0.5793599",
"0.5777473",
"0.5745835",
"0.5742597",
"0.57370... | 0.8546274 | 1 |
projects:fork GIT_URL PROJECT_NAME Used when you want to fork an existing Git repository into your own Mortar project. public Register a public project, which can be viewed and forked by anyone. | def fork
git_url = shift_argument
name = shift_argument
unless git_url and name
error("Usage: mortar projects:fork GIT_URL PROJECT\nMust specify GIT_URL and PROJECT.")
end
validate_arguments!
validate_project_name(name)
if git.has_dot_git?
begin
error("Currently in git r... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def admin_fork_repo(dst, src)\n response = HTTParty.post(\n GIT_BASE_URL + 'projects/' + dst.to_s + '/fork/' + src.to_s,\n :headers => {\n 'PRIVATE-TOKEN' => GIT_TOKEN\n }\n )\n Rails.logger.info \"Git server response (fork repo): #{response}\"\n end",
"def create_repo_f... | [
"0.7000899",
"0.6796955",
"0.6410218",
"0.6164391",
"0.6145727",
"0.6117099",
"0.61133814",
"0.6104223",
"0.60817224",
"0.60664755",
"0.6032076",
"0.59603673",
"0.59322625",
"0.5931203",
"0.5917447",
"0.5913743",
"0.5909714",
"0.58901495",
"0.5862971",
"0.58540183",
"0.585145... | 0.8252669 | 0 |
Prints the best plan for the selected features. Shows the total price of the plan selected. | def to_s
if match?
"Best Plan: " + @plans_name + "for $" + '%.2f' % [(@cost * 100).round / 100.0]
else
"No matching plan for your features"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def optimal_plan=(plans)\n @plans = plans\n @cost = 0.00\n @plans_name = \"\"\n @features_count = 0\n @plans.each do |plan|\n @cost += plan['cost']\n @plans_name += plan['name'] + \" \"\n @features_count += plan['features'].size\n end\n end",
"def do_filtered_plan_display\n ... | [
"0.62128544",
"0.58965933",
"0.57153493",
"0.5684067",
"0.5590316",
"0.55577505",
"0.5530362",
"0.55002445",
"0.54985905",
"0.54802513",
"0.5435955",
"0.54123163",
"0.53586847",
"0.5356282",
"0.5331135",
"0.5311932",
"0.5305011",
"0.52871114",
"0.52792466",
"0.52788854",
"0.5... | 0.70799404 | 0 |
is there at least one matching plan(s) for requested features | def match?
@plans and @plans.size > 0
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has_feature?(*feature_names, match: :all?)\n features = get_var!(\"features\", single_match: :force)\n feature_names.map(&:to_s).send(match) do |feature_name|\n features.include? feature_name\n end\n end",
"def cheaper?(plan)\n cost = plan.inject(0) {|sum,plan| sum + plan['cost']}\n feat... | [
"0.6741976",
"0.64889693",
"0.64785147",
"0.6353291",
"0.6352293",
"0.6303821",
"0.6282219",
"0.6277143",
"0.62335676",
"0.61741847",
"0.61596876",
"0.6124389",
"0.6063933",
"0.6063024",
"0.60503775",
"0.6031704",
"0.6029332",
"0.5998901",
"0.5987527",
"0.5957292",
"0.5953631... | 0.708158 | 0 |
returns an array of all combinations of plans where the selected feature exist Example F1 selected feature existing in following plans [[P1],[P1,P2]...] | def matching_combinations(plans, selected_features)
a = {}
# array of plan indexed by feature
# Example F1 => [P1, P2], F2 => [P2, P3] ...
plans.each do |plan|
plan['features'].each do |f|
a[f] ||= []
a[f] << plan
end
end
# Returns an array of all combinatio... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def combinations\n self.locations.product(self.criterias)\n end",
"def plans(within_product=nil)\n product_id = within_product ? within_product.enabled_products.map(&:id) + [within_product.id] : nil\n Plan.where(:id => plan_ids, :product_id => product_id).all\n end",
"def opt_param... | [
"0.6114172",
"0.6042254",
"0.57879674",
"0.5766543",
"0.57328206",
"0.56937814",
"0.56345755",
"0.56344414",
"0.5536038",
"0.5522393",
"0.54283637",
"0.5384993",
"0.53054136",
"0.52885693",
"0.5281848",
"0.52582914",
"0.5251883",
"0.5247608",
"0.52353096",
"0.5226844",
"0.518... | 0.77840865 | 0 |
set lowest plan and compute global name/feature_count/cost | def optimal_plan=(plans)
@plans = plans
@cost = 0.00
@plans_name = ""
@features_count = 0
@plans.each do |plan|
@cost += plan['cost']
@plans_name += plan['name'] + " "
@features_count += plan['features'].size
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cheaper?(plan)\n cost = plan.inject(0) {|sum,plan| sum + plan['cost']}\n features_count = plan.inject(0) {|sum,plan| sum + plan['features'].size}\n @cost.nil? or cost < @cost or (cost == @cost && features_count > @features_count)\n end",
"def plan\n 0\n end",
"def plan; end",
"def to_s\n ... | [
"0.65415066",
"0.6359894",
"0.60918415",
"0.60409456",
"0.59103656",
"0.58384174",
"0.5773555",
"0.5761045",
"0.57514215",
"0.5713995",
"0.5692845",
"0.5675192",
"0.56427705",
"0.56001556",
"0.558127",
"0.55578923",
"0.5552348",
"0.55357087",
"0.548267",
"0.548267",
"0.548014... | 0.6954604 | 0 |
Is the matching plan cheaper? We make two assumptions here: 1. If cost are equal, return the plan with more features as cheaper plan 2. If cost are equal, feature count is same and feature belongs to both plan, the first plan retrieved is selected. This behavior can be easily changed. Based on business need both plan c... | def cheaper?(plan)
cost = plan.inject(0) {|sum,plan| sum + plan['cost']}
features_count = plan.inject(0) {|sum,plan| sum + plan['features'].size}
@cost.nil? or cost < @cost or (cost == @cost && features_count > @features_count)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_s\n if match?\n \"Best Plan: \" + @plans_name + \"for $\" + '%.2f' % [(@cost * 100).round / 100.0]\n else\n \"No matching plan for your features\"\n end\n end",
"def matching_combinations(plans, selected_features)\n a = {}\n \n # array of plan indexed by feature\n # Example... | [
"0.68194604",
"0.6333256",
"0.6147887",
"0.60911",
"0.59614336",
"0.59326947",
"0.58656025",
"0.5775174",
"0.5746929",
"0.57186216",
"0.57186216",
"0.5688096",
"0.568036",
"0.5651539",
"0.55394995",
"0.54938084",
"0.54895586",
"0.547203",
"0.5471945",
"0.5430631",
"0.5408961"... | 0.8141394 | 0 |
adds the necessary javascript include tags, stylesheet tags, and load event with necessary javascript to activate wym editor(s) | def wym_editor_initialize(*dom_ids)
editor_ids = (@wym_editor_ids || []) + wym_extract_dom_ids(*dom_ids)
output = []
output << stylesheet_link_tag('/wymeditor/wymeditor/skins/default/screen')
output << javascript_include_tag('/wymeditor/jquery/jquery')
output << javascript_include_tag('/wymeditor/wy... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_js\n AssetManager.include_contrib_library [:core_ui, :jquery_tab]\n AssetManager.include_local_library [ 'ckeditor/init']\n\n AssetManager.include_css [:blog_global]\n end",
"def page_script(context={})\n \n [\"/htmleditor/js/jquery.wysiwyg.js\",\n \"/htmleditor/js/ysd.editor.js\... | [
"0.7019391",
"0.6608026",
"0.6321885",
"0.6229285",
"0.62082946",
"0.61583054",
"0.6098102",
"0.6011592",
"0.60063833",
"0.5863114",
"0.58468765",
"0.5834803",
"0.5834803",
"0.5790196",
"0.5755622",
"0.5695198",
"0.56814504",
"0.5668234",
"0.5648277",
"0.5646434",
"0.5643013"... | 0.69603467 | 1 |
Sets the token value for the current session and returns it in a masked form that's safe to send to the client. See section 3.4 of "BREACH: Reviving the CRIME attack". | def masked_authenticity_token(session)
one_time_pad = SecureRandom.random_bytes(AUTHENTICITY_TOKEN_LENGTH)
encrypted_csrf_token = xor_byte_strings(one_time_pad, real_csrf_token(session))
masked_token = one_time_pad + encrypted_csrf_token
Base64.strict_encode64(masked_token)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def masked_authenticity_token(session, form_options: T.unsafe(nil)); end",
"def set_token\n self.token = SecureRandom.hex(16)\n end",
"def set_token\n self.token = SecureRandom.hex(16)\n end",
"def set_token\n self.token ||= SecureRandom.uuid.gsub(/\\-/, '').first(5).upcase\n end",
"def set_tok... | [
"0.6830139",
"0.65041685",
"0.65041685",
"0.64283067",
"0.6327143",
"0.6318878",
"0.6278038",
"0.6204214",
"0.61473805",
"0.6131066",
"0.61267567",
"0.6109995",
"0.6098966",
"0.60460377",
"0.6044267",
"0.60171235",
"0.5985372",
"0.59787583",
"0.59399724",
"0.5924458",
"0.5910... | 0.70682895 | 0 |
Checks the client's masked token to see if it matches the session token. Essentially the inverse of +masked_authenticity_token+. | def valid_authenticity_token?(session, encoded_masked_token)
return false if encoded_masked_token.nil? || encoded_masked_token.empty?
masked_token = Base64.strict_decode64(encoded_masked_token)
return false if masked_token.length != AUTHENTICITY_TOKEN_LENGTH * 2
# Split the token into... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def valid_authenticity_token?(session, encoded_masked_token); end",
"def masked_authenticity_token(session)\n one_time_pad = SecureRandom.random_bytes(AUTHENTICITY_TOKEN_LENGTH)\n encrypted_csrf_token = xor_byte_strings(one_time_pad, real_csrf_token(session))\n masked_token = one_time_pad + ... | [
"0.8165088",
"0.6949309",
"0.6852407",
"0.6852407",
"0.6852407",
"0.6852407",
"0.6852407",
"0.6852407",
"0.6852407",
"0.6852407",
"0.6852407",
"0.6852407",
"0.6852407",
"0.6852407",
"0.6852407",
"0.67660624",
"0.67561024",
"0.67561024",
"0.67561024",
"0.67531353",
"0.67362356... | 0.8027464 | 1 |
Destroy all records and stop Daemon script on logout | def destroy
system "ruby streaming_script.rb stop"
session[:username] = nil
User.all.each do |user|
user.destroy
end
User.reset_pk_sequence
Tweet.all.each do |tweet|
tweet.destroy
end
Tweet.reset_pk_sequence
reset_session
redirect_to root_path
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n log_out\n end",
"def destroy\n kill\n reset\n end",
"def daemon_clean_up\n TaskQueue.where(id: $daemon[:heartbeat_task_queue_id]).destroy_all\n File.delete($daemon[:pid_file])\nend",
"def clean_sessions\n self.log_puts(\"Cleaning sessions on appserver.\") if @debug\n... | [
"0.66424865",
"0.6568091",
"0.65014905",
"0.64252025",
"0.6346752",
"0.63371754",
"0.63297087",
"0.6321891",
"0.6320664",
"0.6310702",
"0.6285546",
"0.6282958",
"0.6278167",
"0.62675714",
"0.62645936",
"0.6254862",
"0.6188635",
"0.6183023",
"0.61717826",
"0.6139106",
"0.61391... | 0.66317403 | 1 |
GET /restaurants/1/tables GET /restaurants/1/tables.json | def index
@tables = @restaurant.tables
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @restaurant_table = RestaurantTable.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @restaurant_table }\n end\n end",
"def list(table)\n self.get(\"/#{table}\")\n end",
"def listRestaurants\n _restaurants = Restaurant... | [
"0.7248467",
"0.6869382",
"0.68106014",
"0.6714031",
"0.6665551",
"0.66593635",
"0.66562",
"0.6310047",
"0.6297372",
"0.62689877",
"0.6236629",
"0.62266326",
"0.62266326",
"0.62266326",
"0.6197502",
"0.6129593",
"0.61229014",
"0.61080986",
"0.60944676",
"0.6091092",
"0.608061... | 0.7427656 | 0 |
POST /restaurants//tables POST /restaurants/1/tables.json | def create
@table = @restaurant.tables.build(table_params)
respond_to do |format|
if @table.save
format.html { redirect_to restaurant_tables_path(@restaurant), notice: 'Table was successfully created.' }
format.json { render :show, status: :created, location: @table }
else
f... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n if current_user.restaurant_ids.include?(params[:restaurant_id].to_i)\n # find new table number\n table_index = 1\n tables = Table.where(restaurant_id: params[:restaurant_id])\n if !tables.nil? && tables.count > 0\n tables.each do |table|\n table_index = table.tab... | [
"0.72751194",
"0.676111",
"0.6393096",
"0.6262105",
"0.5993949",
"0.58371073",
"0.5829471",
"0.5816438",
"0.5790426",
"0.5720594",
"0.5675311",
"0.56332034",
"0.560765",
"0.55981475",
"0.5595866",
"0.5579365",
"0.5562936",
"0.5526544",
"0.5522176",
"0.5507415",
"0.5474045",
... | 0.71772075 | 1 |
PATCH/PUT /restaurants/1/tables/1 PATCH/PUT /restaurants/1/tables/1.json | def update
respond_to do |format|
if @table.update(table_params)
format.html { redirect_to restaurant_tables_path(@restaurant), notice: 'Table was successfully updated.' }
format.json { render :show, status: :ok, location: @table }
else
format.html { render :edit }
format... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @restaurant_table = RestaurantTable.find(params[:id])\n\n respond_to do |format|\n if @restaurant_table.update_attributes(params[:restaurant_table])\n format.html { redirect_to @restaurant_table, notice: 'Restaurant table was successfully updated.' }\n format.json { head :no_c... | [
"0.6857745",
"0.6312511",
"0.6252273",
"0.6060474",
"0.602739",
"0.5971374",
"0.5960167",
"0.5894511",
"0.58566034",
"0.58282554",
"0.5821747",
"0.5800232",
"0.57935786",
"0.57913935",
"0.57905793",
"0.5781102",
"0.57748574",
"0.57748574",
"0.57748574",
"0.57748574",
"0.57634... | 0.6892507 | 0 |
Stamps all files matching DIR_PATTERNS and the +includepaths+ option unless they have already been stamped | def run!(options={})
options[:exclude_paths] ||= []
options[:include_paths].each do |path|
DIR_PATTERS << path
end if options[:include_paths]
DIR_PATTERS.each do |main_dir|
Dir.glob(main_dir).each do |path|
# skip to the next file if this file matches exclude_paths
next ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def process_exclusions(globs); end",
"def enhance_file_list\n return unless @enhanced_mode\n @current_dir ||= Dir.pwd\n\n begin\n actr = @files.size\n\n # zshglob: M = MARK_DIRS with slash\n # zshglob: N = NULL_GLOB no error if no result, this is causing space to split\n # file sometimes for sing... | [
"0.5891279",
"0.583747",
"0.57488465",
"0.56499076",
"0.56059915",
"0.5542858",
"0.5538062",
"0.5534155",
"0.5521908",
"0.5513069",
"0.5460612",
"0.54544026",
"0.5437576",
"0.543569",
"0.54348433",
"0.54218185",
"0.5394347",
"0.5375221",
"0.5355468",
"0.53522056",
"0.5348523"... | 0.7404886 | 0 |
Read a CSV string into an array of CSVEntries. | def read(string)
lines = string.split("\n")
header = lines[0]
attributes = header.split(',').map! { |v| v.to_sym }
# Struct.new('CSVEntry', *attributes)
ret = []
lines.drop(1).each do |line|
values = line.split(',')
opts = {}
values.each_with_index do |val, idx|
opts[at... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def csv_to_array(csv_name)\n\tCSV.read(csv_name)\nend",
"def csv_to_array(csv); end",
"def readCSV(filename)\n resultArray = Array.new\n\n # read csv file\n File.open(filename) { |file|\n while line = file.gets\n row = CSV.parse_line( Kconv::kconv(line, Kconv::UTF8, Kconv::SJIS) )\n resultArray... | [
"0.7203955",
"0.69532484",
"0.69352037",
"0.6906603",
"0.6906603",
"0.6905589",
"0.6748106",
"0.66476566",
"0.6629817",
"0.64393413",
"0.6424258",
"0.641854",
"0.6372537",
"0.6286747",
"0.6269038",
"0.60965294",
"0.6086337",
"0.6079646",
"0.6033713",
"0.60110503",
"0.6008343"... | 0.7536426 | 0 |
Try ping three times. Return true if at least one time responds. def ping3 | def update_ping
result = false
3.times do
command =
"ping -c 1 -W #{PING_MIN_INTERVAL} #{@hostname} 2> /dev/null 1> /dev/null"
if system(command)
result = true
break
end
end
write_cache("ping", result)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ping target, attempts = 5\n try = 0\n while try < attempts\n result = exec(Beaker::Command.new(\"ping -c 1 #{target}\"), :accept_all_exit_codes => true)\n return true if result.exit_code == 0\n\n try += 1\n end\n result.exit_code == 0\n end",
"def ping\n tries = 3\n begin\n ... | [
"0.6861726",
"0.65738636",
"0.65690535",
"0.635896",
"0.6145886",
"0.6058369",
"0.6047648",
"0.60227",
"0.6017396",
"0.5995556",
"0.59912825",
"0.5983551",
"0.5948659",
"0.5899114",
"0.58788985",
"0.58781224",
"0.5876417",
"0.5875402",
"0.58700114",
"0.5869033",
"0.5845669",
... | 0.6751828 | 1 |
POST /districts POST /districts.json | def create
@district = District.new(district_params)
respond_to do |format|
if @district.save
format.html { redirect_to @district, notice: 'District was successfully created.' }
format.json { render :show, status: :created, location: @district }
else
format.html { render :ne... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @admins_district = Admins::District.new(admins_district_params)\n\n respond_to do |format|\n if @admins_district.save\n format.html { redirect_to @admins_district, notice: 'District was successfully created.' }\n format.json { render :show, status: :created, location: @admins_... | [
"0.73754716",
"0.71334803",
"0.7103008",
"0.70803386",
"0.70637786",
"0.7062713",
"0.7040849",
"0.70311344",
"0.70261407",
"0.6893635",
"0.6869062",
"0.67810947",
"0.6735712",
"0.6735712",
"0.66597795",
"0.6647939",
"0.6609418",
"0.6574611",
"0.65476805",
"0.6431698",
"0.6324... | 0.76711434 | 1 |
PATCH/PUT /districts/1 PATCH/PUT /districts/1.json | def update
respond_to do |format|
if @district.update(district_params)
format.html { redirect_to @district, notice: 'District was successfully updated.' }
format.json { render :show, status: :ok, location: @district }
else
format.html { render :edit }
format.json { render... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @district = District.find(params[:id])\n\n respond_to do |format|\n if @district.update_attributes(params[:district])\n flash[:success] = \"Район успешно отредактирован.\"\n format.html { redirect_to @district }\n format.json { head :no_content }\n else\n fl... | [
"0.7126122",
"0.6996551",
"0.69761693",
"0.69454235",
"0.69368136",
"0.69137615",
"0.6912139",
"0.68911105",
"0.6760865",
"0.67091334",
"0.66382796",
"0.6565201",
"0.65612084",
"0.65612084",
"0.6485658",
"0.6357987",
"0.62105393",
"0.6091936",
"0.60824805",
"0.59730554",
"0.5... | 0.7215769 | 1 |
fetches the product referenced by the id. | def fetch_product
@product = Product.visible.find(params[:id]) if params[:id]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_by_id(id)\n get_product_by_id(id)\n end",
"def get_product_by_id(product_id)\n return Product.find(product_id)\n end",
"def getProduct(id)\n @products.find {|prod| prod.productId.to_i == id.to_i}\n end",
"def getProduct( product_id)\n params = Hash.new\n params['product_id'... | [
"0.80749166",
"0.7794719",
"0.7640569",
"0.7373178",
"0.73709536",
"0.73395765",
"0.73023564",
"0.7291947",
"0.72218937",
"0.7219605",
"0.71767926",
"0.7139996",
"0.70568436",
"0.70204425",
"0.6978034",
"0.6946414",
"0.69326305",
"0.6916953",
"0.6833144",
"0.676108",
"0.67127... | 0.78149086 | 1 |
creates a cookie that will store the products this user viewed. | def store_visited_product
id = @product.id
unless cookies[:user_visited_products]
cookies[:user_visited_products] = id
else
cookies_array = cookies[:user_visited_products].to_s.split(',')
if cookies_array.size < 20
cookies_array << id unless cookies_array.include?("#{id}")
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_products_to_cookies\n if cookies[:product].blank?\n cookies[:product] = [params[:id]]\n else\n @recently = cookies[:product].split('&').last(8)\n unless @recently.include?(params[:id])\n cookies[:product] = [cookies[:product]] << params[:id]\n end\n end\n\n end",
"def... | [
"0.7519355",
"0.6408353",
"0.63304436",
"0.631407",
"0.62956756",
"0.6283701",
"0.6258405",
"0.6217388",
"0.619936",
"0.6197179",
"0.6183296",
"0.6136613",
"0.6128804",
"0.6124218",
"0.6124218",
"0.6124218",
"0.6124218",
"0.6124218",
"0.6124218",
"0.6124218",
"0.61016715",
... | 0.7477063 | 1 |
Add a node to the project graph. | def add_node(node)
@nodes.add node
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add(node)\r\n @nodes << node\r\n end",
"def add_node(node); end",
"def add_node(name, node)\n language.nodes[name] = node if name\n node\n end",
"def add_node(node)\n @nodes[node.id.to_i] = node\n node.db = self\n end",
"def add_node(node)\n node... | [
"0.75790536",
"0.7533743",
"0.7449676",
"0.7437881",
"0.7423904",
"0.7324917",
"0.7315779",
"0.7194684",
"0.7064985",
"0.7031119",
"0.70273966",
"0.7005919",
"0.70036244",
"0.6947567",
"0.6860344",
"0.68166935",
"0.6773264",
"0.6758635",
"0.67541605",
"0.67330635",
"0.6679167... | 0.8292682 | 0 |
Add multiple nodes at once. | def add_nodes(*nodes)
@nodes.merge nodes
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add(*nodes)\n @nodes.push(*nodes)\n end",
"def add_childs(*nodes)\n nodes.each do |node|\n self.addChild(node)\n end\n end",
"def AddNodes(nodes)\n\tnodes.each do |n|\n\t\tn.id=@lastId\n\t\tDefineGroup(n)\n\t\t@lastId=@lastId+1\n\tend\n\treturn nodes\n end",
"def add(node)\r\n @no... | [
"0.8452777",
"0.73931134",
"0.73497957",
"0.72169966",
"0.711111",
"0.70864254",
"0.7069811",
"0.70236915",
"0.67949355",
"0.6767138",
"0.6742206",
"0.67292094",
"0.6646378",
"0.663818",
"0.6628216",
"0.6596066",
"0.65833205",
"0.64750105",
"0.6293812",
"0.6269824",
"0.618248... | 0.83360803 | 1 |
Set maximum project duration by adding an edge with negative duration as weight. | def max_duration=(duration)
nodes = @nodes.to_a
add_edge(nodes.last, nodes.first, -duration)
duration
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def maximum_duration=(value)\n @maximum_duration = value\n end",
"def set_duration\n if self.end_time\n # self.duration = (end_time - start_time).to_i\n self.duration = (end_time - start_time).to_i\n else\n self.duration = DEFAULT_DURATION\n self.end_time = sel... | [
"0.57675135",
"0.5741691",
"0.5448167",
"0.5161886",
"0.5148244",
"0.51042074",
"0.50982696",
"0.50919807",
"0.5077229",
"0.5076094",
"0.50020987",
"0.50020987",
"0.49458435",
"0.4879381",
"0.48665136",
"0.4855394",
"0.48398173",
"0.48382357",
"0.48365098",
"0.48259312",
"0.4... | 0.77499884 | 0 |
inserting a new row into the database contact | def save
if self.id
self.update
else
sql = <<-SQL
INSERT INTO contacts (name, phone_number, address, email)
VALUES (?, ?, ?, ?)
SQL
DB[:conn].execute(sql, name, phone_number, address, email)
@id = DB[:conn].execute("SELECT last_insert_rowid() FROM contacts"... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save\n if id\n Connection.conn.exec_params('UPDATE contacts SET name = $1, email = $2 WHERE id = $3::int;', [name,email,id])\n else\n pg_contact = Connection.conn.exec_params('INSERT INTO contacts (name,email) VALUES ($1, $2) RETURNING *;', [name,email])\n self.id = pg_contact[0][\"id\"]\n... | [
"0.6945833",
"0.66643983",
"0.66426486",
"0.65783554",
"0.65502375",
"0.652647",
"0.6502897",
"0.6468677",
"0.64677274",
"0.64457864",
"0.64041525",
"0.6390677",
"0.63866675",
"0.6381132",
"0.633995",
"0.6336467",
"0.63266736",
"0.63254476",
"0.63178056",
"0.6316364",
"0.6245... | 0.69711155 | 0 |
updating the database row mapped to the Contact instance. | def update
sql = "UPDATE contacts SET name = ?, phone_number = ?, address = ?, email = ? WHERE id = ?"
DB[:conn].execute(sql, name, phone_number, address, email, id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @contact = current_user.contacts.find(params[:id])\n @contact.update_attributes(params[:contact])\n end",
"def update fields\n self.contact = @nimble.put \"contact/#{self.id}\", { fields: fields }\n return nil unless self.contact\n self\n end",
"def contact_update(handle, ... | [
"0.6964599",
"0.68154514",
"0.6657135",
"0.6624171",
"0.65670824",
"0.6502961",
"0.6457798",
"0.6424585",
"0.6363718",
"0.6337078",
"0.6334092",
"0.63161355",
"0.6309855",
"0.62971133",
"0.6266566",
"0.6264457",
"0.6253173",
"0.62450945",
"0.62222177",
"0.6220779",
"0.6201020... | 0.70957 | 0 |
A URI describing where we are listening | def listener_uri(addr = datastore['ReverseListenerBindAddress'])
addr = datastore['LHOST'] if addr.nil? || addr.empty?
uri_host = Rex::Socket.is_ipv6?(addr) ? "[#{addr}]" : addr
"tcp://#{uri_host}:#{bind_port}"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def uri(location, options={})\n ops = resolve_defaults(options)\n @listener.register(location, ops[:handler], ops[:in_front])\n end",
"def listener_uri(addr = datastore['ReverseListenerBindAddress'])\n addr = datastore['LHOST'] if addr.nil? || addr.empty?\n uri_host = Rex::Socket.is_ipv6?(addr... | [
"0.7068179",
"0.6658383",
"0.65697294",
"0.64794505",
"0.6290014",
"0.6240302",
"0.6240302",
"0.6240302",
"0.62150824",
"0.6081083",
"0.60782856",
"0.60782856",
"0.6043254",
"0.6019149",
"0.60067594",
"0.5982672",
"0.5982672",
"0.5911158",
"0.5911158",
"0.5911158",
"0.5911158... | 0.7039041 | 1 |
Save record that user visited this country | def visit_country
self.user_countries.create!(user_id: self.visitor_id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def visited\n self.visited_at = Time.now\n self.save!\n end",
"def update\r\n @country = Country.find(params[:id])\r\n\r\n respond_to do |format|\r\n if\r\n case\r\n\t when params[:visited]\r\n\t\t unless @user.countries.include?(@country)\r\n\t\t\t @user.countrie... | [
"0.6624323",
"0.6616378",
"0.6532649",
"0.6506247",
"0.65031755",
"0.62527263",
"0.61437446",
"0.5997392",
"0.583226",
"0.58318615",
"0.5689034",
"0.5671381",
"0.5647143",
"0.5634113",
"0.5617625",
"0.56017053",
"0.5578527",
"0.5572745",
"0.55164605",
"0.5498923",
"0.5498923"... | 0.6979638 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.