query
stringlengths
7
9.55k
document
stringlengths
10
363k
metadata
dict
negatives
listlengths
0
101
negative_scores
listlengths
0
101
document_score
stringlengths
3
10
document_rank
stringclasses
102 values
POST /documents POST /documents.xml
def create @document = Document.new(params[:document]) respond_to do |format| if @document.save flash[:notice] = 'Document was successfully created.' #format.html { redirect_to(@document) } format.xml { render :xml => @document, :status => :created, :location => @document } else format.html { render :action => "new" } format.xml { render :xml => @document.errors, :status => :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def post(xmldoc)\n headers = {'Content-Type' => 'text/xml'}\n check_response( @httpcli.post(@endpoint, xmldoc, headers) )\n end", "def create\n @document = Document.new(params[:document])\n\n respond_to do |format|\n if @document.save\n format.html { redirect_to(@document, :notice => 'Do...
[ "0.7048327", "0.67540735", "0.67359203", "0.66302395", "0.661557", "0.6535959", "0.64859235", "0.6483103", "0.6481126", "0.64725393", "0.6443887", "0.6443887", "0.642961", "0.63952994", "0.6380277", "0.63607997", "0.63313854", "0.632637", "0.6279595", "0.627031", "0.6264694",...
0.6641407
3
PUT /documents/1 PUT /documents/1.xml
def update @document = Document.find(:first, :conditions => ["id = ?", params[:id]]) respond_to do |format| if @document.update_attributes(params[:document]) flash[:notice] = 'Document was successfully updated.' format.html { redirect_to(@document) } format.xml { head :ok } else format.html { render :action => "edit" } format.xml { render :xml => @document.errors, :status => :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def put_document index, id, document\n uri = URI(\"http://#{@host}:#{@port_s}/#{index}/_doc/#{id}\")\n req = Net::HTTP::Put.new(uri)\n req.body = document.to_json\n run(uri, req)\n end", "def update_document index, id, document\n uri = URI(\"http://#{@host}:#{@port_s}/#{index}/_doc/#{id}/_update\...
[ "0.7123757", "0.70059437", "0.674303", "0.65919405", "0.6590788", "0.6532039", "0.6520595", "0.64843297", "0.6471367", "0.64341277", "0.63930666", "0.63583857", "0.6356449", "0.63502795", "0.635025", "0.63292205", "0.6326798", "0.6316763", "0.63157225", "0.6311689", "0.630048...
0.6497797
7
DELETE /documents/1 DELETE /documents/1.xml
def destroy @document = Document.find(:first, :conditions => ["id = ?", params[:id]]) @document.destroy respond_to do |format| format.html { redirect_to(documents_url) } format.xml { head :ok } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @document.destroy\n save_log({ :action => 'DELETE', :document => { :before => @old_document }})\n #TODO delete the file from disk\n respond_to do |format|\n format.html { redirect_to(documents_url) }\n format.xml { head :ok }\n end\n end", "def delete\n @client.d...
[ "0.7584859", "0.7426469", "0.7419458", "0.73197496", "0.73197496", "0.73197496", "0.73070437", "0.73070437", "0.7192757", "0.70987463", "0.70755804", "0.702043", "0.7009198", "0.69643795", "0.69545716", "0.6927975", "0.6914381", "0.6908026", "0.6907971", "0.69073266", "0.6892...
0.7363343
3
and the sum of the squares of the first n positivie integers return 0 if number < 2 make an array from 1 to that number inject both equations with operators and subtract
def sum_square_difference(num) (1..num).sum ** 2 - (1..num).map {|num| num ** 2 }.sum end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sum_of_squares(n)\n (1..n).inject(0) do |total, i|\n total += i**2\n end\nend", "def solution(num)\n sum_of_squares = 0\n\n (1..num).each do |number|\n sum_of_squares += number**2\n end\n\n square_of_sums = (1..num).inject(:+) ** 2\n\n p (square_of_sums - sum_of_squares).abs\nend", "def sum_o...
[ "0.6975218", "0.69625574", "0.68806833", "0.68447375", "0.6799764", "0.6775325", "0.6767229", "0.6764937", "0.6742806", "0.6740794", "0.6722965", "0.67016816", "0.66846764", "0.66839725", "0.6679079", "0.66734535", "0.666858", "0.6625694", "0.66167504", "0.6593061", "0.657711...
0.6284798
74
Returns the list of roles for this membership.
def roles (properties[:roles] || []).map { |r| r.is_a?(Link) ? r : Link.new(r, nil, client) } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def roles\n return [] if !subject.respond_to?(roles_list_meth) || roles_of(subject).blank?\n roles_of(subject).flatten\n end", "def roles\n raise \"#{subject.inspect} should have a #{roles_list_meth} method\" if !subject.respond_to?(roles_list_meth)\n subj_roles = subject.send(ro...
[ "0.8099087", "0.803368", "0.77345794", "0.7657316", "0.7645684", "0.76139003", "0.76139003", "0.7578383", "0.7539112", "0.75305885", "0.74796844", "0.7368308", "0.7336048", "0.73123986", "0.7205183", "0.7149737", "0.71118593", "0.7101826", "0.7048627", "0.7045833", "0.7004875...
0.68326604
27
GET /orders GET /orders.json
def index sleep 1 @orders = Order.order("created_at DESC").paginate(page: params[:page], per_page: 5) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getorders(args={})\n {\n :method=> \"GetOrders\"\n }.to_json\n end", "def orders\n params = { command: 'account_orders' }\n get('/json.php', params)\n end", "def index\n @orders = Order.all\n render json: @orders\n end", "def index\n @orders = Order.all\n ...
[ "0.83267236", "0.815406", "0.80041754", "0.7947603", "0.7846487", "0.7823147", "0.78028905", "0.76992875", "0.76980406", "0.7682792", "0.7682792", "0.7682792", "0.7682792", "0.76827645", "0.75880665", "0.7574349", "0.756171", "0.7531827", "0.74860185", "0.7432208", "0.7369724...
0.0
-1
GET /orders/1 GET /orders/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getorders(args={})\n {\n :method=> \"GetOrders\"\n }.to_json\n end", "def index\n @orders = Order.all\n render json: @orders\n end", "def index\n @orders = Order.all\n render json: @orders, status: 200\n end", "def index\n @orders = Order.order(\"id\").all\n\n resp...
[ "0.7554187", "0.7488565", "0.7475228", "0.73777765", "0.73714006", "0.7341344", "0.73384553", "0.73168725", "0.73018956", "0.7291244", "0.7291244", "0.7291244", "0.7291244", "0.72911215", "0.7281374", "0.7266143", "0.72498786", "0.7228276", "0.7213504", "0.71842283", "0.71261...
0.0
-1
POST /orders POST /orders.json
def create @order = Order.new(order_params) @time = Time.now @order_last = Order.last() if @order_last == nil @ponum = "4900000001" else @ponum = @order_last.PONumber.to_i + 1 end @supp = Supplier.all arr = Array.new(params[:order][:order_lines_attributes].length) i = 0 while i < params[:order][:order_lines_attributes].length do arr[i] = params[:order][:order_lines_attributes]["#{i}"][:consolidate_id] i +=1 end @consolidate = Consolidate.find(arr) # raise params.inspect if @order.save @consolidate.each do |cons| params = ActionController::Parameters.new({ request: { status: "Purchase Ordered" } }) permitted = params.require(:request).permit(:status) cons.update(permitted) end flash[:success] = "Purchase Order has successfully generated" redirect_to orders_path else render 'new' end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def orders\n authenticated_post(\"orders\").body\n end", "def orders\n authenticated_post(\"auth/r/orders\").body\n end", "def create\n order = Order.create(order_params)\n render json: order\nend", "def submit_order()\n\tputs \"Submitting order\"\n\tdata = create_order()\n\tresponse = ...
[ "0.7586514", "0.74892014", "0.7488341", "0.74672353", "0.72729415", "0.7195772", "0.7061979", "0.6973998", "0.6909955", "0.6888593", "0.6873822", "0.68497854", "0.68402505", "0.68375117", "0.68375117", "0.68375117", "0.68375117", "0.68217", "0.67893606", "0.6779084", "0.67776...
0.0
-1
PATCH/PUT /orders/1 PATCH/PUT /orders/1.json
def update @action = params[:commit] ords_ids = params[:ords_ids] @receive = params[:receive] @reject = params[:reject] if @receive != nil if @order.status == "Pending" redirect_to new_receife_path(:order => @order) else @receive = Receive.where("order_id" => @order) @receive.each do |r| @id = r.id end # raise params.inspect redirect_to edit_receife_path(:id => @id) end elsif @action == "Reject" || @reject != nil if @reject != nil params = ActionController::Parameters.new({ order: { status: "Rejected" } }) permitted = params.require(:order).permit(:status) if @order.update(permitted) flash[:warning] = "Purchase Order has successfully rejected" redirect_to orders_path else render 'show' end else x = 0 arr = ords_ids.tr('', '').split(',').map(&:to_i) status = Array.new(arr.length) @orders = Order.find(arr) @orders.each do |o| status[x] = o.status x +=1 end if status.include?("Rejected") || status.include?("Partially Received") || status.include?("Completely Received") flash[:danger] = "Unable to reject purchase order. Please select a pending one." redirect_to orders_path elsif status.uniq.length == 0 flash[:danger] = "Please select purchase order to reject." redirect_to orders_path else @orders.each do |o| params = ActionController::Parameters.new({ order: { status: "Rejected" } }) permitted = params.require(:order).permit(:status) o.update(permitted) end flash[:success] = "Purchase Order has successfully rejected." redirect_to orders_path end # raise params.inspect end else params = ActionController::Parameters.new({ order: { total_amount: order_params[:total_amount] } }) permitted = params.require(:order).permit(:total_amount) if @order.update(permitted) i = 0 while i < order_params[:order_lines_attributes].length params = ActionController::Parameters.new({ order_line: { unit_price: order_params[:order_lines_attributes]["#{i}"][:unit_price], amount: order_params[:order_lines_attributes]["#{i}"][:amount] } }) asd = params.require(:order_line).permit(:unit_price, :amount) @order_line = OrderLine.find(@order.order_lines.ids[i]) @order_line.update(asd) i +=1 end flash[:success] = "Purchase Order has successfully updated" redirect_to orders_path else render 'edit' end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @order = Order.find(params[:id])\n\n if @order.update(order_params)\n head :no_content\n else\n render json: @order.errors, status: :unprocessable_entity\n end\n end", "def update\n @order = Order.find(params[:id])\n\n if @order.update(order_params)\n head :no_conte...
[ "0.680366", "0.680366", "0.6776075", "0.6744552", "0.6736555", "0.6728256", "0.6724577", "0.6720915", "0.6705972", "0.6705906", "0.6705906", "0.6705906", "0.6705906", "0.6705906", "0.6705906", "0.6705906", "0.6705906", "0.6705906", "0.6705906", "0.6705906", "0.6705906", "0....
0.0
-1
DELETE /orders/1 DELETE /orders/1.json
def destroy @order.destroy respond_to do |format| format.html { redirect_to orders_url, notice: 'Order was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @v1_order = V1::Order.find(params[:id])\n @v1_order.destroy\n\n head :no_content\n end", "def destroy\n @order1 = Order1.find(params[:id])\n @order1.destroy\n\n respond_to do |format|\n format.html { redirect_to order1s_url }\n format.json { head :no_content }\n end\...
[ "0.7592003", "0.7475092", "0.74298924", "0.7371978", "0.7371411", "0.7371187", "0.7357556", "0.7357556", "0.7357556", "0.7357556", "0.7357556", "0.7347606", "0.7347606", "0.7347606", "0.7347606", "0.7347606", "0.7347606", "0.7347606", "0.7347606", "0.7347606", "0.7347606", ...
0.0
-1
Use callbacks to share common setup or constraints between actions.
def set_order @order = Order.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_...
[ "0.6163163", "0.6045976", "0.5946146", "0.591683", "0.5890051", "0.58349305", "0.5776858", "0.5703237", "0.5703237", "0.5652805", "0.5621621", "0.54210985", "0.5411113", "0.5411113", "0.5411113", "0.5391541", "0.53794575", "0.5357573", "0.53402257", "0.53394014", "0.53321576"...
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def order_params params.require(:order).permit(:PONumber, :terms, :delivery_date, :supplier_id, :total_amount, :user_id, :status, order_lines_attributes: [:consolidate_id, :type_id, :product_id, :description, :qty, :unit_id, :unit_price, :amount]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strong_params\n params.require(:user).permit(param_whitelist)\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def allow_params_authentication!; end", "def allowed_params\n ALLOWED_PARAMS\n end", "def default_param_whitelist\n [\"mode\"]\n...
[ "0.69780594", "0.678054", "0.6742781", "0.67387927", "0.67346025", "0.6590683", "0.6501642", "0.6495788", "0.6479752", "0.64763314", "0.645457", "0.6437739", "0.6377168", "0.6372484", "0.6363871", "0.63179374", "0.62981373", "0.6297456", "0.62916917", "0.6290227", "0.628954",...
0.0
-1
Replace every letter in the string with the 3rd letter following it in the alphabet (i.e. c becomes f, Z becomes C). Then return this modified string.
def letter_changes(string) array = ("a".."z").to_a result_array = string.chars.map do |char| case when char.downcase == "x" then char == "x" ? "a" : "A" when char.downcase == "y" then char == "y" ? "b" : "B" when char.downcase == "z" then char == "z" ? "c" : "C" when char.match(/[a-z]/) then array[array.index(char.downcase) + 3] when char.match(/[A-Z]/) then array[array.index(char.downcase) + 3].upcase else char end end result_array.join end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def letter_changes(str)\n str.each_char.with_index do |char, idx|\n if char =~ /[A-Za-z]/\n if char =~ /[Zz]/\n str[idx] = 'a'\n else\n str[idx] = (char.ord + 1).chr\n end\n end\n end\n str.each_char.with_index do |char, idx|\n str[idx] = char.upcase if char =~ /[aeiou]/\n ...
[ "0.721506", "0.72146434", "0.70828086", "0.70708966", "0.70708966", "0.6971978", "0.69276655", "0.6841148", "0.68020046", "0.679593", "0.6769678", "0.6763481", "0.67598057", "0.6741699", "0.66600674", "0.6656298", "0.66552967", "0.6638782", "0.6625182", "0.661497", "0.6612486...
0.7041812
5
Makes actual post request using the json body passed to it
def http_post_request(req_body) #New http request (uri library deals with port and host on its own when parsing the url) http = Net::HTTP.new(@uri.host, @uri.port) #Original api url get does not need SSL (bad solution but any other way would not seem to work properly) if caller[1][/`.*'/].nil? or not (caller[1][/`.*'/][1..-2] == "initialize") #Https security stuff (don't need security when getting initial api url) http.use_ssl = true http.verify_mode = OpenSSL::SSL::VERIFY_NONE end #Post request using uri request = Net::HTTP::Post.new(@uri.request_uri) #Sets request to use basic authentication using the given username and api_key request.basic_auth(@username, @api_key) #Sets request to use json content type request.content_type = "application/json" #Sets request body to json file passed request.body = req_body #Executes setup request and returns body http.request(request).body end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def raw_post_request raw_params\n json_body = raw_params.to_json\n Rubix.logger.log(Logger::DEBUG, \"SEND: #{json_body}\") if Rubix.logger\n Net::HTTP::Post.new(uri.path).tap do |req|\n req['Content-Type'] = 'application/json-rpc'\n req.body = json_body\n end\n end",...
[ "0.72912496", "0.72084624", "0.7193714", "0.70875937", "0.70751303", "0.7044073", "0.7041821", "0.7035514", "0.7029094", "0.70117235", "0.7008881", "0.69427633", "0.6934985", "0.68956494", "0.68861336", "0.68704474", "0.6863687", "0.68570143", "0.6852852", "0.6781999", "0.677...
0.65286
46
This function turns the call into a method call in the Nutshell API When you call a missing method in the class it comes here passing the name of function that you tried to call and the arguments that you sent that function
def method_missing(name, *args) #Creates a json file with the method that you want to call (name), a custom id for the call (can be anything), and any other parameters passed to the function req_body = { :method => name, :params => args, :id => "Northworld Manager" }.to_json #Executes request request = http_post_request(req_body) #Checks for an empty request response if request.empty? puts "Recieved an empty response. There may not have been any items matching your query online." nil else #Parses the json response from the request resp = JSON.parse(request) #Checks for errors if resp['error'] #Update error if resp['error']['code'] == 409 puts "Rev key out of date. Online changes have been made. Please sync manager with nutshell." #Other errors else puts "Nutshell API Error: " + resp['error']['message'] + " (" + resp['error']['code'].to_s + ")" end nil end #Return json response result from the api method call resp['result'] end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def call(*args); end", "def method_missing(name, *args)\n\t\t\tcall name, *args\n\t\tend", "def method_missing(name, *args)\n\t\t\tcall(name, *args)\n\t\tend", "def method_missing(method, params={})\n call(method, params)\n end", "def invocation\n # -> uncomment the next line to manually enabl...
[ "0.66204864", "0.6610981", "0.65447575", "0.6518487", "0.6487511", "0.64319813", "0.64319813", "0.6393755", "0.63722706", "0.6333374", "0.63315", "0.63245213", "0.6288937", "0.6288937", "0.6288937", "0.6288937", "0.6288937", "0.6288937", "0.6288937", "0.6288937", "0.62428993"...
0.5775378
81
both reader and writter
def initialize( quantity) #@item_name = item_name @quantity = quantity end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def reader; end", "def read; end", "def read; end", "def read; end", "def read; end", "def read; end", "def read; end", "def read; end", "def read() end", "def read\nend", "def read\n \n end", "def read\n end", "def read\n end", "def read\n end", "def read\n end", "def writer\...
[ "0.75540686", "0.70388186", "0.70388186", "0.70388186", "0.70388186", "0.70388186", "0.70388186", "0.70388186", "0.7017304", "0.69760334", "0.6957953", "0.6911371", "0.6911371", "0.6911371", "0.6911371", "0.6743019", "0.6743019", "0.6734483", "0.6573621", "0.6459516", "0.6399...
0.0
-1
Returns +true+ if _other_payload_ is equivalent to the payload.
def ==(other_payload) return false unless other_payload.kind_of?(HTTY::Payload) (other_payload.body == body) && (other_payload.headers == headers) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ==(other) # :nodoc:\n @payload == other.payload\n end", "def is_equivalent_to?(other)\n return false if other.nil?\n return false unless self.factor == other.factor\n return false unless self.scaling == other.scaling\n return false unless self.dimensions == other.dimension...
[ "0.7916902", "0.6600822", "0.63954103", "0.6359097", "0.63247424", "0.6303252", "0.62991875", "0.62374", "0.6216023", "0.6161612", "0.61600405", "0.6154308", "0.6149585", "0.6143278", "0.6140154", "0.6136505", "0.6131435", "0.61294353", "0.6119302", "0.61074084", "0.61025596"...
0.77950794
2
Returns an array of the headers belonging to the payload.
def headers @headers.to_a end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def headers\n begin\n JSON(data['message_headers'])\n rescue => e\n return []\n end\n end", "def headers\r\n # NB: return value is supposed to be an array of strings\r\n @headers || []\r\n end", "def headers\n @headers ||= message.header_field...
[ "0.8099131", "0.76239556", "0.7326137", "0.7272457", "0.7146751", "0.7068802", "0.7036111", "0.6961386", "0.69194394", "0.68888", "0.6871369", "0.68491876", "0.6828644", "0.68220335", "0.6812799", "0.6797363", "0.6793594", "0.6773036", "0.67621845", "0.6720283", "0.6720283", ...
0.7744963
2
Initializes a new HTTY::Payload with attribute values specified in the _attributes_ hash. Valid _attributes_ keys include: :body :headers
def initialize(attributes={}) @body = attributes[:body] @headers = HTTY::Headers.new Array(attributes[:headers]).each do |name, value| @headers[name] = value end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def initialize(attributes={})\n @body = attributes[:body]\n @headers = HTTY::OrderedHash.new\n Array(attributes[:headers]).each do |name, value|\n @headers[name] = value\n end\n end", "def initialize(body = \"\", payload = {})\n\t\tself.body = body\n\t\tpayload.each do |attr, val|\n\t\t\tsen...
[ "0.80160606", "0.75768906", "0.7007949", "0.6960128", "0.6922348", "0.69110656", "0.68920857", "0.68520087", "0.68295634", "0.67770046", "0.6730699", "0.6688958", "0.6667352", "0.666473", "0.666473", "0.666473", "0.666473", "0.666473", "0.6659562", "0.6651622", "0.66442657", ...
0.80611414
0
GET /feedbacks/1 GET /feedbacks/1.xml
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @feedbacks = Feedback.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @feedbacks }\n end\n end", "def index\n @feedbacks = Feedback.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xm...
[ "0.7437164", "0.7437164", "0.72738105", "0.72738105", "0.7238189", "0.7232585", "0.7196398", "0.7196398", "0.7196398", "0.7052263", "0.69827724", "0.6576332", "0.65658754", "0.6561407", "0.655879", "0.655879", "0.65527", "0.65465325", "0.65465325", "0.65465325", "0.65465325",...
0.0
-1
GET /feedbacks/new GET /feedbacks/new.xml
def new # @feedback = Feedback.new # # respond_to do |format| # format.html # new.html.erb # format.xml { render :xml => @feedback } # end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @feedback = Feedback.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @feedback }\n end\n end", "def new\n @feedback = Feedback.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @feedb...
[ "0.7832282", "0.7832282", "0.7219957", "0.71561265", "0.71561265", "0.71561265", "0.7137715", "0.71078765", "0.70687723", "0.70331156", "0.6938807", "0.6885344", "0.6877128", "0.6863653", "0.6863653", "0.67993194", "0.679177", "0.6773832", "0.67358893", "0.67358893", "0.67358...
0.75234807
2
POST /feedbacks POST /feedbacks.xml
def create @feedback = Feedback.new @feedback.interested_in = params[:interested_in] @feedback.user_id = current_user respond_to do |format| if @feedback.save head :created else head :bad_request end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @feedback = Feedback.new(params[:feedback])\n\n respond_to do |format|\n if @feedback.save\n format.html { redirect_to(common_feedbacks_path, :notice => 'Feedback was successfully created.') }\n format.xml { render :xml => @feedback, :status => :created, :location => @feedbac...
[ "0.69489455", "0.6802758", "0.6697536", "0.6677916", "0.66024816", "0.65719485", "0.6566446", "0.6554324", "0.6537043", "0.6517721", "0.6517721", "0.65024394", "0.64738643", "0.64497185", "0.6428008", "0.642641", "0.63566124", "0.6346254", "0.6345876", "0.6298022", "0.6296507...
0.59853524
52
PUT /feedbacks/1 PUT /feedbacks/1.xml
def update end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @feedback = Feedback.find(params[:id])\n\n respond_to do |format|\n if @feedback.update_attributes(params[:feedback])\n format.html { redirect_to(common_feedbacks_path, :notice => 'Feedback was successfully updated.') }\n format.xml { head :ok }\n else\n format.ht...
[ "0.6814418", "0.674985", "0.6703245", "0.6668227", "0.66426915", "0.6558212", "0.64907223", "0.6468429", "0.6468429", "0.6468429", "0.6429464", "0.6345724", "0.6345724", "0.6345724", "0.6345724", "0.6308526", "0.62882733", "0.62882733", "0.62882733", "0.62882733", "0.6267961"...
0.0
-1
DELETE /feedbacks/1 DELETE /feedbacks/1.xml
def destroy end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @feedback = Feedback.find(params[:id])\n @feedback.destroy\n\n respond_to do |format|\n format.html { redirect_to(feedbacks_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @feedback = Feedback.find(params[:id])\n @feedback.destroy\n\n respond_to do |for...
[ "0.75749785", "0.7545315", "0.74684083", "0.7283183", "0.7047658", "0.6967679", "0.6942331", "0.6942331", "0.6942331", "0.6942331", "0.6942331", "0.6938935", "0.6938935", "0.6938935", "0.69337463", "0.6923122", "0.69116753", "0.68956715", "0.6811006", "0.6801841", "0.67517287...
0.0
-1
if we find missing method we assume it's a class, look it up in the hash so we can assign
def method_missing(sym, *args, &block) return @klass_hash[sym.to_s] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def method_missing( method, *args, &block )\n key = @key.dup << method.to_s\n Undefined.warn key\n return Undefined.new(key)\n end", "def method_missing(method, *args)\n @klass[method] = args.first\n end", "def method_missing(method, *args, &block)\n if @hash.key?(method.to_s.t...
[ "0.65502656", "0.64719236", "0.64604425", "0.62719387", "0.61792576", "0.61514", "0.61491734", "0.61480916", "0.61396736", "0.612392", "0.6100472", "0.60933876", "0.60908556", "0.6063464", "0.6043789", "0.60318106", "0.6010178", "0.6003255", "0.6001917", "0.5988287", "0.59813...
0.67579126
0
helper functions defined by evaluation engine
def roundcent(amount) return ((amount * 100).round)/100 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def evaluate\n\n end", "def eval(expr, *rest) end", "def eval(*args); end", "def expressions; end", "def expression; end", "def evaluate(ops)\n \t\tops = tokens(ops)\n \t\tmethods = {:+ => Proc.new{plus()}, :- => Proc.new{minus()}, :* => Proc.new{times()}, :/ => Proc.new{divide()}}\n \t\tops.each do ...
[ "0.7518073", "0.69303536", "0.6888141", "0.6822457", "0.6541098", "0.6501706", "0.6479885", "0.6417756", "0.64135295", "0.640845", "0.6384017", "0.6383323", "0.6363283", "0.6173045", "0.6155615", "0.61459917", "0.61046016", "0.6092344", "0.60811985", "0.6064142", "0.60561204"...
0.0
-1
end helper functions calculate a single expression file with a single row of data from csv file
def calc_once calc_file, in_header, in_data, output_variables in_header.each_with_index do | theval, ix | eval "#{theval} = #{in_data[ix]}" end file = File.new(calc_file, "r") count = 0; while (line = file.gets) count+=1 begin eval(line) rescue Exception => e puts "#{calc_file}(#{count}): " + e.message end end file.close #output to stdout s = "" output_variables.each do |output_var| s << (eval output_var).to_s s << "," end puts s end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_data_from_csv_file(csv_file)\n begin\n start_time = 0,\n end_time = 0,\n sum = 0, temp_sum = 0, index = 1,\n data = [],\n first_row = true\n \n if csv_file\n csv_data = FasterCSV.parse(csv_file)\n length = csv_data.length\n interval = 1\n unti...
[ "0.6502344", "0.6201807", "0.6103036", "0.60784465", "0.60453665", "0.60309196", "0.59680396", "0.58564156", "0.58393294", "0.5824818", "0.58112913", "0.57953215", "0.57466805", "0.5736717", "0.56824034", "0.5674356", "0.56691664", "0.56641465", "0.5658511", "0.56428766", "0....
0.63431054
1
read a csv file into rows
def read_csv_data file rows = [] readerIn = CSV.open(file, 'r') row = readerIn.shift while row!= nil && !row.empty? rows << row row = readerIn.shift end readerIn.close return rows end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def rows\n csv.rows.map { |row_array|\n Row.new(header: header, row_array: row_array).to_a\n }\n end", "def create_item_rows_from_csv \n item_rows = []\n CSV.foreach('./data/items.csv', headers: true, header_converters: :symbol) do |row|\n item_rows << row\n end \n return item_rows\n...
[ "0.7517813", "0.72080564", "0.715779", "0.7044131", "0.703256", "0.6999245", "0.68976396", "0.68965465", "0.6896368", "0.6853518", "0.68388814", "0.68107295", "0.68027824", "0.68019736", "0.67968833", "0.67734563", "0.67375183", "0.67350686", "0.67276555", "0.67085904", "0.67...
0.73528224
1
define classes by eval'ing them
def define_classes klasses klasses.each do |klassname| klass = klassname.gsub(/\b('?[a-z])/) { $1.capitalize } #make uppercase #could check to see if not already define but at the minute not important #if (eval "defined? #{klass}") != "constant" eval "class #{klass} < DynAttrClass \n end" #end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def process_class exp\n exp\n end", "def dynamic_classes(&definition)\n if definition\n @dynamic_classes.instance_eval &definition\n # @dynamic_classes.load!\n nil\n else\n @dynamic_classes\n end\n end", "def class_eval(*args, &block)\r\n metaclass.class_eva...
[ "0.6585369", "0.63955766", "0.63579994", "0.62055516", "0.61791605", "0.6169565", "0.6141973", "0.6125554", "0.60733926", "0.6069374", "0.6064823", "0.6032036", "0.6023303", "0.60041595", "0.59692514", "0.5928872", "0.5926827", "0.5915461", "0.59048885", "0.5897236", "0.58972...
0.75577897
0
initialize() ================================================ The dealer must initially draw cards until he has at least 17 points (forget the "she" political correctness). ================================================
def dealerMustMeetPointMinimum() #================================================ notDone = true continueToPlay = true while (notDone == true) do if (@dealer.points < 17) handleOneCard(@dealer) continueToPlay = mayGameContinue(@dealer) else notDone = false end # else, if end # while return continueToPlay end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def initialize()\n\t\tcards = []\n\t\t@board = cards\n\t\t@deck = Deck.new\n\t\tSTARTINGCARDS.times { @board << @deck.draw }\n\tend", "def game_init\r\n state(0)\r\n @game_deck.create_new_deck\r\n @player_deck = {}\r\n @dealer_deck = {}\r\n @player.points = 0\r\n @dealer.points = 0\r\n end", ...
[ "0.753206", "0.72271645", "0.70403606", "0.6991041", "0.6963729", "0.68919915", "0.68611693", "0.6857939", "0.6852485", "0.6834234", "0.6764655", "0.6747966", "0.6744563", "0.66957676", "0.6619018", "0.6615722", "0.66079044", "0.660747", "0.65863085", "0.65641487", "0.6530432...
0.0
-1
proceed() ================================================ Game 57 Floyd wins Floyd: Points: Cards: Dealer: Points: Cards: ================================================
def showResults() #================================================ puts "Game # " + @count.to_s if (@winner == :player) puts Match.playerName + " wins" else puts "Dealer wins" end # else, if # puts Match.playerName + ":" puts "\tPoints: " + @player.points.to_s puts "\tCards: " playerCards = @player.allCards count = 0 while (count < playerCards.length) do oneCard = playerCards[count] puts "\t\t" + Card::CardNames[oneCard.cardFace] + " of " + oneCard.cardSuit count = count + 1 end # while # puts "Dealer:" puts "\tPoints: " + @dealer.points.to_s if (@dealer.points == 0) puts "\tCards: none" else puts "\tCards: " dealerCards = @dealer.allCards count = 0 while (count < dealerCards.length) do oneCard = dealerCards[count] puts "\t\t" + Card::CardNames[oneCard.cardFace] + " of " + oneCard.cardSuit count += 1 end # while end #else, if end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def win_actions\n @i.cls\n @i.show_balance(@user)\n @i.show_cards(@open, @user, @croupier)\n @i.winner_msg(@user, @croupier, @winner) if @winner == @user || @winner == @croupier\n @i.winner_msg(@user, @croupier, @draw) if @winner == @draw\n\n # balance\n @winner.balance += @bank if @winner == ...
[ "0.6960318", "0.6940127", "0.6894226", "0.6889818", "0.6885212", "0.68808585", "0.686623", "0.6843683", "0.6839904", "0.6822689", "0.68147755", "0.68093693", "0.6803844", "0.67963386", "0.67955923", "0.67891294", "0.678866", "0.6784608", "0.6773542", "0.6772301", "0.67695093"...
0.0
-1
Add the index to the database
def execute index_statement = "CREATE#{' UNIQUE' if @unique} INDEX #{@name} ON #{@table_name} (#{@columns.join ", "})" MotionRecord::Base.connection.execute index_statement end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def <<(index)\n @indexes[index.name] = index\n end", "def create_index\n dataset.create_index(index_params)\n end", "def add_index(table, *args)\n alter_table(table) {add_index(*args)}\n end", "def update_index\n SolrService.add(to_solr, softCommit: true)\n end", ...
[ "0.7366267", "0.71795", "0.7177015", "0.7157226", "0.7076951", "0.70759153", "0.7064524", "0.70582557", "0.70541644", "0.70318604", "0.7025729", "0.7019722", "0.69847584", "0.6964651", "0.69537884", "0.6941296", "0.69318587", "0.6928132", "0.6918241", "0.6874658", "0.68205273...
0.6207227
95
just in case you need it to let your fuzzer components continue
def send_resume_request begin request = Net::HTTP::Get.new("#{@uri.request_uri}/reattach") response = @http.request(request) rescue => e puts e end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def run\n setup\n fuzzing_loop\n end", "def accept?(fuzz_match)\n\t\t\t\ttrue\n\t\t\tend", "def post_match() end", "def fuzz\n sanityCheck\n\n @originalSubject = @subject.clone\n\n @currentSubject = @subject.clone\n \n while(1 == 1) do\n @currentSubject = @manipul...
[ "0.73665965", "0.63921696", "0.6156516", "0.61212367", "0.5993874", "0.5981841", "0.5981841", "0.58605945", "0.58426553", "0.5760852", "0.57287437", "0.5720987", "0.5720987", "0.56745005", "0.56745005", "0.56058455", "0.56058455", "0.55695635", "0.5552394", "0.5552394", "0.55...
0.0
-1
Example: The binary representation of 1234 is 10011010010, so the function should return 5 in this case solution 1:
def count_bits(n) # TODO: Program me binary_array = [] while n >= 2 reminder = n % 2 binary_array.unshift(reminder) n = n / 2 end binary_array.unshift(n) sum = 0 binary_array.each do |num| if num == 1 sum += 1 end end return sum end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def bits(integer)\n number = integer.to_s(2)\n count = number.count('1')\n puts(number)\n return count\nend", "def count_bits(n)\n n.to_s(2).count \"1\"\nend", "def count_bits(n)\n n.to_s(2).count(\"1\")\nend", "def count_bits(n)\n n.to_s(2).count('1')\nend", "def count_bits(n)\n n.to_s(2).count('...
[ "0.7826926", "0.77376825", "0.77327853", "0.77301353", "0.77301353", "0.76756585", "0.7631997", "0.7508798", "0.73288584", "0.7259279", "0.7202616", "0.7174895", "0.7108298", "0.7090033", "0.70374805", "0.70365834", "0.6976598", "0.6951136", "0.69460136", "0.68574214", "0.685...
0.6848134
22
puts count_bits(1234) 5 solution 2
def count_bits(n) n.to_s(2).count "1" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def count_bits(n)\n n.to_s(2).count \"1\"\nend", "def count_bits(n)\n n.to_s(2).count('1')\nend", "def count_bits(n)\n n.to_s(2).count('1')\nend", "def count_bits(n)\n n.to_s(2).count(\"1\")\nend", "def count_bits(n)\n a = n.to_s(2).count '1'\n p \"answer for count_bits of #{n} is #{a}\"\nend", "de...
[ "0.865432", "0.8625303", "0.8625303", "0.86183196", "0.8610589", "0.8295757", "0.82433665", "0.823564", "0.81201255", "0.79647684", "0.78887093", "0.75620157", "0.7548582", "0.74914914", "0.7324738", "0.7234051", "0.7109541", "0.7099545", "0.6986227", "0.69240355", "0.6918036...
0.8666228
0
DSL to define which method to use to extract data from the value
def extract(extractor_name, method_name: extractor_name) extractors[extractor_name] = [method_name] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def value() end", "def parse_value; end", "def fetch_value(value); end", "def value\n @value ||= extract_value\n end", "def process_field_value(value)\r\n value\r\n end", "def get_value\n value\n end", "def get_value\n value\n end", "def value; end", "def value; end", "def value; ...
[ "0.6839925", "0.68185526", "0.67944854", "0.673279", "0.65708214", "0.65319824", "0.65319824", "0.6411054", "0.6411054", "0.6411054", "0.6411054", "0.6411054", "0.6411054", "0.6411054", "0.6411054", "0.6411054", "0.6411054", "0.6411054", "0.6411054", "0.6411054", "0.6411054",...
0.0
-1
Turns matching process into 2 steps: extraction of data from the value validation using the policy_klass
def match extract! policy_failure_match! || self end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def process_value(value, klass)\n begin\n klass.new(value, spec).process\n rescue Forbidden\n log.warn(\"Authorization failed for #{value.name}\")\n rescue Exception => e\n log.error(\"Error processing value: #{e.message}\")\n end\n end", "def policy2(label, content)\n...
[ "0.57868034", "0.55406255", "0.54608876", "0.5293349", "0.52048814", "0.511393", "0.50862837", "0.5063285", "0.5036427", "0.4972736", "0.4924464", "0.4923072", "0.48820618", "0.48237127", "0.4819585", "0.4809038", "0.47916794", "0.47327992", "0.47172672", "0.4708374", "0.4708...
0.6588328
0
Turns value into the hash of extracted data
def mapped keys = self.class.extractors.keys Hash[keys.zip(@context.values_at(*keys))] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def hash\n [value].hash\n end", "def hash\n [value].hash\n end", "def hash\n value.hash\n end", "def hash\n\t\tvalue.hash\n\tend", "def hash\n @value.hash\n end", "def hash\n value_id.hash\n end", "def to_hash\n call\n @hash = @value\n @has...
[ "0.73495233", "0.73495233", "0.70882034", "0.70189923", "0.6975112", "0.68765146", "0.6728257", "0.6559627", "0.6319286", "0.6319286", "0.62592393", "0.61572456", "0.61363494", "0.61363494", "0.61354786", "0.61289245", "0.6123918", "0.60855645", "0.6072941", "0.6072941", "0.6...
0.0
-1
Retrieve a section of the source path
def path_part(part) @_path_parts ||= app.blog.drafts.path_matcher.match(path).captures @_path_parts[app.blog.drafts.matcher_indexes[part]] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def section\n @section || path_section\n end", "def path_section\n $1 if @basename.to_s =~ /\\.(\\d\\w*)\\./\n end", "def source_path\n source[:path]\n end", "def section_of(file, section_name) \n File.read(file).split(/^(?==)/).each do |section|\n lines = section.split(\"...
[ "0.722931", "0.70111966", "0.6726607", "0.6574139", "0.648108", "0.6360375", "0.6331258", "0.6286356", "0.62368655", "0.62356627", "0.619478", "0.6108201", "0.6106228", "0.60805106", "0.5960745", "0.5958364", "0.5957925", "0.5951008", "0.59408015", "0.5935312", "0.5935312", ...
0.0
-1
Returns current date as we can't guess when the article will be published We need this in place or the layout used for blog posts might blow up
def date Time.now.in_time_zone end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def pub_date\n Date.today\n end", "def date_published\n created_at.strftime(\"%b %d, %Y\")\n end", "def article_post_date(article)\n if article.posted_at.nil?\n content = article.issue.date.strftime(\"%A %B %d, %Y\") \n else\n content = article.posted_at.strftime(\"%A %B %d, %Y - %...
[ "0.7649044", "0.7185731", "0.71639967", "0.71489507", "0.71115744", "0.7070092", "0.7070092", "0.698247", "0.6968161", "0.6943806", "0.6867545", "0.6864636", "0.6864636", "0.6855636", "0.6838868", "0.6831942", "0.68055356", "0.68055356", "0.6795687", "0.6788045", "0.67686677"...
0.6089736
79
Extends resource data adding the date field
def data super.dup.merge(date: date) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def adicionar_data\n self.date = Date.today\n end", "def initialize data\n super\n self['date'] = Time.at date / 1_000\n end", "def attributes(*args)\n attrib = super(*args)\n attrib[:register_date] = object.register_date.to_time.iso8601 unless object.register_date.blank?\n attr...
[ "0.6676965", "0.6610571", "0.6370896", "0.6313465", "0.6212929", "0.60945684", "0.6042348", "0.6035376", "0.60090274", "0.59587485", "0.59414", "0.59414", "0.58471525", "0.58471525", "0.58471525", "0.58471525", "0.58306706", "0.58135444", "0.58135444", "0.58041906", "0.580419...
0.7245228
0
helper methods print lines from buffer using prefix before each
def plines(buffer, prefix=" *") prefix ||= "" buffer.lines.each do |line| puts prefix + " " + line end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def buffer_lines\n buffer_line_cycle.map { |i| self[i] }.join(\"\\n\")\n end", "def print_buffer(buf)\n $stdout.print buf if @flush_buffer\n $stdout.flush unless $stdout.sync\n end", "def buffer( msg, flush: true )\n return buffer_reset if quiet\n if msg.respond_to? :each\n msg....
[ "0.619022", "0.5904538", "0.58760804", "0.5739069", "0.5695088", "0.56416166", "0.56342965", "0.5587519", "0.5574825", "0.5543094", "0.5453709", "0.5417501", "0.5412834", "0.540356", "0.5399562", "0.53978837", "0.5397668", "0.53917885", "0.53865063", "0.5385628", "0.53830814"...
0.8215807
0
Remembers a user in a persistent session.
def remember(user) user.remember cookies.permanent.signed[:user_id] = user.id cookies.permanent[:remember_token] = user.remember_token end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def reset_user\n return unless exists?(:previous_user)\n set :user, fetch(:previous_user)\n unset :previous_user\n clear_sessions\n end", "def change_password\n @user = User.find_by_id(session[:remember_token])\n end", "def log_in_user!(user)\n session[:session_token] = ...
[ "0.675591", "0.6644072", "0.6311052", "0.6311052", "0.62816244", "0.62358135", "0.6200064", "0.6200064", "0.6180077", "0.61798525", "0.6169222", "0.6156497", "0.6137487", "0.61251116", "0.6117853", "0.6090493", "0.60684174", "0.6063047", "0.60603493", "0.605217", "0.6049069",...
0.5917268
68
Forgets a persistent session.
def forget(user) user.forget cookies.delete(:user_id) cookies.delete(:remember_token) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def reset_session!\n raw_session.clear\n end", "def abandon!\n @user = nil\n session.delete\n end", "def abandon!\n @user = nil\n session.delete\n end", "def abandon!\n @user = nil\n session.clear\n end", "def invalidate_session\n @sequence = 0\n ...
[ "0.7149095", "0.7059213", "0.7059213", "0.70340604", "0.69786507", "0.68063825", "0.6668415", "0.6590212", "0.65894204", "0.65851307", "0.65851307", "0.6546038", "0.6429771", "0.6429771", "0.6391262", "0.63660854", "0.63422614", "0.6315281", "0.63146967", "0.62607706", "0.625...
0.0
-1
GET /poblamiento_import_locations GET /poblamiento_import_locations.json
def index @poblamiento_import_locations = PoblamientoImportLocation.all respond_to do |format| format.html # index.html.erb format.json { render json: @poblamiento_import_locations } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n @poblamiento_import_location = PoblamientoImportLocation.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @poblamiento_import_location }\n end\n end", "def locations\n get('locations')\n end", "def index\n locations = ...
[ "0.6899725", "0.6819118", "0.6551288", "0.64867944", "0.6461181", "0.6443942", "0.63710064", "0.6364207", "0.6344871", "0.63374984", "0.6308447", "0.6271906", "0.6264768", "0.62133837", "0.6203406", "0.6179522", "0.6179522", "0.616725", "0.61648804", "0.61536264", "0.6139612"...
0.77058744
0
GET /poblamiento_import_locations/1 GET /poblamiento_import_locations/1.json
def show @poblamiento_import_location = PoblamientoImportLocation.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render json: @poblamiento_import_location } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @poblamiento_import_locations = PoblamientoImportLocation.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @poblamiento_import_locations }\n end\n end", "def new\n @poblamiento_import_location = PoblamientoImportLocation.new\n\n resp...
[ "0.76524866", "0.67205846", "0.6501822", "0.6411969", "0.6402902", "0.6372215", "0.6346025", "0.6223413", "0.619312", "0.6160288", "0.6157224", "0.610801", "0.6107701", "0.60660183", "0.60203147", "0.59803003", "0.59748673", "0.5941163", "0.5910019", "0.5910019", "0.59053624"...
0.72188187
1
GET /poblamiento_import_locations/new GET /poblamiento_import_locations/new.json
def new @poblamiento_import_location = PoblamientoImportLocation.new respond_to do |format| format.html # new.html.erb format.json { render json: @poblamiento_import_location } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @poblamiento_import_location = PoblamientoImportLocation.new(params[:poblamiento_import_location])\n\n respond_to do |format|\n if @poblamiento_import_location.save\n format.html { redirect_to @poblamiento_import_location, notice: 'Poblamiento import location was successfully created...
[ "0.7444555", "0.69598746", "0.69023925", "0.6878459", "0.68602383", "0.68160504", "0.68160504", "0.6813999", "0.6807802", "0.6786816", "0.6786816", "0.6786816", "0.6786816", "0.6786816", "0.6784915", "0.6784915", "0.67729616", "0.6771963", "0.6764837", "0.67473036", "0.671905...
0.79780453
0
POST /poblamiento_import_locations POST /poblamiento_import_locations.json
def create @poblamiento_import_location = PoblamientoImportLocation.new(params[:poblamiento_import_location]) respond_to do |format| if @poblamiento_import_location.save format.html { redirect_to @poblamiento_import_location, notice: 'Poblamiento import location was successfully created.' } format.json { render json: @poblamiento_import_location, status: :created, location: @poblamiento_import_location } else format.html { render action: "new" } format.json { render json: @poblamiento_import_location.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def import\n Rails.logger.info(\"Beginning import of TripAdvisor location data\")\n data = JSON.parse(io.read)\n\n import_location(nil, data)\n Rails.logger.info(\"Finished import of TripAdvisor location data\")\n end", "def upload_locations\n puts 'Uploading Locations'\n\n cities_fi...
[ "0.68779653", "0.6628438", "0.62503076", "0.61057556", "0.6060425", "0.5926581", "0.5896028", "0.588711", "0.5885446", "0.58408976", "0.58370364", "0.58257776", "0.5786414", "0.57785976", "0.57407314", "0.57345337", "0.5721761", "0.57083577", "0.5647262", "0.5630686", "0.5623...
0.71197987
0
PUT /poblamiento_import_locations/1 PUT /poblamiento_import_locations/1.json
def update @poblamiento_import_location = PoblamientoImportLocation.find(params[:id]) respond_to do |format| if @poblamiento_import_location.update_attributes(params[:poblamiento_import_location]) format.html { redirect_to @poblamiento_import_location, notice: 'Poblamiento import location was successfully updated.' } format.json { head :ok } else format.html { render action: "edit" } format.json { render json: @poblamiento_import_location.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @poblamiento_import_location = PoblamientoImportLocation.new(params[:poblamiento_import_location])\n\n respond_to do |format|\n if @poblamiento_import_location.save\n format.html { redirect_to @poblamiento_import_location, notice: 'Poblamiento import location was successfully created...
[ "0.6599074", "0.61258763", "0.6080014", "0.60561603", "0.60143405", "0.59122187", "0.5885753", "0.5848179", "0.5847799", "0.58467287", "0.5845927", "0.58457327", "0.5833417", "0.5800562", "0.5757697", "0.5754331", "0.5727585", "0.5704201", "0.56955457", "0.56848204", "0.56578...
0.7118561
0
DELETE /poblamiento_import_locations/1 DELETE /poblamiento_import_locations/1.json
def destroy @poblamiento_import_location = PoblamientoImportLocation.find(params[:id]) @poblamiento_import_location.destroy respond_to do |format| format.html { redirect_to poblamiento_import_locations_url } format.json { head :ok } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete\n render json: Location.delete(params[\"id\"])\n end", "def delete_json(path)\n url = [base_url, path].join\n resp = HTTParty.delete(url, headers: standard_headers)\n parse_json(url, resp)\n end", "def destroy\r\n @location = Location.find(params[:id])\r\n RemovedLocation.create(...
[ "0.68968797", "0.68108624", "0.6668683", "0.6615955", "0.65723705", "0.65567887", "0.65537447", "0.64953417", "0.6495259", "0.64799273", "0.647417", "0.6470321", "0.64641964", "0.64615774", "0.64597416", "0.64280397", "0.6415894", "0.64112216", "0.6362337", "0.63591146", "0.6...
0.75379556
0
GET /products/new see section 9 for how the unitprices are saved automatically in create and update. and If any of the unitprices_attributes in params does not have id attributes, they will be created new. The ones with ids are updated.
def new @product = Product.new build_unitprices(@product) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @price = @product.prices.new(price_params)\n\n respond_to do |format|\n if @price.save\n format.html { redirect_to product_path(@product), notice: 'Price was successfully created.' }\n format.json { render :show, status: :created, location: @price }\n else\n format...
[ "0.66455966", "0.6484774", "0.6440467", "0.62930006", "0.61771625", "0.6173489", "0.6140999", "0.61277175", "0.6108224", "0.6080552", "0.607811", "0.60329187", "0.60039914", "0.5999755", "0.59818965", "0.59787375", "0.5973713", "0.5902808", "0.58924204", "0.58910197", "0.5890...
0.73629797
0
A copy of a product is created with a new title.
def clone @clone = @product.dup @clone.title = params.require(:product)['title'] # Has_one associations are cloned but unitprices, shippingoptions, locations are not set on new product. Product.transaction do # Dup all the unitprices and assign them to new product. @product.unitprices.each do |unitprice| cloned_unitprice = unitprice.dup cloned_unitprice.save! # save unitprice with original product_id for now. @clone.unitprices << cloned_unitprice # in-memory association, clone hasn't been saved yet. end # Assign existing shipping options to new product (HABTM update). @product.shippingoptions.each do |shipopt| @clone.shippingoptions << shipopt end # Assign existing to-locations to new product (HABTM update). @product.locations.each do |location| @clone.locations << location end # Assign existing payment methods to new product (HABTM update). @product.payment_methods.each do |pay| @clone.payment_methods << pay end # Up to this point the only changes to db are the new unitprices. # Save will create all the HABTM association records, and update the new unitprices to belong to the clone. @clone.save! # This will cause the rollback and show a 500 error. Not sure how to do this nicely. redirect_to [:vendor, @clone], notice: 'Product was cloned, this is the new copy' end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new_product_with_title(title)\n Product.new(:title => title,\n :description => products(:ruby).description,\n :price => products(:ruby).price,\n :image_url => products(:ruby).image_url)\n end", "def add_to_product\n\t\tif product_title_exists...
[ "0.77507406", "0.71946734", "0.69042426", "0.66443276", "0.6634355", "0.6524918", "0.63881266", "0.63127637", "0.62452346", "0.62195283", "0.6215587", "0.619511", "0.6138929", "0.6110003", "0.60638976", "0.6031498", "0.60152835", "0.6014152", "0.5975747", "0.59545463", "0.594...
0.62942016
8
Products never get deleted because orders reference them and orders are never deleted.
def destroy if @product.vendor == current_user @product.deleted = true @product.image1 = nil # Depending on paperclip settings, this may delete image off disk. @product.image2 = nil @product.image3 = nil if @product.save redirect_to vendor_products_path, notice: 'This product has been deleted' else redirect_to vendor_products_path, alert: 'Error deleting product' end else # Deleting someone elses product. raise NotAuthorized end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @product.destroy\n set_products\n end", "def before_destroy\n self.product.destroy\n\nend", "def test_remove_product\n o = Order.new\n o.expects(:cleanup_promotion).times(4)\n o.add_product(items(:red_lightsaber), 2)\n o.add_product(items(:blue_lightsaber), 2)\n assert_equa...
[ "0.71984434", "0.7078697", "0.6811449", "0.6730168", "0.66860336", "0.66597694", "0.66529346", "0.659777", "0.6584689", "0.6542916", "0.6501084", "0.6461571", "0.6453831", "0.6439384", "0.6438378", "0.64335895", "0.6413389", "0.6314775", "0.6304237", "0.62965447", "0.62916964...
0.6110735
37
Ensure a fixed number of unitprices show up in the form.
def build_unitprices(product) i = product.unitprices.count while (i < 8) do product.unitprices.build(price: '') i += 1 end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def price_in_five_centimes\n if price and price % 0.05 != 0.0\n errors.add(:price, \"Price must be in 0.05 steps.\")\n end\n end", "def quantity_cannot_be_greater_than_tickets_available\n \tremaining_ticket_count = showing.tickets_remaining\n \tif quantity != nil && quantity > remaining_ticket_coun...
[ "0.5466684", "0.537547", "0.5330248", "0.5328209", "0.52206826", "0.521903", "0.5216043", "0.52137804", "0.520274", "0.51983595", "0.5125927", "0.5125129", "0.51031417", "0.50878626", "0.50853264", "0.50823766", "0.5060707", "0.50602424", "0.5051407", "0.5045258", "0.50426143...
0.6242579
0
Defines a linked timezone.
def linked_timezone(identifier, link_to_identifier) @timezone = LinkedTimezoneInfo.new(identifier, link_to_identifier) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def linked_timezone(identifier); end", "def linked_timezone(identifier); end", "def linked_timezone(identifier); end", "def linked_timezone(identifier); end", "def linked_timezone(identifier)\n identifier = StringDeduper.global.dedupe(identifier)\n @timezones << identifier\n @lin...
[ "0.80107456", "0.80107456", "0.80107456", "0.80107456", "0.76864934", "0.7653597", "0.7530103", "0.7530103", "0.7253627", "0.7253627", "0.7253627", "0.72285885", "0.72285885", "0.72285885", "0.72285885", "0.72285885", "0.71845394", "0.71845394", "0.71845394", "0.71845394", "0...
0.7897046
5
Returns the last TimezoneInfo to be defined with timezone or linked_timezone.
def get @timezone end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def tz_timezone ; timezone? ? TZInfo::Timezone.get(@timezone) : nil ; end", "def time_zone\n addresses.primary.blank? || addresses.primary.time_zone.blank? ? nil : addresses.primary.time_zone\n end", "def timezone\n @history.objects.find { |o| o.name == \"tz\" }.val\n end", "def canonical_zone\n...
[ "0.70822656", "0.68752325", "0.6812707", "0.6753517", "0.66245914", "0.66065073", "0.65770215", "0.6569467", "0.65009236", "0.64806706", "0.64806706", "0.64806706", "0.64806706", "0.6449225", "0.64392763", "0.64384913", "0.6403027", "0.6300928", "0.626075", "0.6251509", "0.62...
0.6098722
29
we avoid going back to the file so as not to block page requests with imagemagick calls
def geometry(style_name='original') if style_name == 'original' Paperclip::Geometry.parse("#{original_width}x#{original_height}") else Paperclip::Geometry.parse(style_dimensions(style_name)) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def extract_first_page_images\n #######\n # Docsplit.extract_images(document.file.file, :size => %w{200x 700x 1000x}, :format => :jpg, :pages => %w{1}, output: output_path)\n Docsplit.extract_images(file.path, :size => %w{200x 700x 1000x}, :format => :jpg, :pages => %w{1}, output: \"public/#{self.do...
[ "0.5793652", "0.57833153", "0.5717043", "0.5672693", "0.55736375", "0.5529052", "0.55199176", "0.55189204", "0.5492095", "0.54643625", "0.5442433", "0.54345125", "0.54338807", "0.54086167", "0.5399223", "0.53987074", "0.5393844", "0.537032", "0.5358453", "0.535736", "0.535405...
0.0
-1
To show thread messages and origin message
def new chthread = TChannelMessage.find_by(chmsg_id: params[:chthread_id]) channelthread chthread @chmsg_original = TChannelMessage.select("m_users.user_name,t_channel_messages.chmsg_id,t_channel_messages.count,t_channel_messages.chmessage,t_channel_messages.created_at,t_channel_messages.updated_at") .joins("join m_users on m_users.user_id=t_channel_messages.chsender_id") .where("t_channel_messages.chmsg_id=?", session[:chthread_id]).order("t_channel_messages.created_at ASC") @chthread_msg = HChmessageReply.select("m_users.user_name,h_chmessage_replies.chmsg_id,h_chmessage_replies.chthreadmsg,h_chmessage_replies.created_at") .joins("join m_users on m_users.user_id=h_chmessage_replies.chreplyer_id") .where("h_chmessage_replies.chmsg_id=? and h_chmessage_replies.chreplyer_id=?", session[:chthread_id], session[:user_id]).order("h_chmessage_replies.created_at ASC") @chmsg_original.each { |thread| @thredcount = HChmessageReply.select("*") .joins("join t_channel_messages on t_channel_messages.chmsg_id=h_chmessage_replies.chmsg_id") .where("h_chmessage_replies.chmsg_id=?", thread.chmsg_id) thread.count = (@thredcount.size).to_s } #TChunreadMessage.joins("join t_channel_messages on t_channel_messages.chmsg_id=t_chunread_messages.chmsg_id") #.where("chuser_id=? and t_channel_messages.channel_id =? ", session[:user_id], session[:clickchannel_id]).update_all(is_read: 0) main end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n commontator_thread_show(@forum)\n end", "def info_display\n @queue << \"i d\"\n end", "def get_thread_details(username, thread_id)\n $LOG.i \"running \" + __method__.to_s\n @client.get '/mc/v1/threads/' + username + '/' + thread_id\n end", "def show\n @page_...
[ "0.6144304", "0.6058604", "0.6024566", "0.59703356", "0.5968872", "0.5938567", "0.5876829", "0.57643205", "0.57417446", "0.5736701", "0.5725958", "0.56999594", "0.56988114", "0.56915206", "0.5687443", "0.5687443", "0.5687443", "0.5685006", "0.5681816", "0.56746376", "0.567296...
0.0
-1
To review the reply messages
def chreplymsg @chreplymsg = HChmessageReply.select("m_users.user_name,h_chmessage_replies.chmsg_id,h_chmessage_replies.chthreadmsg,h_chmessage_replies.created_at") .joins("join m_users on m_users.user_id=h_chmessage_replies.chreplyer_id") .where("h_chmessage_replies.chmsg_id=?", params[:chclickid]).order("h_chmessage_replies.created_at ASC") #TChunreadMessage.joins("join t_channel_messages on t_channel_messages.chmsg_id=t_chunread_messages.chmsg_id") #.where("chuser_id=? and t_channel_messages.channel_id =? ", session[:user_id], session[:clickchannel_id]).update_all(is_read: 0) main end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def receive_replies(connection); end", "def reply\n end", "def get_reply\n @reply\n end", "def reply msg\n\t\t# get message from user\n\t\trep = @@client.message(msg)\n\t\t# handle the message\n\t\tputs handle_message(rep)\n\t\t\n\t\t# interactive Wit\n\t\t#@@client.interactive(method(:handle_message))\...
[ "0.7030759", "0.7028954", "0.6884325", "0.6863042", "0.677828", "0.6772718", "0.67090696", "0.66723484", "0.66610813", "0.66291845", "0.65896547", "0.6588036", "0.6563135", "0.65187424", "0.6517531", "0.65031785", "0.64656776", "0.64552647", "0.64460284", "0.6417484", "0.6411...
0.6499028
16
adds an error if the end time is after the start time does not add an error if the end time is not set
def end_time_after_start_time if self.end_time && self.end_time < self.start_time self.errors.add(:end_time, "The end time must be after the start time") end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ends_after_start\n unless end_time.nil? || start_time.nil?\n errors[:end_time] << \"can't be before start time\" if end_time < start_time\n end\n end", "def end_time_after_start_time\n return if end_time.blank? || start_time.blank?\n\n if end_time < start_time\n errors.add(:end_time, \...
[ "0.83648384", "0.8204546", "0.8152565", "0.8096388", "0.80935", "0.80529547", "0.7953774", "0.7948906", "0.7931938", "0.7909975", "0.7800588", "0.7753684", "0.77219385", "0.7656235", "0.75947905", "0.75841564", "0.75136876", "0.7364433", "0.73034805", "0.7224438", "0.7224438"...
0.8324124
1
Appends the input text onto the log text I am aware that these two methods are duplicates nd we could merge them I am not convinced that the code would be any more readable or maintainable It does cut down the number of tests though
def add_log_text(text) self.log_text = "" if self.log_text.nil? self.log_text += text + "\n" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def append(text); end", "def writeLog(text)\n\n Utils_visiona.verifyInput(String, text.class)\n\n return if @logFile.nil?\n\n Thread.new do\n\n File.open(@logFile, 'a+') {|file| file.puts \"#{Time.now} #{text}\"}\n end\n\t\tend", "def log(text)\n puts text\n end", "def proc...
[ "0.6779716", "0.67084086", "0.6689335", "0.6638899", "0.65558976", "0.65307873", "0.6513991", "0.63158906", "0.6293744", "0.62791646", "0.6176243", "0.61143416", "0.6059186", "0.6041899", "0.6040502", "0.60084134", "0.6003947", "0.59923124", "0.5975583", "0.5969165", "0.59087...
0.7581811
0
Appends the input text onto the error text
def add_error_text(text) self.error_text = "" if self.error_text.nil? self.error_text += text + "\n" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def append_error(msg)\n @errors.empty? ? @errors = msg : @errors << \"\\n\" + msg + \" \"\n end", "def xprint(text)\n self.error_messages += text\n end", "def display_error\n error <<~MSG\n Sorry, please check\n your input to verify it\n is correct.\n MSG\n prompt error\nend", "def err(input)\n...
[ "0.6964977", "0.6959104", "0.6735986", "0.66883725", "0.66656464", "0.6633878", "0.6601589", "0.6544596", "0.63583094", "0.63485295", "0.6325897", "0.63173395", "0.6262158", "0.62589586", "0.62463665", "0.6222522", "0.6211961", "0.61665916", "0.615575", "0.6139618", "0.604065...
0.8114537
0
Creates run time based on start and end time If there is no end_time, display 'Run has not completed.'
def display_run_time if self.end_time return run_time_or_time_elapsed.gmtime.strftime('%R:%S') else return "Run has not completed." end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def run_time\n return nil unless self.start_time\n (self.end_time || Time.now) - self.start_time\n end", "def start=(time); end", "def run_time_or_time_elapsed\n if self.end_time \n return Time.at(self.end_time - self.start_time)\n else\n return Time.at(Time.now - self....
[ "0.69156563", "0.6723885", "0.6509999", "0.64750457", "0.64750457", "0.64385766", "0.6414998", "0.6414242", "0.63969445", "0.63864505", "0.63355523", "0.6318597", "0.63083726", "0.62978446", "0.6261814", "0.6190965", "0.6143857", "0.61306256", "0.61272526", "0.61059725", "0.6...
0.74994683
0
Creates run time based on start and end time If there is no end_time, returns time between start and now
def run_time_or_time_elapsed if self.end_time return Time.at(self.end_time - self.start_time) else return Time.at(Time.now - self.start_time) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def run_time\n return nil unless self.start_time\n (self.end_time || Time.now) - self.start_time\n end", "def start=(time); end", "def as_point_in_time\n if time\n time\n elsif start_time\n start_time\n else\n end_time\n end\n end", "def get_run_time\n return next_to_l...
[ "0.742195", "0.6894294", "0.6844839", "0.6826245", "0.6791383", "0.6742184", "0.6721079", "0.6707918", "0.6698869", "0.66659945", "0.66466177", "0.66023576", "0.66023576", "0.6501535", "0.64271766", "0.64252484", "0.6362807", "0.6319231", "0.63012576", "0.62746423", "0.626269...
0.7135071
1
Determines error message color based on success and whether or not there is error text Return value corresponds to a css color
def status_color if self.success && self.error_text.nil? return 'green' elsif self.success return 'yellow' else return 'red' end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def error_color(text)\r\n \"<font color=red>#{text}</font>\"\r\n end", "def status_color\n if skipped?\n :yellow\n elsif error?\n :red\n else\n :green\n end\n end", "def error_style(error)\n red_style(error)\nend", "def results_color results\n if result...
[ "0.7828154", "0.7481136", "0.7416134", "0.7267331", "0.6860741", "0.6811196", "0.68086046", "0.67306685", "0.67154574", "0.6694889", "0.6645804", "0.65481657", "0.6529466", "0.6485719", "0.6459736", "0.64422506", "0.63971996", "0.63760865", "0.63620114", "0.6359302", "0.63544...
0.7988959
0
Register a new event
def event(name, opts = {}, &block) event = Event.new(name, opts.merge(namespace: self), &block) @events << event event end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def on_event_registered(unit, event)\n event\n end", "def on_event(event_name=:__default__, &block)\n event_handler.register( event_name, &block )\n end", "def event(type)\n Event.register(type, self)\n end", "def push_event event\n @event_queue << event\n end", "def add...
[ "0.74238354", "0.70845085", "0.7055231", "0.7013755", "0.690734", "0.68939024", "0.68924886", "0.68883485", "0.6864106", "0.6814125", "0.6794003", "0.6791694", "0.67783976", "0.67650807", "0.6764175", "0.66909873", "0.6688942", "0.6686366", "0.66388506", "0.6638677", "0.66382...
0.60856676
55
Broadcast a new event
def announce(event_name, opts = {}, &block) announce_local(event_name, opts, &block) @children.each { |c| c.announce(event_name, opts, &block) } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def broadcast(public, event)\n core.broadcast(public, event)\n end", "def broadcast\n end", "def broadcast(event_name, payload)\n @event_queue << { id: SecureRandom.uuid, name: event_name, payload: payload }\n end", "def broadcast(event, payload)\n subscribers_for(even...
[ "0.7349347", "0.7308165", "0.7224545", "0.70793587", "0.6936649", "0.69103456", "0.6647351", "0.6631629", "0.6628194", "0.65857935", "0.64923805", "0.6465537", "0.6413392", "0.6363786", "0.63426864", "0.63230175", "0.6312756", "0.6301428", "0.62849617", "0.6209994", "0.619599...
0.0
-1
will search the admin table for an existing admin username and password combination need to figure out how to search other tables as well?
def create # @admin = Admin.create(admin_params) @teacher = Teacher.find_by(username: params[:admin][:username]) @admin = Admin.find_by(username: params[:admin][:username]) if @admin && @admin.authenticate(params[:admin][:password]) session[:admin_id] = @admin.id redirect_to courses_path elsif @teacher && @teacher.authenticate(params[:admin][:password]) p "it read the line above" session[:teacher_id] = @teacher redirect_to courses_path else p "rejected" render 'new' end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def search_admins\n unless @current_admin.is_super_admin\n flash[:error]=\"You are not authorized to navigate to this page \"\n redirect_to admin_index_path\n return\n end\n @sub_admin=Admin.new\n end", "def index\n authorize Admin\n @admins = User.find_by_sql([\"select * from user...
[ "0.6807442", "0.67733324", "0.65366864", "0.65278864", "0.6446474", "0.6385242", "0.6307548", "0.6297387", "0.62568223", "0.6243475", "0.62289524", "0.6220433", "0.6165949", "0.6141036", "0.6130882", "0.61151654", "0.610312", "0.6065382", "0.60150623", "0.59990656", "0.599194...
0.0
-1
Check the cache before a database lookup unless a hash is supplied.
def [](*args) args = args.first if (args.size == 1) return super(args) if args.is_a?(Hash) ck = cache_key(args) if obj = @cache_store.get(ck) return obj end if obj = super(args) @cache_store.set(ck, obj, @cache_ttl) end obj end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_cache(type, id)\n end", "def check_cache(type, id)\n end", "def check_cache(type, id)\n end", "def cached?; end", "def cache_on?; end", "def cache_on?; end", "def check_from_cache(url, username, password)\n key = generate_key url, username, password\n\n res = @@file_cache...
[ "0.639195", "0.639195", "0.6367927", "0.62846965", "0.6221912", "0.6221912", "0.6092861", "0.5939821", "0.5928824", "0.5928824", "0.5845644", "0.58036023", "0.5743142", "0.57239115", "0.57224095", "0.57093984", "0.5706287", "0.56936187", "0.56897676", "0.5687041", "0.5680016"...
0.0
-1
Set the time to live for the cache store, in seconds (default is 3600, so 1 hour).
def set_cache_ttl(ttl) @cache_ttl = ttl end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ttl_in_seconds= value\n @ttl_in_seconds = value\n refresh_rates_expiration! if ttl_in_seconds\n end", "def ttl_in_seconds=(value)\n @ttl_in_seconds = value\n refresh_rates_expiration! if ttl_in_seconds\n end", "def ttl_in_seconds=(value)\n @ttl_in_...
[ "0.7135701", "0.71057475", "0.71057475", "0.71057475", "0.70213604", "0.7001946", "0.69455546", "0.6922091", "0.6860274", "0.6834666", "0.6785477", "0.6687079", "0.66237134", "0.6466216", "0.6409496", "0.6388343", "0.6381062", "0.63783276", "0.6365913", "0.6355517", "0.627981...
0.62860787
20
Copy the cache_store and cache_ttl to the subclass.
def inherited(subclass) super store = @cache_store ttl = @cache_ttl subclass.instance_eval do @cache_store = store @cache_ttl = ttl end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cache_store(*args)\n super { |key, value| @store[key] = value }\n end", "def inherited(subclass)\n super\n subclass.acts_as_cacheable_cache = acts_as_cacheable_cache\n subclass.acts_as_cacheable_time_to_live = acts_as_cacheable_time_to_live\n subclass.acts_as_c...
[ "0.689181", "0.6611153", "0.62799364", "0.6277294", "0.62738353", "0.62738353", "0.6273459", "0.6273459", "0.62630147", "0.6168717", "0.61601317", "0.61601317", "0.6159486", "0.6024914", "0.6006554", "0.5994362", "0.5967278", "0.59128284", "0.59011626", "0.58886665", "0.58544...
0.7922229
0
Delete the entry with the matching key from the cache
def cache_delete(key) @cache_store.delete(key) nil end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete(key)\n id = @cache[key]\n @cache.delete(key)\n @index.delete(id) if id\n end", "def del(key)\n log(\"remove :Cache, #{key}\")\n connection.remove(:Cache, key)\n end", "def delete(key)\n ref = @cache.delete(key)\n ref.__getobj__ rescue nil\n end", ...
[ "0.81256825", "0.8063641", "0.8043744", "0.7999689", "0.79984075", "0.7759497", "0.7729625", "0.7634428", "0.7624118", "0.76193583", "0.75928366", "0.75742316", "0.7552471", "0.75266975", "0.75266975", "0.75266975", "0.75266975", "0.75266975", "0.75030255", "0.74667966", "0.7...
0.8115898
1
Return a key string for the pk
def cache_key(pk) "#{self}:#{Array(pk).join(',')}" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def to_s\n @real_key\n end", "def key\n @key.id2name\n end", "def primary_key_string\n key_attributes.join(' ').parameterize\n end", "def key\n to_a[0..(num_key_fields-1)].join(\"-\")\n end", "def scaffold_primary_key\n get_key_array_safe(key).name\n end", "def cache_k...
[ "0.76021665", "0.7559105", "0.7519196", "0.74659264", "0.7429365", "0.7428305", "0.7419473", "0.739566", "0.7392887", "0.7371973", "0.7260838", "0.72606766", "0.723994", "0.72223955", "0.7198893", "0.7178159", "0.71750444", "0.71750444", "0.7172094", "0.7155475", "0.71388716"...
0.7166798
19
Remove the object from the cache when deleting
def delete cache_delete super end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cache_delete\n model.send(:cache_delete, cache_key)\n end", "def destroy_cache(obj)\n storage.del(key(obj))\n end", "def cache_delete\n model.cache_delete_pk(pk)\n end", "def delete(key)\n ref = @cache.delete(key)\n ref.__getobj__ rescue nil\n en...
[ "0.8151326", "0.81008375", "0.80786186", "0.7660673", "0.7481445", "0.74329716", "0.7384611", "0.7384611", "0.7368783", "0.7313292", "0.7224962", "0.72207284", "0.72122324", "0.7190715", "0.71583945", "0.7138529", "0.7095784", "0.70811075", "0.70704514", "0.7052158", "0.70173...
0.8104902
2
Remove the object from the cache when updating
def update_values(*args) cache_delete super end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete\n cache_delete\n super\n end", "def delete\n cache_delete\n super\n end", "def cache_delete\n model.send(:cache_delete, cache_key)\n end", "def destroy_cache(obj)\n storage.del(key(obj))\n end", "def clear_cache; end", "...
[ "0.7346217", "0.7346217", "0.73225236", "0.72895294", "0.714288", "0.7070399", "0.69532645", "0.6904988", "0.68791467", "0.6871663", "0.68677336", "0.68677336", "0.6862695", "0.684924", "0.67988265", "0.6796695", "0.6754142", "0.67315716", "0.6712842", "0.67037153", "0.668487...
0.65704465
28
Delete this object from the cache
def cache_delete model.send(:cache_delete, cache_key) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete\n cache_delete\n super\n end", "def delete\n cache_delete\n super\n end", "def destroy_cache(obj)\n storage.del(key(obj))\n end", "def cache_delete\n model.cache_delete_pk(pk)\n end", "def delete(key)\n ref = @cache...
[ "0.81441265", "0.81441265", "0.80223024", "0.7975368", "0.7692353", "0.75405985", "0.75405985", "0.7403827", "0.7389887", "0.7238018", "0.71372825", "0.7122454", "0.7107692", "0.7103104", "0.70745534", "0.7069298", "0.70410645", "0.702203", "0.70173144", "0.7014405", "0.70122...
0.82878786
0
Subject can be set in your I18n file at config/locales/en.yml with the following lookup: en.alert.opportunities.subject
def opportunities(sport_events) @sport_events = sport_events subject = @sport_events.count.to_s + " Opportunités de pari détectées !" mail to: "louis.fourrier@gmail.com, samy.jazaerli@gmail.com", subject: subject end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def deliver_invitation(options = {})\n super(options.merge(subject: _('A Data Management Plan in %{application_name} has been shared with you') % {application_name: Rails.configuration.branding[:application][:name]}))\n end", "def translate(mapping, key)\n I18n.t(:\"#{mapping.name}_subject\", :scope => [:...
[ "0.66533315", "0.66060114", "0.65603125", "0.6526741", "0.65084374", "0.6506447", "0.6403772", "0.6401163", "0.6341616", "0.6230191", "0.6209554", "0.6205333", "0.61525786", "0.6142047", "0.6141075", "0.6133875", "0.60556275", "0.6044861", "0.59912807", "0.59784645", "0.59737...
0.53612256
89
Subject can be set in your I18n file at config/locales/en.yml with the following lookup: en.alert.trade_updates.subject
def trade_updates(date) @update_date = date mail to: "louis.fourrier@gmail.com", subject: "Mise à jour des trades sur le serveur !" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def subject\n self['subject'] || msg['subject']\n end", "def translate(mapping, key)\n I18n.t(:\"notifications_subject\", :scope => [:eventifier, :notifications, key],\n :default => [:subject, key.to_s.humanize])\n end", "def subject=(subject); @message_impl.setSubject subject; end", ...
[ "0.6575818", "0.6550315", "0.65243316", "0.6517958", "0.64954245", "0.6421595", "0.6206513", "0.6186115", "0.6075865", "0.6064591", "0.6055966", "0.6044399", "0.6025707", "0.5984743", "0.5970088", "0.5943675", "0.5938585", "0.59241366", "0.59057397", "0.58683765", "0.58580685...
0.0
-1
redefine your position_taken? method here, so that you can use it in the valid_move? method above.
def position_taken?(board, index) board[index] != " " && board[index] != "" && board[index] != nil end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def position_taken?(board, position)\n return false if valid_move?(board, position)\n return true unless valid_move?(board, position)\nend", "def position_taken?\nend", "def valid_move?(board, index)\n if index.between?(0, 8)\n # re-define your #position_taken? method here, so that you can use it in the #v...
[ "0.8409533", "0.8161412", "0.80915326", "0.802741", "0.80150443", "0.78980684", "0.7893883", "0.7886275", "0.78447807", "0.7843449", "0.7831682", "0.78148174", "0.7813732", "0.7810363", "0.78020334", "0.7801113", "0.7800951", "0.7789361", "0.7782831", "0.777421", "0.7774137",...
0.0
-1
Auxiliary function which is useful for fitting of linear models. Transforms a Daru::Vector, whose entries are assumed to represent levels of a categorical variable, into a Daru::DataFrame with a column of zeros and ones for each category. If +full+ is set to false, then the first category is discarded, which is useful to generate a design matrix for linear regression, when a intercept term is present in the model. === Arguments +name+ used for the naming of the columns of the returned data frame +for_model_without_intercept+ if false (which is the default), then the first column of the produced data frame will be excluded === Usage
def to_indicator_cols_df(name:, for_model_without_intercept: false) levels = self.to_a.uniq names = levels.map { |e| "#{name}_lvl_#{e}".to_sym } unless for_model_without_intercept levels.shift names.shift end cols_array = Array.new levels.each do |l| col = Array.new self.each { |e| e==l ? col.push(1.0) : col.push(0.0) } cols_array.push(col) end return Daru::DataFrame.new(cols_array, order: names) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def build!(data_set_name)\n interface(data_set_name).create_empty_data_set\n library[data_set_name] = DataSet.new(data_set_name, interface(data_set_name))\n end", "def build(data_set_name)\n raise Interfaces::DataSetAlreadyExists if interface(data_set_name).data_set_exists?\n bui...
[ "0.40999368", "0.39485714", "0.3853212", "0.3853212", "0.38175547", "0.37970096", "0.37923986", "0.37635228", "0.3752857", "0.3733816", "0.3714853", "0.3712097", "0.37051493", "0.36936587", "0.36726457", "0.36584103", "0.36017573", "0.35891798", "0.35877293", "0.35488728", "0...
0.6156844
0
get the first available employee to handle the call maybe escalate to employee with higher title later
def get_handler_for_call(call) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_employee(employee_id)\n plsql.employees2.first :employee_id => employee_id\n end", "def get_employee(employee_id)\n plsql.employees.first :employee_id => employee_id\n end", "def assigned_employee\n\t\tassignments.where(:is_active => true).first.employee \n\tend", "def last_employee\n @las...
[ "0.6267775", "0.621137", "0.58855176", "0.58566344", "0.58373904", "0.57309717", "0.5726206", "0.57045", "0.5700133", "0.56883496", "0.5626684", "0.5578307", "0.55456185", "0.5543132", "0.5501492", "0.5500486", "0.548312", "0.54752225", "0.5450107", "0.53919446", "0.53802854"...
0.0
-1
def tenant_group_params params[:] end
def user_group_ship_params params[:user_group_ship].permit(:message) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def t_group_params\n params.require(:t_group).permit(:name, :provider_aptour_id, :operator_aptour_id)\n end", "def group_params\n params[:group]\n end", "def group_params\n params[:group]\n end", "def group_params\n params[:group]\n end", "def group_params\n params.requ...
[ "0.7136619", "0.7006055", "0.7006055", "0.7006055", "0.6896343", "0.6775469", "0.67003953", "0.66925764", "0.66699547", "0.6664244", "0.6663089", "0.6661704", "0.6653869", "0.6652347", "0.6632056", "0.6628823", "0.65945137", "0.6582722", "0.6566437", "0.6556062", "0.6553556",...
0.0
-1
Return true if one or more inserts were made
def any? inserted > 0 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def inserts_valid\n @inserts_valid\n end", "def supports_multi_insert?\n true\n end", "def insertable?\n persistable? && !_assigning? && inserts_valid\n end", "def use_insert?\n !use_copy?\n end", "def any?\n raise \"#{self.class}: instance not prepare...
[ "0.7511224", "0.74842566", "0.66823214", "0.6415248", "0.63888687", "0.62641746", "0.6190296", "0.6177407", "0.60312384", "0.60134524", "0.600402", "0.59984225", "0.59966755", "0.59873146", "0.5980836", "0.5972874", "0.5959756", "0.59540427", "0.59535044", "0.59283817", "0.59...
0.65592074
3
Return true if no inserts were made
def none? !any? end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def inserts_valid\n @inserts_valid\n end", "def any?\n inserted > 0\n end", "def insertable?\n persistable? && !_assigning? && inserts_valid\n end", "def any?\n raise \"#{self.class}: instance not prepared before doing any move\" unless @prepared\n\n @tot...
[ "0.75708467", "0.6899699", "0.6822521", "0.67822516", "0.6762548", "0.6672698", "0.66053253", "0.65387934", "0.65318304", "0.6494197", "0.6472593", "0.6466557", "0.64610535", "0.63468635", "0.6284778", "0.62532336", "0.61780345", "0.61686313", "0.61520183", "0.6146029", "0.61...
0.0
-1
StorageParticipant includes Enumerable, therefore, it should respond to select...
def test_select @dashboard.register { catchall } @dashboard.launch(Ruote.define do concurrence { alpha; bravo; charly } end) while @dashboard.storage_participant.size < 3; end assert_equal( 1, @dashboard.storage_participant.select { |wi| wi.participant_name == 'bravo' }.size) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def by_participant(participant_name, opts={})\n\n return @context.storage.by_participant(\n 'workitems', participant_name, opts\n ) if @context.storage.respond_to?(:by_participant)\n\n do_select(opts) do |hwi|\n hwi['participant_name'] == participant_name\n end\n end", "def p...
[ "0.5700594", "0.5357356", "0.5315023", "0.5289066", "0.52375215", "0.52340513", "0.5222871", "0.5152753", "0.51302093", "0.51271236", "0.51271236", "0.51271236", "0.5101505", "0.50917524", "0.5081835", "0.5076479", "0.50752634", "0.5067535", "0.50376046", "0.49565315", "0.494...
0.5457961
1
Originally written by Doug Bryant in
def test_update_workitem_alt @dashboard.register_participant 'alpha', Ruote::StorageParticipant wfid = @dashboard.launch(Ruote.process_definition { alpha }) wait_for(:alpha) #wi = @dashboard.process(wfid).workitems.first # doesn't work: the returned workitem isn't a workite document, it's # just a fragment of info wi = @dashboard.process(wfid).stored_workitems.first # works OK #wi = alpha.first # works OK, but you have to grab alpha first... alpha = @dashboard.participant(wi.participant_name) wi.set_field('my_field', 'abc123') alpha.update(wi) assert_equal nil, @dashboard.process(wfid).workitems.first.fields['my_field'] assert_equal 'abc123', alpha.first.fields['my_field'] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def private; end", "def probers; end", "def schubert; end", "def specie; end", "def specie; end", "def specie; end", "def specie; end", "def berlioz; end", "def stderrs; end", "def terpene; end", "def anchored; end", "def loc; end", "def loc; end", "def loc; end", "def formation; end", ...
[ "0.7181768", "0.67454493", "0.6345762", "0.6293891", "0.6293891", "0.6293891", "0.6293891", "0.62715703", "0.6247474", "0.612452", "0.6057567", "0.6024156", "0.6024156", "0.6024156", "0.6022436", "0.59560794", "0.5947871", "0.59088194", "0.5876603", "0.58733946", "0.58590645"...
0.0
-1
GET /address_cocoons GET /address_cocoons.json
def index @address_cocoons = AddressCocoon.all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_address_cocoon\n @address_cocoon = AddressCocoon.find(params[:id])\n end", "def create\n @address_cocoon = AddressCocoon.new(address_cocoon_params)\n\n respond_to do |format|\n if @address_cocoon.save\n format.html { redirect_to @address_cocoon, notice: 'Address cocoon was succe...
[ "0.6878364", "0.6656563", "0.6349949", "0.6148203", "0.60726887", "0.60458964", "0.60354733", "0.5963437", "0.59379053", "0.5924347", "0.59092927", "0.5902422", "0.5854732", "0.57148695", "0.56926405", "0.56627816", "0.56418407", "0.56337917", "0.56016177", "0.5588973", "0.55...
0.77668846
0
GET /address_cocoons/1 GET /address_cocoons/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @address_cocoons = AddressCocoon.all\n end", "def set_address_cocoon\n @address_cocoon = AddressCocoon.find(params[:id])\n end", "def create\n @address_cocoon = AddressCocoon.new(address_cocoon_params)\n\n respond_to do |format|\n if @address_cocoon.save\n format.html ...
[ "0.75780386", "0.69681966", "0.6588273", "0.63609856", "0.6269", "0.62085164", "0.61665016", "0.6137728", "0.60824066", "0.60341966", "0.602829", "0.6027019", "0.59675306", "0.5936602", "0.5925707", "0.58905566", "0.58482796", "0.58054966", "0.5776454", "0.57721037", "0.57721...
0.0
-1
POST /address_cocoons POST /address_cocoons.json
def create @address_cocoon = AddressCocoon.new(address_cocoon_params) respond_to do |format| if @address_cocoon.save format.html { redirect_to @address_cocoon, notice: 'Address cocoon was successfully created.' } format.json { render :show, status: :created, location: @address_cocoon } else format.html { render :new } format.json { render json: @address_cocoon.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def address_cocoon_params\n params.require(:address_cocoon).permit(:line_one, :line_two, :zip_code, :person_cocoon_id)\n end", "def set_address_cocoon\n @address_cocoon = AddressCocoon.find(params[:id])\n end", "def index\n @address_cocoons = AddressCocoon.all\n end", "def update\n res...
[ "0.7060084", "0.6856831", "0.67794496", "0.63281983", "0.6082128", "0.606514", "0.6063955", "0.6023681", "0.5938629", "0.59024036", "0.57297486", "0.57282364", "0.56530535", "0.5627147", "0.560972", "0.5567507", "0.5552429", "0.55398554", "0.5531957", "0.5520639", "0.5519856"...
0.7723272
0
PATCH/PUT /address_cocoons/1 PATCH/PUT /address_cocoons/1.json
def update respond_to do |format| if @address_cocoon.update(address_cocoon_params) format.html { redirect_to @address_cocoon, notice: 'Address cocoon was successfully updated.' } format.json { render :show, status: :ok, location: @address_cocoon } else format.html { render :edit } format.json { render json: @address_cocoon.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_address_cocoon\n @address_cocoon = AddressCocoon.find(params[:id])\n end", "def address_cocoon_params\n params.require(:address_cocoon).permit(:line_one, :line_two, :zip_code, :person_cocoon_id)\n end", "def update\n respond_to do |format|\n if @cocoon_example.update(cocoon_exam...
[ "0.68165296", "0.6553078", "0.6460438", "0.6453433", "0.6356866", "0.625627", "0.6227543", "0.6172339", "0.61155766", "0.6094744", "0.6087891", "0.6068533", "0.6064659", "0.600373", "0.5958168", "0.58997", "0.5882613", "0.5873081", "0.5872717", "0.58585644", "0.58485115", "...
0.769142
0
DELETE /address_cocoons/1 DELETE /address_cocoons/1.json
def destroy @address_cocoon.destroy respond_to do |format| format.html { redirect_to address_cocoons_url, notice: 'Address cocoon was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @client_address.destroy\n respond_to do |format|\n format.html { redirect_to client_addresses_url, notice: 'Client address was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @customers_address = CustomersAddress.find(params[:id])\n ...
[ "0.6957936", "0.68548787", "0.6699446", "0.6699446", "0.6699446", "0.6699446", "0.6682233", "0.6675987", "0.66155726", "0.6600107", "0.6600107", "0.65974253", "0.6595983", "0.65710175", "0.65607315", "0.6539655", "0.6531665", "0.646794", "0.6459527", "0.6458629", "0.644555", ...
0.7809303
0
Use callbacks to share common setup or constraints between actions.
def set_address_cocoon @address_cocoon = AddressCocoon.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_...
[ "0.61637366", "0.60446453", "0.59452957", "0.591511", "0.58885515", "0.5834122", "0.57761765", "0.5702554", "0.5702554", "0.5652102", "0.5619581", "0.5423898", "0.5409782", "0.5409782", "0.5409782", "0.5394745", "0.53780794", "0.5356209", "0.5338898", "0.53381324", "0.5328622...
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def address_cocoon_params params.require(:address_cocoon).permit(:line_one, :line_two, :zip_code, :person_cocoon_id) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strong_params\n params.require(:user).permit(param_whitelist)\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def allow_params_authentication!; end", "def allowed_params\n ALLOWED_PARAMS\n end", "def default_param_whitelist\n [\"mode\"]\n...
[ "0.6981606", "0.6784227", "0.6746523", "0.67439264", "0.67361516", "0.6593381", "0.6506166", "0.64994407", "0.6483518", "0.64797056", "0.64578557", "0.6441216", "0.63811713", "0.63773805", "0.6366333", "0.63217646", "0.6301816", "0.63009787", "0.6294436", "0.62940663", "0.629...
0.0
-1
TODO: move this to a builder and combine the save account user method into a builder ensure the account user association is also created in a single transaction
def create_user return @user.send_confirmation_instructions if @user @user = User.create!(new_agent_params.slice(:email, :name, :password, :password_confirmation)) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_account\n set_user\n set_payer\n set_user_sport\n save_account\n end", "def create_account_options\n AccountOption.create!(:user => self)\n end", "def add_account_user account_user\n \n \n # find or create catalog user\n catalog_user = CatalogUser.where( user_...
[ "0.67910695", "0.65597767", "0.6475188", "0.6434148", "0.63809705", "0.6360692", "0.6300126", "0.6206417", "0.61880946", "0.61619544", "0.6097232", "0.60930026", "0.6041121", "0.60130614", "0.60086614", "0.60036594", "0.59721684", "0.5966716", "0.5957078", "0.595505", "0.5946...
0.0
-1
Funciones y codigo personalizado
def as_json { :id => self.id, :empresa => self.empresa.as_json, :usuario => self.usuario.as_json, } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def suivre; end", "def zuruecksetzen()\n end", "def mi_carrera\n\n\tend", "def functions\n\n end", "def probers; end", "def custom; end", "def custom; end", "def operations; end", "def operations; end", "def code; end", "def code; end", "def code; end", "def code; end", "def code; end",...
[ "0.7378923", "0.7030819", "0.69482577", "0.6727263", "0.65133315", "0.6508423", "0.6508423", "0.65034413", "0.65034413", "0.64614797", "0.64614797", "0.64614797", "0.64614797", "0.64614797", "0.64614797", "0.64614797", "0.64255404", "0.6416642", "0.6373922", "0.63500303", "0....
0.0
-1
Devise resource name fix
def resource_name :user end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def resource_name\n devise_mapping.name\n end", "def resource_name\n \t\t:user\n \tend", "def resource_name\r\n :user\r\n end", "def resource_name\n\t\t:user\n\tend", "def resource_name\n :user\n end", "def resource_name\n :user\n end", "def resource_name\n :user\n end", "def ...
[ "0.81083786", "0.72499657", "0.704162", "0.70260257", "0.69209445", "0.68850565", "0.68850565", "0.68850565", "0.68850565", "0.68850565", "0.68850565", "0.68850565", "0.68850565", "0.68850565", "0.68850565", "0.68850565", "0.68850565", "0.68850565", "0.68850565", "0.68850565", ...
0.66663384
47
finds files in a path using the '' glob
def find_files(path) entries = Dir[path + "/*"] puts entries.size entries.select! { |entry| File.file?(entry) } entries end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def find_files dir = test_dir\n glob file_pattern(dir)\n end", "def files() = files_path.glob('**/*')", "def files_listing path\n cmd = \"find #{path} -type f \"\n cmd += \"-regextype posix-extended \"\n cmd += \"-regex \\\"#{@file_regexp}\\\" \" if @file_regexp\n ...
[ "0.8255938", "0.781236", "0.7790381", "0.7626271", "0.74537754", "0.74217826", "0.74116945", "0.7406977", "0.7329209", "0.73044753", "0.72983885", "0.7283478", "0.7249676", "0.72381914", "0.7223958", "0.71943605", "0.71595305", "0.7158012", "0.71461433", "0.7138742", "0.71366...
0.7358666
8
Sorts an array with [file, timestamp]
def sort_files(files) files.sort! { |x,y| x[1] <=> y[1] } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sort_files!; end", "def sort_array\n a = File.readlines(file_name)\n b = a.sort\n end", "def sorted_array\n total_views_per_file_path.sort { |a, b| b[1] <=> a[1] }\n end", "def extract_files(an_array)\n files = []\n an_array.reverse.each do |a_file|\n next if a_file.empty?\n next if a_...
[ "0.72473717", "0.72432774", "0.7189366", "0.6778739", "0.66728187", "0.66284335", "0.6463812", "0.6434579", "0.6381163", "0.6356909", "0.6354897", "0.6309172", "0.63007134", "0.6274207", "0.6258278", "0.62114775", "0.6199925", "0.61377597", "0.6055666", "0.60357606", "0.60079...
0.71553457
3
Two numbers in reverse order counter idx, add num ^ 10^counter to sum
def add_two_numbers(l1, l2) counter = 0 sum = 0 while !l1.nil? && !l2.nil? do sum += (l1.val + l2.val) * 10**counter counter += 1 l1 = l1.next l2 = l2.next end sum end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_two_numbers(l1, l2)\n (linked_list_to_array(l1).map(&:to_s).join.to_i + linked_list_to_array(l2).map(&:to_s).join.to_i).to_s.reverse.chars.map(&:to_i)\nend", "def two_sum(nums, target)\n results = []\n i = 1\n while i < nums.length\n diff = target - nums[i - 1]\n if nums[i..-1].include?(diff)\n...
[ "0.628652", "0.6169121", "0.6157533", "0.6155694", "0.6154818", "0.6143384", "0.6130651", "0.6128868", "0.6115622", "0.60769373", "0.60561734", "0.60195035", "0.600736", "0.5985168", "0.59500194", "0.5936116", "0.58864653", "0.5873499", "0.58658165", "0.5855285", "0.5846294",...
0.589667
16
Retrieves metadata for MP3s
def extract_metadata return unless audio? path = upload.queued_for_write[:original].path open_opts = { :encoding => 'utf-8' } Mp3Info.open(path, open_opts) do |mp3info| self.metadata = mp3info.tag end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def metadata\n puts \"Adding Metadata...\"\n doc = Nokogiri::HTML(open(\"http://www.last.fm/search?q=#{query}&type=track\"))\n url = doc.css(\"span.chartlist-ellipsis-wrap\").first.css(\"a.link-block-target\").first.attr('href')\n ch = url.gsub('/music/', \"\")\n artist, title = ch.split(\"/_/\")\n ...
[ "0.7496735", "0.74124306", "0.7365459", "0.7261131", "0.68965197", "0.6856877", "0.6796013", "0.664414", "0.66302603", "0.66209805", "0.64992034", "0.6491276", "0.6412064", "0.6161389", "0.6113114", "0.6105798", "0.60858166", "0.60754204", "0.60671127", "0.6064859", "0.605623...
0.7686719
0