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
PUT /admin/shirt_colors/1 PUT /admin/shirt_colors/1.json
def update @shirt_color = ShirtColor.find(params[:id]) respond_to do |format| if @shirt_color.update_attributes(params[:shirt_color]) format.html { redirect_to admins_shirt_colors_url, notice: 'Shirt color was successfully updated.' } format.json { head :no_content } else format.html { render action: "edit" } format.json { render json: @shirt_color.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n respond_to do |format|\n require 'rest-client'\n response = RestClient.put('localhost:3001/colores/'+@color.id.to_s, color_params.as_json, {:Authorization => 'admin irizREhyoG6Ejwr4AcjsQME9'})\n if response.code == 200\n @color = JSON.parse(response.body)\n\n format.htm...
[ "0.7418968", "0.66204554", "0.65830916", "0.6535938", "0.6498077", "0.64291906", "0.6320395", "0.63089687", "0.62797195", "0.62597305", "0.62443966", "0.6231157", "0.6229021", "0.6221083", "0.6210442", "0.62048304", "0.62031114", "0.62004775", "0.6181998", "0.614203", "0.6109...
0.73742723
1
DELETE /admin/shirt_colors/1 DELETE /admin/shirt_colors/1.json
def destroy @shirt_color = ShirtColor.find(params[:id]) @shirt_color.destroy respond_to do |format| format.html { redirect_to admins_shirt_colors_url } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n \n respond_to do |format|\n RestClient.delete 'localhost:3001/colores/'+@color.id.to_s, {:Authorization => 'admin irizREhyoG6Ejwr4AcjsQME9'}\n format.html { redirect_to colors_url, notice: \"Color was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end"...
[ "0.7895721", "0.7253408", "0.72148347", "0.7204698", "0.7060551", "0.7060551", "0.7053655", "0.7036212", "0.69999903", "0.6959335", "0.69069874", "0.6879896", "0.6866158", "0.6802698", "0.67977387", "0.6795793", "0.6755527", "0.67211616", "0.6720177", "0.6711934", "0.6702769"...
0.78010786
1
before_action :new, :check_if_student GET /books GET /books.json
def index check_if_student @books = Book.all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @student = Student.find(params[:student_id])\n @student_book = @student.student_books.new(student_book_params)\n authorize! :create, @student_book\n\n respond_to do |format|\n if @student.save\n format.html { redirect_to student_student_books_path(@student), notice: 'Student bo...
[ "0.68464494", "0.65687937", "0.6554601", "0.6502732", "0.6370361", "0.6274324", "0.62663233", "0.61579055", "0.6149347", "0.61476344", "0.61146224", "0.61006683", "0.60970044", "0.60884786", "0.60394114", "0.6039122", "0.6036817", "0.60239", "0.60199237", "0.59859014", "0.597...
0.701106
0
GET /books/1 GET /books/1.json
def show @library = Library.find(Book.find(params[:id]).library_id) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n base_url = 'https://www.googleapis.com/books/v1/volumes?q=fiction&maxResults=20'\n and_key = '&key='\n key = ENV['GOOGLE_BOOKS_API_KEY'] \n googleurl = base_url + and_key + key\n\n response = RestClient.get(googleurl)\n @books = JSON.parse(response)\n\n respond_to do |format|\n format.html\n ...
[ "0.7638282", "0.7442742", "0.7441457", "0.73351127", "0.73137444", "0.7297435", "0.72266304", "0.72266304", "0.7222271", "0.72091204", "0.72091204", "0.72091204", "0.72091204", "0.72091204", "0.72091204", "0.72091204", "0.72091204", "0.72091204", "0.71578825", "0.71435905", "...
0.0
-1
POST /books POST /books.json
def create @book = Book.new(book_params) respond_to do |format| if @book.save format.html { redirect_to @book, notice: 'Book was successfully created.' } format.json { render :show, status: :created, location: @book } else format.html { render :new } format.json { render json: @book.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @book = Book.new(book_params)\n\n if @book.save\n render json: @book, status: :created, location: @book\n else\n render json: @book.errors, status: :unprocessable_entity\n end\n end", "def create\n\n @book = Book.new(params[:book])\n\n respond_to do |format|\n if @b...
[ "0.7260979", "0.7052168", "0.6990385", "0.69234765", "0.6920176", "0.68718755", "0.68718755", "0.68718755", "0.68718755", "0.68718755", "0.685515", "0.6847371", "0.67841905", "0.6777309", "0.67586553", "0.67586553", "0.6756703", "0.6698212", "0.66888076", "0.6679647", "0.6679...
0.67478836
26
PATCH/PUT /books/1 PATCH/PUT /books/1.json
def update respond_to do |format| if @book.update(book_params) format.html { redirect_to @book, notice: 'Book was successfully updated.' } format.json { render :show, status: :ok, location: @book } else format.html { render :edit } format.json { render json: @book.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @book = Book.find(params[:id])\n\n respond_to do |format|\n if @book.update_attributes(params[:book])\n \n format.json { render json: @book, status: :created, location: @book }\n else\n \n format.json { render json: @book.errors, status: :unprocessable_entity }\n...
[ "0.7048773", "0.688817", "0.68527925", "0.68271405", "0.6824262", "0.6821144", "0.6802083", "0.6802083", "0.6802083", "0.6802083", "0.6802083", "0.6802083", "0.6802083", "0.6802083", "0.6802083", "0.6800069", "0.67871505", "0.67303824", "0.67264384", "0.6724246", "0.67084", ...
0.65435743
47
DELETE /books/1 DELETE /books/1.json
def destroy @book.destroy respond_to do |format| format.html { redirect_to books_url, notice: 'Book was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @book = Book.find(params[:id])\n @book.destroy\n \n respond_to do |format|\n format.html { redirect_to books_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @book = Book.find(params[:id])\n @book.destroy\n\n respond_to do |format|\n form...
[ "0.74842304", "0.74440986", "0.74440986", "0.7437947", "0.74340576", "0.74340576", "0.74340576", "0.74340576", "0.74340576", "0.74340576", "0.74340576", "0.74340576", "0.74340576", "0.74340576", "0.74340576", "0.74340576", "0.7420059", "0.7401971", "0.7401971", "0.7401971", "...
0.714886
58
Use callbacks to share common setup or constraints between actions.
def set_book @book = Book.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.6163443", "0.604317", "0.5943409", "0.59143174", "0.5887026", "0.58335453", "0.57738566", "0.5701527", "0.5701527", "0.56534666", "0.5618685", "0.54237175", "0.5407991", "0.5407991", "0.5407991", "0.5394463", "0.5376582", "0.5355932", "0.53376216", "0.5337122", "0.5329516"...
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def book_params params.require(:book).permit(:title,:isbn,:author,:language,:published,:edition,:cover_image,:subject, :library_id,:summary,:quantity,:special_collection) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strong_params\n params.require(:user).permit(param_whitelist)\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def allow_params_authentication!; end", "def allowed_params\n ALLOWED_PARAMS\n end", "def default_param_whitelist\n [\"mode\"]\n...
[ "0.69792545", "0.6781151", "0.67419964", "0.674013", "0.6734356", "0.6591046", "0.6502396", "0.6496313", "0.6480641", "0.6477825", "0.64565", "0.6438387", "0.63791263", "0.63740575", "0.6364131", "0.63192815", "0.62991166", "0.62978333", "0.6292148", "0.6290449", "0.6290076",...
0.0
-1
Use callbacks to share common setup or constraints between actions.
def set_interest @interest = Interest.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_...
[ "0.6163163", "0.6045976", "0.5946146", "0.591683", "0.5890051", "0.58349305", "0.5776858", "0.5703237", "0.5703237", "0.5652805", "0.5621621", "0.54210985", "0.5411113", "0.5411113", "0.5411113", "0.5391541", "0.53794575", "0.5357573", "0.53402257", "0.53394014", "0.53321576"...
0.0
-1
Only allow a trusted parameter "white list" through.
def create_interest_params params.permit(:yelp_id, :interests => [:min_seats, :max_seats, :datetime]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def allowed_params\n ALLOWED_PARAMS\n end", "def expected_permitted_parameter_names; end", "def param_whitelist\n [:role, :title]\n end", "def default_param_whitelist\n [\"mode\"]\n end", "def permitir_parametros\n \t\tparams.permit!\n \tend", "def permitted_params\n []\n end", ...
[ "0.7120904", "0.70538116", "0.69469863", "0.6901261", "0.67348766", "0.6717708", "0.66874576", "0.6676195", "0.66601187", "0.65563625", "0.6525127", "0.64565873", "0.64494514", "0.644928", "0.64452374", "0.6433947", "0.6412815", "0.6412815", "0.6391939", "0.63792473", "0.6379...
0.0
-1
Good to know: Ruby's array sort method more or less uses quick sort. Time complexity O(nlog(n)) Space complexity ?
def quick_sort(array) # Base case return array if array.length <= 1 left = [] right = [] # Uses random to select a pivot in case the array is already sorted # to avoid running in quadriatic time pivot_idx = rand(array.length) pivot = array[pivot_idx] array.each_with_index do |n, i| next if i == pivot_idx # If n < pivot, put it in the left array, else put it in the right array n < pivot ? left << n : right << n end # Concats the sorted left array with the pivot and the sorted right array quick_sort(left).concat([pivot]).concat(quick_sort(right)) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def quick_sort(array)\nend", "def quick_sort(array)\n return array if array.size <= 1\n pivot = array.shift\n left = array.select { |el| el < pivot }\n right = array.select { |el| el >= pivot }\n\n quick_sort(left) + [pivot] + quick_sort(right)\nend", "def quick_sort(arr, low = 0, high = arr.size - 1)\n ...
[ "0.83448756", "0.7830855", "0.78072894", "0.77814233", "0.77813566", "0.7762061", "0.7749257", "0.7737508", "0.77335906", "0.77187526", "0.7673464", "0.7667501", "0.7650058", "0.7632176", "0.7603435", "0.7585873", "0.7570686", "0.7564733", "0.7559527", "0.7536383", "0.7533662...
0.75749403
16
GET /brevis GET /brevis.json
def index @brevi = Brevi.new @brevis = Brevi.limit(100).order(clicks: :desc) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @brags = Brag.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @brags }\n end\n end", "def show\n @verbo = Verbo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @verbo...
[ "0.6640117", "0.65098894", "0.64953256", "0.6468548", "0.6444701", "0.6413933", "0.6412369", "0.6403215", "0.63330984", "0.63242215", "0.6321689", "0.6319305", "0.63037753", "0.62918055", "0.62918055", "0.6269501", "0.62681985", "0.6258365", "0.6253375", "0.6251128", "0.62507...
0.0
-1
GET /brevis/1 GET /brevis/1.json
def show @brevi = Brevi.find_by_slug params[:slug] if @brevi @brevi.increment! :clicks redirect_to @brevi.original_url else redirect_to brevis_url, notice: 'There was an error redirecting.' end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @brags = Brag.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @brags }\n end\n end", "def show\n @baton = Baton.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @baton...
[ "0.6656918", "0.65922934", "0.6580305", "0.6530296", "0.649651", "0.6450551", "0.64009273", "0.6374918", "0.63541543", "0.633254", "0.633223", "0.63307136", "0.6313404", "0.630367", "0.63033855", "0.62830514", "0.6281329", "0.6280386", "0.627854", "0.6275999", "0.62746304", ...
0.0
-1
POST /brevis POST /brevis.json
def create @brevi = Brevi.new(brevi_params) respond_to do |format| if @brevi.save format.html { redirect_to brevis_url, notice: "Your short link is <a href='#{root_url}#{@brevi.slug}'>#{root_url}#{@brevi.slug}</a>"} else format.html { render :new } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @my_visa = MyVisa.new(my_visa_params)\n\n respond_to do |format|\n if @my_visa.save\n format.html { redirect_to @my_visa, notice: 'My visa was successfully created.' }\n format.json { render :show, status: :created, location: @my_visa }\n else\n format.html { rende...
[ "0.63501275", "0.61068016", "0.60103196", "0.6000841", "0.5935757", "0.5807656", "0.5790341", "0.5749002", "0.5742203", "0.5741611", "0.5736204", "0.57244253", "0.5722468", "0.5719426", "0.56738275", "0.56738275", "0.56736964", "0.567326", "0.5643534", "0.5642834", "0.5639025...
0.0
-1
Use callbacks to share common setup or constraints between actions.
def set_brevi @brevi = Brevi.find_by_slug(params[:slug]) 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.6163443", "0.604317", "0.5943409", "0.59143174", "0.5887026", "0.58335453", "0.57738566", "0.5701527", "0.5701527", "0.56534666", "0.5618685", "0.54237175", "0.5407991", "0.5407991", "0.5407991", "0.5394463", "0.5376582", "0.5355932", "0.53376216", "0.5337122", "0.5329516"...
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def brevi_params params.require(:brevi).permit(:original_url, :slug, :clicks) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strong_params\n params.require(:user).permit(param_whitelist)\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def allow_params_authentication!; end", "def allowed_params\n ALLOWED_PARAMS\n end", "def default_param_whitelist\n [\"mode\"]\n...
[ "0.69792545", "0.6781151", "0.67419964", "0.674013", "0.6734356", "0.6591046", "0.6502396", "0.6496313", "0.6480641", "0.6477825", "0.64565", "0.6438387", "0.63791263", "0.63740575", "0.6364131", "0.63192815", "0.62991166", "0.62978333", "0.6292148", "0.6290449", "0.6290076",...
0.0
-1
TODO use multithread uncompressing tool
def perform @extracted_files = Array.new @files_to_extract.each do |f| @extracted_files.push File.basename(@filename, '.tbz') + '/' + f end extract = extract_command(@basename, @extracted_files.join(' ')) result = system "cd #{@dirname} && #{extract}" if result _extracted_files = @extracted_files.map{|f| File.join(@dirname, f)} @file_entry = FileEntry.new(@filename, Hash[@files_to_extract.zip(_extracted_files)]) FileUtils.remove_file(@filename, true) unless keep_tbz_after_extract? else raise "Unable to extract files '#{@files_to_extract.join(' ')}' from #{@filename}" end @file_entry end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def decompressor; end", "def compressor; end", "def compress!; end", "def decompress(data); end", "def compression; end", "def compress(data); end", "def uncompress_files(oConfig)\n\n #Just uncompress the files now directly...\n Dir.glob(oConfig.data_dir + \"/*.gz\") do |file_name|\n\n #Th...
[ "0.7671836", "0.6596917", "0.6560826", "0.65423965", "0.6363955", "0.6312613", "0.6308213", "0.5971433", "0.593914", "0.58782595", "0.58758765", "0.58283037", "0.5741421", "0.57403594", "0.57348984", "0.57114273", "0.5708162", "0.5707759", "0.5696128", "0.5696128", "0.5695615...
0.0
-1
Only allow a trusted parameter "white list" through.
def user_params params.require(:user).permit(:name, :email, :password, :password_confirmation) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def allowed_params\n ALLOWED_PARAMS\n end", "def expected_permitted_parameter_names; end", "def param_whitelist\n [:role, :title]\n end", "def default_param_whitelist\n [\"mode\"]\n end", "def permitir_parametros\n \t\tparams.permit!\n \tend", "def permitted_params\n []\n end", ...
[ "0.7120904", "0.70538116", "0.69469863", "0.6901261", "0.67348766", "0.6717708", "0.66874576", "0.6676195", "0.66601187", "0.65563625", "0.6525127", "0.64565873", "0.64494514", "0.644928", "0.64452374", "0.6433947", "0.6412815", "0.6412815", "0.6391939", "0.63792473", "0.6379...
0.0
-1
Get a SoftLayer server.
def get(identifier) return nil if identifier.nil? || identifier == "" response = service.get_vm(identifier) bare_metal = false if response.status == 404 # we didn't find it as a VM, look for a BMC server response = service.get_bare_metal_server(identifier) bare_metal = true end data = response.body data['bare_metal'] = bare_metal new.merge_attributes(data) rescue Excon::Errors::NotFound nil end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def server\n servers[0]\n end", "def get_server(id)\n OpenStack::Compute::Server.new(self,id)\n end", "def get_server(id)\n OpenStack::Compute::Server.new(self,id)\n end", "def server\n\t\treturn @server ||= self.create_server\n\tend", "def get_server(id)\n CloudServers::Server...
[ "0.72764385", "0.726068", "0.726068", "0.71155316", "0.7094219", "0.70935243", "0.7043799", "0.6905586", "0.6757211", "0.6651028", "0.659919", "0.65268624", "0.65133137", "0.6488324", "0.6394069", "0.6328231", "0.6255257", "0.62434775", "0.61879516", "0.61154723", "0.60722744...
0.0
-1
Get a SoftLayer server by ip.
def get_by_ip(ip) return nil if ip.blank? response = service.get_virtual_guest_by_ip(ip) bare_metal = false if response.status == 404 # we didn't find it as a VM, look for a BMC server response = service.get_bare_metal_server_by_ip(ip) bare_metal = true end data = response.body data['bare_metal'] = bare_metal new.merge_attributes(data) rescue Excon::Errors::NotFound nil end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_server( host, port )\n server_list = servers\n server_list.select{ |s| s[:addr] == host and s[:port] == port.to_i}[0] or raise ArgumentError.new(\"Could not find #{host}:#{port} in #{server_list.inspect}\")\n end", "def get_server(id)\n OpenStack::Compute::Server.new(self,id)\n end", "de...
[ "0.67086923", "0.65305895", "0.65305895", "0.630614", "0.6266668", "0.61623293", "0.603519", "0.60301644", "0.5928978", "0.591991", "0.58517724", "0.5834359", "0.5834293", "0.5831503", "0.5737879", "0.57264936", "0.5725896", "0.57012063", "0.5679588", "0.56718856", "0.5648056...
0.64933115
3
done == success or failure
def fetch_done(task) @fetch_worker_queue.remove_from_input(task) @current_connections.delete(task.ip) if task.failure @node_manager.log_error task.failure, task.http_url.to_s.inspect else @node_manager.log :success, task.http_url.to_s.inspect end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def done?; true end", "def done?; end", "def done; end", "def do_success; end", "def done\n end", "def done\n end", "def done\r\n @done = true\r\n end", "def done\n @done = true\n end", "def done!\n @done = true\n end", "def finished?\n failed? or successful? or skipped...
[ "0.8262399", "0.79952", "0.78558743", "0.7292884", "0.7274515", "0.7274515", "0.7247886", "0.724128", "0.72387046", "0.7153625", "0.70842814", "0.70842814", "0.7056095", "0.7053715", "0.7041289", "0.7020785", "0.70106906", "0.69784766", "0.69784766", "0.69784766", "0.69784766...
0.0
-1
Returns the next HttpUrl that is neither invalid nor already fetched. If there are no more URLs, it returns +nil+.
def get_next_url while true unless url = @node_manager.dequeue_url # there are currently no further URLs in the queue return nil end unless http_url = HttpUrl.parse(url) @node_manager.log_error :invalid_url, url.inspect next end if @node_manager.has_file?(http_url.to_filename) @node_manager.log :skip_url__already_fetched, url.inspect next end return http_url end # while end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_next_url\n while true\n unless url = dequeue_url()\n # there are currently no further URLs in the queue\n return nil\n end\n\n unless http_url = HttpUrl.parse(url)\n log_error :invalid_url, url.inspect \n next\n end\n\n if has_file?(http_url.to_filena...
[ "0.8423655", "0.6022834", "0.59125125", "0.58111787", "0.577472", "0.577472", "0.57190794", "0.5705838", "0.5705838", "0.5705838", "0.5705838", "0.5698161", "0.56560874", "0.5654704", "0.5654704", "0.5654704", "0.5639774", "0.5629583", "0.5570565", "0.5570565", "0.55143726", ...
0.82380056
1
Find the group with the most actions and return an int h where: h = (max_actions + pad) factor the pad represents the top two header lines in the rendered post it the factor represents the line height of the action list
def compute_height(pad = 2, factor = 13) (max_actions + pad) * factor end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def max_action_length\n @max_action_length ||= actions.inject(0){|memo, a| [memo, a.to_s.length].max}\n end", "def max_action_length\n @max_action_length ||= actions.inject(0){|memo, a| [memo, a.to_s.length].max}\n end", "def max_action_length\n @max_action_length ||= actions.inject(0){|...
[ "0.5806632", "0.5806632", "0.57885504", "0.5447509", "0.5403133", "0.5402194", "0.51390976", "0.5093184", "0.5090375", "0.5083449", "0.508129", "0.50665444", "0.50417334", "0.5037443", "0.5007906", "0.500024", "0.4975096", "0.49619475", "0.49557513", "0.49306992", "0.49247235...
0.62843657
0
Make the groups with the least lines of code green and gradually go to red return a string that will be parameters to the css rgb rule
def compute_color(loc, resolution = 50) min_loc = total_loc grouping_sorted_by_total_loc.first.last max_loc = total_loc grouping_sorted_by_total_loc.reverse.first.last range = max_loc - min_loc progress = loc - min_loc percent = progress.to_f / range.to_f * 100.0 gradient = ColorFun::Gradient.new "00ff00", "FF9100", "ff0000" # green, orange, red gradient.resolution = resolution rgb = gradient.at [percent, resolution].min [rgb.red, rgb.green, rgb.blue] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def red\n colorize(31)\n end", "def get_green_to_red_scala n\n colors = []\n r = 0; g = 150; b = 0\n max = 255\n\n #se empieza en un g oscuro en 150 y se aclarece añadiendo g hasta 255\n #ni = numero iteraciones\n ni = (1*n/3)\n for i in 1..(1*n/3.to_f).floor\n g = 150 + (i*(max - 1...
[ "0.66967916", "0.6665774", "0.65976214", "0.64546555", "0.6360181", "0.62740016", "0.626505", "0.62432027", "0.62268454", "0.6225492", "0.6225492", "0.6225492", "0.6225492", "0.6225492", "0.6225492", "0.6221012", "0.62087804", "0.61889887", "0.61612266", "0.6156814", "0.61341...
0.0
-1
wraps xml in version header
def wrap_in_version(xml_rq) if QBWC.api == :qbpos %Q( <?qbposxml version="#{QBWC.min_version}"?> ) + xml_rq else %Q( <?qbxml version="#{QBWC.min_version}"?> ) + xml_rq end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def xmldecl(version, encoding, standalone); end", "def xmldecl(version, encoding, standalone); end", "def xmldecl(version, encoding, standalone); end", "def xmldecl(version, encoding, standalone); end", "def add_version(xml)\n\t\t\t\txml.Version{\n\t\t\t\t\txml.ServiceId service[:id]\n\t\t\t\t\txml.Major ...
[ "0.6723737", "0.6723737", "0.6723737", "0.6723737", "0.6659281", "0.664731", "0.66338986", "0.65876263", "0.6467459", "0.6310855", "0.61711985", "0.61427736", "0.61385816", "0.6134556", "0.60396314", "0.6014451", "0.5994631", "0.5983378", "0.58720636", "0.5855758", "0.5851338...
0.66784006
4
Prints the main menu only
def show_main_menu puts "Welcome to the app. What's next?" puts " new - Create a new contact" puts " list - List all contacts" puts " find - Find by name" puts " quit - Exit Application" print "> " end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def main()\n main_menu(SHOW_HEADER);\n end", "def display_main_menu(clear_screen = false)\n clear if clear_screen\n title_header(TITLES[:main_menu],\"_\",\"-\",false)\n\n Api.main_topics.each_with_index do |type, i|\n puts \"#{(\" \" * (PROFILE_SIDE / 2))}#...
[ "0.78009224", "0.7689885", "0.7643563", "0.76135117", "0.7599054", "0.7596337", "0.75843924", "0.7488118", "0.74608237", "0.74579257", "0.7409105", "0.7360588", "0.7335936", "0.7329466", "0.7329066", "0.73279434", "0.72759974", "0.72679996", "0.7208426", "0.71990603", "0.7182...
0.7509519
7
def show_contact Contact. end
def get_contact_name puts "Please enter the contact first name:" gets.chomp end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def contact\n end", "def contact\n end", "def contact\n end", "def contact\n end", "def contact\n end", "def contact\n end", "def contact\n end", "def contact\n end", "def contact\n end", "def contact\n end", "def contact\n end", "def contact\n end", "def contact\n end", "def...
[ "0.81235385", "0.81235385", "0.81235385", "0.81235385", "0.81235385", "0.81235385", "0.81235385", "0.81235385", "0.81235385", "0.81235385", "0.81235385", "0.81235385", "0.81235385", "0.81235385", "0.80569017", "0.80569017", "0.79665256", "0.79496145", "0.7909112", "0.78851795",...
0.0
-1
NOTE: For ref Manual way of authenticate request
def authenticate_manual api_key = request.headers['X-Api-Key'] @app = App.where(api_key: api_key).first if api_key unless @app head status: :unauthorized return false end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def authenticate\n end", "def authenticate(request)\n\n end", "def authenticate!\n # Do nothing yet\n end", "def http_auth_login\n # FIXME: Implement\n end", "def authenticate_requester!(request)\n end", "def authenticate!\n error!(\"401 Unauthori...
[ "0.8274238", "0.82676715", "0.7937465", "0.7796201", "0.77778196", "0.77039933", "0.77006316", "0.77006316", "0.76863253", "0.76783955", "0.76482433", "0.76136935", "0.7514551", "0.7502928", "0.74920034", "0.7484768", "0.74815667", "0.7455801", "0.74480003", "0.7414616", "0.7...
0.0
-1
Check request per min You can add field to user table request per min or define constant. Here I am just passsing some random value
def validate_rpm if ApiRpmStore.threshold?(@app.id, @app.api_rpm) # 10 request per min render json: { help: 'http://prediction.io' }, status: :too_many_requests return false end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def rate_limit\n new_request=RequestLimit.new({ip:request.remote_ip.to_s})\n\n # create a new record of RequestLimit to keep count of the incomming requests\n new_request.save\n\n # Check if current request exceeds max limit specified\n\n if RequestLimit.all.size > RequestLimit::MAX_LIMIT\n\n #...
[ "0.5928781", "0.58438295", "0.58438295", "0.5758866", "0.5702651", "0.5686577", "0.56617475", "0.56564784", "0.5653852", "0.5633291", "0.5619237", "0.5602089", "0.5599445", "0.55829924", "0.5573553", "0.5573553", "0.5554576", "0.55529034", "0.55267805", "0.5512437", "0.549667...
0.52840704
42
Write a program that solicits 6 numbers from the user, then prints a message that describes whether or not the 6th number appears amongs the first 5 numbers.
def prompt(msg) puts ">> #{msg}" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def number_problem()\n\n\tcount = 10\n\twhile count > 0\n\t\tputs \"you have #{count} times you can do this!\"\n\n\t\tputs \"Please enter a number that is a multiple of 3 or 5, 1-100 for a phrase or word back!\"\n\t\tnumber = gets.chomp\n\n\t\tmult_of_three = [\"3\", \"6\", \"9\", \"12\", \"18\", \"21\", \"24\", \...
[ "0.6843137", "0.682451", "0.6787685", "0.67030257", "0.6488398", "0.64438015", "0.6402141", "0.63950896", "0.6370546", "0.6367428", "0.63459754", "0.6334254", "0.63275945", "0.6324411", "0.63181484", "0.63065875", "0.62793624", "0.62619233", "0.6256921", "0.6234388", "0.62297...
0.0
-1
removes cards from deck and returns them
def take end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def remove_card\n cards.shift\n return cards\n end", "def remove_card_from_deck (card)\n\t\t@deck -= [card]\n\tend", "def discard\n\n # organize hand into sorted array of cards\n #### METHOD\n\n puts \"here is your hand #{hand}\"\n\n puts 'what cards? you can only discard 3.'\n\n #the pla...
[ "0.8165804", "0.76598626", "0.76206326", "0.7613722", "0.7583243", "0.75755656", "0.75327635", "0.7517896", "0.7486409", "0.7441576", "0.7386255", "0.73485655", "0.7311808", "0.73085326", "0.7252754", "0.7192282", "0.718419", "0.71690774", "0.7148452", "0.71413684", "0.714093...
0.0
-1
method to find edge from 2 vertices
def findEdge(vertex1, vertex2) visualedges = @visualGraph.visual_edges visualedges.each do |edge| if edge.v1.id == vertex1 && edge.v2.id == vertex2 # edge from vertex1 to vertex2 return edge elsif edge.v2.id == vertex1 && edge.v1.id == vertex2 # edge from vertex2 to vertex1 return edge end end return nil end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def has_edge?(vertex1, vertex2)\n\tend", "def find_edge(node_1, node_2)\n @edges[node_1][node_2] if @edges[node_1]\n end", "def find_edge(one, two)\n edges.find do |e|\n (e.one == one && e.two == two) || (e.two == one && e.one == two)\n end\n end", "def end_vertice...
[ "0.7394766", "0.7323445", "0.73078275", "0.72541255", "0.7220407", "0.70989025", "0.70989025", "0.6944398", "0.6875293", "0.6861289", "0.68169624", "0.6740854", "0.6740854", "0.6718185", "0.66641533", "0.66641533", "0.65968657", "0.65937185", "0.6589447", "0.65610266", "0.654...
0.79551625
0
Method to add an item to a list input: list, item name, and optional quantity steps: define method, add item and quanity to specific list output: the new list
def add_item(list,new_item,item_count) list[new_item] = item_count end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_item(list, item, quantity=1)\r\n# input: item name and optional quantity\r\n# steps: \r\n # Use shopping list as input\r\n # Use the item to be added as 2nd input\r\n # Use the item quantity as a 3rd input (look up whether optional input is possible)\r\n # Add the item and quantity to the shopping list...
[ "0.795133", "0.790262", "0.78300786", "0.7814698", "0.77794486", "0.7779328", "0.7779328", "0.77266306", "0.77266306", "0.7657119", "0.7603219", "0.76005363", "0.75877446", "0.7581513", "0.7580342", "0.74991405", "0.74892855", "0.74843735", "0.7478123", "0.7450399", "0.744880...
0.0
-1
Method to remove an item from the list input: get the hash/list name and the key to delete steps: then delete the key from the hash output: updated list, minus what we deleted
def delete_item(list,item) list.delete(item) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def remove_item(list_name, item)\r\n# input: list, item name\r\n# steps: delete item name and value from hash\r\n list_name.delete(item)\r\n# output: updated hash with item removed\r\np list_name\r\nend", "def remove_item(input_hash, item)\n# input: list, item name, and optional quantity\n# steps: use input ite...
[ "0.8384225", "0.8319248", "0.81510663", "0.8003024", "0.78639805", "0.7797896", "0.77775574", "0.77769065", "0.7773278", "0.7648284", "0.76454604", "0.7574883", "0.7484497", "0.7474068", "0.7469355", "0.74413306", "0.74376804", "0.74181265", "0.73635554", "0.73521113", "0.734...
0.0
-1
Method to update the quantity of an item input: get the hash/list name, the key, and the upated quantity to change steps: update the quanityt number output: updated list with the new quantity
def update_quantity(list,item,item_count) list[item] = item_count end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_quantity(list_name, item, value)\r\n# input: list, item name, new quantity\r\n# steps: find item in the hash and change quantity to new quantity\r\n list_name[item] = value\r\n# output: updated hash with new value for item key\r\n p list_name\r\nend", "def update_quanity(list, item, quantity)\r\n# i...
[ "0.82924277", "0.8264403", "0.8118773", "0.80738354", "0.8057201", "0.80567276", "0.80567276", "0.79823816", "0.79579365", "0.79312485", "0.79053307", "0.7901778", "0.7888846", "0.78810966", "0.785935", "0.78493524", "0.7837322", "0.7822981", "0.78197706", "0.7810973", "0.780...
0.7675452
36
Method to print a list and make it look pretty input: the list name steps: iterate through the list with a puts statement and interpelation output: a series of strings expressing what is contained in the list
def print_list(list) list.each do |item,count| puts "#{item}: #{count}" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def pretty_in_print(list)\n puts \"---------------------------------------\"\n puts \"These are the items we are gonna buy\"\n list.each {|item, qty| puts \"#{qty} pieces of #{item}\" }\nend", "def pretty_list(list)\n\tlist.each do |item, quantity|\n\t\tputs \"There are #{quantity} #{item} on the grocer...
[ "0.81935126", "0.79859966", "0.79217684", "0.7825385", "0.7808363", "0.772888", "0.77274865", "0.76622444", "0.7649025", "0.7649025", "0.7645689", "0.7641062", "0.7585162", "0.75796205", "0.7570455", "0.7515595", "0.7509122", "0.74346054", "0.7405648", "0.73806477", "0.737380...
0.7038516
61
def artist_is_current_artist unless current_artist.friendly_id == params[:artist_id] flash[:notice] = "You may only edit your own content." redirect_to artist_albums_path end end
def album_params params.require(:album).permit(:id, :artist_id, :project_id, :album_id, :title, :release_date, :cover_art, :remove_cover_art, :genre, :genre_list, :tag_list) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def require_artist\n unless logged_in? && (current_user.artist? || current_user.administrator?)\n flash[:warning] = \"Only artists can access the #{controller_name} controller\"\n redirect_to controller: \"home\", action: \"index\"\n end\n end", "def valid_artist_name?\n\t\t\tif params[:artist]....
[ "0.7847011", "0.67857", "0.67736536", "0.66327095", "0.6418005", "0.639104", "0.6390477", "0.6369089", "0.629358", "0.6285507", "0.6281747", "0.62524927", "0.6245714", "0.6233448", "0.61937875", "0.6088319", "0.6084119", "0.60833615", "0.6070932", "0.60606337", "0.605855", ...
0.0
-1
Stretch the children layouts to fill the gaps, remove redundant spaces inside the parent layout
def stretch_children_layouts(parent_template, parent_width, parent_height, lines) total_height = 0 lines.each_with_index do |line, line_index| desired_height = if line_index == lines.length - 1 parent_height - total_height else line.map { |_child_template, _child_width, child_height, _x, _y| child_height }.max end total_width = 0 line.map!.with_index do |(child_template, child_width, child_height, x, y), index| child_height = desired_height if parent_template.fill_height child_width = parent_width - total_width if parent_template.fill_width && index == line.length - 1 total_width += child_width [child_template, child_width, child_height, x, y] end total_height += desired_height end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def layout()\n layout_children()\n end", "def do_layout\n _init_layout\n r = @top_margin\n c = @left_margin\n #\n # determine fixed widths and how much is left to share with others,\n # and how many variable width components there are.\n ht = 0 # accumulate fixed height\n fi...
[ "0.59840864", "0.58018905", "0.5796675", "0.5727341", "0.564793", "0.5540127", "0.5504066", "0.5488912", "0.5418825", "0.5327344", "0.5260132", "0.5251093", "0.5246008", "0.51668864", "0.51428837", "0.51121426", "0.5075789", "0.5033938", "0.49686903", "0.49675438", "0.4962577...
0.703636
0
Use callbacks to share common setup or constraints between actions.
def set_reservation @reservation = Reservation.find(params[:reservation_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.6163443", "0.604317", "0.5943409", "0.59143174", "0.5887026", "0.58335453", "0.57738566", "0.5701527", "0.5701527", "0.56534666", "0.5618685", "0.54237175", "0.5407991", "0.5407991", "0.5407991", "0.5394463", "0.5376582", "0.5355932", "0.53376216", "0.5337122", "0.5329516"...
0.0
-1
Only allow a trusted parameter "white list" through.
def reservation_params params.require(:reservation).permit(:start_date, :end_date, :paid, :equipment_id) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def allowed_params\n ALLOWED_PARAMS\n end", "def expected_permitted_parameter_names; end", "def param_whitelist\n [:role, :title]\n end", "def default_param_whitelist\n [\"mode\"]\n end", "def permitir_parametros\n \t\tparams.permit!\n \tend", "def permitted_params\n []\n end", ...
[ "0.7121987", "0.70541996", "0.69483954", "0.6902367", "0.6733912", "0.6717838", "0.6687021", "0.6676254", "0.66612333", "0.6555296", "0.6527056", "0.6456324", "0.6450841", "0.6450127", "0.6447226", "0.6434961", "0.64121825", "0.64121825", "0.63913447", "0.63804525", "0.638045...
0.0
-1
validates :description, :browseable, :saleable, :category, presence: true
def as_json(options=nil) super(include: [:size, :packs, :stocks]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def validate\n super\n errors.add(:name, \"can't be empty\") if name.blank?\n errors.add(:category_id, \"can't be empty\") if category_id.blank?\n errors.add(:price, \"can't be empty\") if price.blank?\n end", "def validate\n validates_presence([:title, :body])\n end", "def validate \n#\tfirst...
[ "0.7373321", "0.66990507", "0.633484", "0.63333195", "0.63276315", "0.6313059", "0.6274657", "0.62730753", "0.6257874", "0.6254055", "0.62496096", "0.6218312", "0.62084687", "0.615548", "0.61207247", "0.6120579", "0.6118149", "0.6026975", "0.6026975", "0.6014819", "0.59984887...
0.0
-1
GET /sections or /sections.json
def index @menu = Menu.find(params[:menu_id]) @sections = @menu.sections render json: SectionSerializer.new(@sections) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @sections = params[:path].nil? ? Section.all : Section.where(path: params[:path])\n\n respond_to do |format|\n format.html { render html: @sections }\n format.json { render json: @sections }\n end\n end", "def index\n @sections = Section.all\n\n respond_to do |format|\n ...
[ "0.7767557", "0.72896004", "0.7129679", "0.7129679", "0.6987889", "0.68669957", "0.68669957", "0.68669957", "0.68408567", "0.6811863", "0.6730119", "0.67064166", "0.66492844", "0.66475123", "0.6639673", "0.6639673", "0.6639673", "0.6639673", "0.6639673", "0.6639673", "0.66396...
0.67724836
10
GET /sections/1 or /sections/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @sections = params[:path].nil? ? Section.all : Section.where(path: params[:path])\n\n respond_to do |format|\n format.html { render html: @sections }\n format.json { render json: @sections }\n end\n end", "def index\n @sections = Section.all\n\n respond_to do |format|\n ...
[ "0.75783086", "0.71649253", "0.7023344", "0.7023344", "0.7023344", "0.69710636", "0.6860085", "0.6860085", "0.68000746", "0.667418", "0.6659199", "0.6655881", "0.6627127", "0.65668356", "0.6509227", "0.65008754", "0.6495838", "0.6495838", "0.6495838", "0.6495838", "0.6495838"...
0.0
-1
POST /sections or /sections.json
def create @section = Section.new(section_params) if @section.save render json: SectionSerializer.new(@section) else render json: @section.errors, status: :unprocessable_entity end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @section = Section.new(section_params)\n\n if @section.save\n render :show, status: :created, location: @section\n else\n render json: @section.errors, status: :unprocessable_entity\n end\n end", "def create\n @section = Section.new(params[:section])\n @section.page = @p...
[ "0.67786705", "0.659407", "0.6583568", "0.6568496", "0.6561841", "0.6520435", "0.6520435", "0.65132475", "0.6494207", "0.64769095", "0.64499754", "0.64323574", "0.64323574", "0.64323574", "0.64323574", "0.64296603", "0.6390424", "0.6380877", "0.6375676", "0.63738686", "0.6359...
0.6856197
0
PATCH/PUT /sections/1 or /sections/1.json
def update if @section.update(section_params) render json: SectionSerializer.new(@section) else render json: @menu.errors, status: :unprocessable_entity end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @section = Section.find(params[:id])\n\n respond_to do |format|\n if @section.update_attributes(params[:section])\n format.html { redirect_to @section, notice: 'Section was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render ac...
[ "0.70796984", "0.70526665", "0.701372", "0.6969117", "0.6949376", "0.68567365", "0.68482435", "0.6837389", "0.6817472", "0.67823505", "0.6777296", "0.6777296", "0.6777296", "0.6777296", "0.6777296", "0.6777296", "0.6756845", "0.66736645", "0.6610641", "0.6610641", "0.6585893"...
0.67491376
17
DELETE /sections/1 or /sections/1.json
def destroy @section.destroy render json: SectionSerializer.new(@section) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @section.destroy\n respond_to do |format|\n format.html { redirect_to sections_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @section.destroy\n respond_to do |format|\n format.html { redirect_to sections_url }\n format.json { head :no_cont...
[ "0.7500553", "0.7500553", "0.74911845", "0.74911845", "0.74698997", "0.7362964", "0.7306996", "0.72674024", "0.72232556", "0.72232556", "0.71437764", "0.70949495", "0.709457", "0.7080434", "0.7080434", "0.7080434", "0.7080434", "0.7080434", "0.7080434", "0.7071732", "0.706472...
0.7121219
11
Use callbacks to share common setup or constraints between actions.
def set_section @section = Section.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.6163443", "0.604317", "0.5943409", "0.59143174", "0.5887026", "0.58335453", "0.57738566", "0.5701527", "0.5701527", "0.56534666", "0.5618685", "0.54237175", "0.5407991", "0.5407991", "0.5407991", "0.5394463", "0.5376582", "0.5355932", "0.53376216", "0.5337122", "0.5329516"...
0.0
-1
Only allow a list of trusted parameters through.
def section_params params.require(:section).permit(:name, :menu_id) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def allowed_params\n ALLOWED_PARAMS\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def parameters_list_params\n params.require(:parameters_list).permit(:name, :description, :is_user_specific)\n end", "def param_whitelist\n [:role, :title]\...
[ "0.69497335", "0.6812623", "0.6803639", "0.6795365", "0.67448795", "0.67399913", "0.6526815", "0.6518771", "0.64931697", "0.6430388", "0.6430388", "0.6430388", "0.63983387", "0.6356042", "0.63535863", "0.63464934", "0.63444513", "0.6337208", "0.6326454", "0.6326454", "0.63264...
0.0
-1
END url helpers for kongo_coaching_pages controllers END
def youtube_embed video, *style result = content_tag :iframe, 'youtube', src: video.yt_embed_link if style result = content_tag :iframe, 'youtube', src: video.yt_embed_link, style: style end return result end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def pages\n end", "def paginate_path(site, num_page); end", "def page\n\n end", "def url_for_index; end", "def url_for_index; end", "def homepage\n end", "def homepage\n end", "def homepage\n end", "def homepage\n end", "def page_url(page, obj = nil)\n url = case page\n when 'home' ...
[ "0.6180016", "0.61165375", "0.60557455", "0.5946249", "0.5946249", "0.5938096", "0.5938096", "0.59291613", "0.59291613", "0.5895041", "0.58630806", "0.5861985", "0.5838518", "0.58357346", "0.58357346", "0.5805513", "0.5805513", "0.5798736", "0.5798736", "0.5798736", "0.579873...
0.0
-1
day08_2.rb AUTHOR:: Kyle Mullins
def process_input(input_lines) input_lines.map { |instr| instr.chomp.gsub('inc', '+').gsub('dec', '-') } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def w_day; end", "def day() end", "def yday() end", "def yday\n end", "def cwday\n end", "def day; end", "def day=(_arg0); end", "def best_day\n\n end", "def ord(day)\n\nend", "def wday() end", "def day\n end", "def sunday_5_54_plus1\n make_hash(draw(49, 5), draw(11, 1))\n end", ...
[ "0.6593516", "0.6548552", "0.65404713", "0.64918506", "0.6452648", "0.6359621", "0.62978435", "0.62582606", "0.624706", "0.6213185", "0.61213076", "0.61128575", "0.6112742", "0.6079944", "0.6018732", "0.60161513", "0.6010929", "0.59905607", "0.59488064", "0.5940972", "0.59285...
0.0
-1
GET /commodities GET /commodities.json
def index @commodities = Commodity.all if params[:search].present? @commodities = @commodities.query(params[:search].to_s) end @commodities = @commodities.page(params[:page]) respond_to do |format| format.html format.js {} format.json { render json: {:commodities => @commodities} } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @categories = Category.all\n @commodities = current_user.commodities.order(\"created_at desc\")\n @selled = @commodities.where(:num => 0).page(params[:page]).per(15)\n @selling = @commodities.where(\"num > ?\", 0).page(params[:page]).per(15)\n respond_to do |format|\n format.html # ...
[ "0.71912295", "0.71552944", "0.7022852", "0.7022852", "0.62883896", "0.6219341", "0.6219341", "0.6196894", "0.61902994", "0.6051019", "0.60480565", "0.60461265", "0.6030203", "0.60208625", "0.60200393", "0.6002363", "0.59913033", "0.5915414", "0.5910676", "0.58964765", "0.587...
0.74435806
0
GET /commodities/1 GET /commodities/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n @commodity = Commodity.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @commodity }\n end\n end", "def show\n @commodity = Commodity.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n ...
[ "0.7433827", "0.7433827", "0.71551454", "0.69652677", "0.689434", "0.6624344", "0.6624344", "0.6546328", "0.6453164", "0.62858075", "0.62366587", "0.61024487", "0.6100771", "0.6013886", "0.5983782", "0.5970167", "0.5938198", "0.5938198", "0.5905315", "0.58970386", "0.5895779"...
0.0
-1
POST /commodities POST /commodities.json
def create @commodity = Commodity.new(commodity_params) respond_to do |format| if @commodity.save format.html { redirect_to commodities_url, flash: {success: '操作成功.' } } format.json { render :show, status: :created, location: @commodity } else format.html { render :new } format.json { render json: @commodity.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @commodity = Commodity.new(commodity_params)\n\n respond_to do |format|\n if @commodity.save\n format.html { redirect_to commodities_url, notice: 'Commodity was successfully created.' }\n format.json { render json: @commodity, status: :created, location: @commodity }\n el...
[ "0.7094458", "0.70077825", "0.64613676", "0.6373147", "0.6214883", "0.6214883", "0.6092892", "0.6036907", "0.5939506", "0.58917487", "0.58812815", "0.5603079", "0.5579009", "0.5560071", "0.55228204", "0.5505408", "0.54937017", "0.54700327", "0.54653186", "0.5463377", "0.54466...
0.6577053
2
PATCH/PUT /commodities/1 PATCH/PUT /commodities/1.json
def update respond_to do |format| if @commodity.update(commodity_params) format.html { redirect_to commodities_url, flash: {success: '操作成功.' } } format.json { render :show, status: :ok, location: @commodity } else format.html { render :edit } format.json { render json: @commodity.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @commodity = Commodity.find(params[:id])\n\n respond_to do |format|\n if @commodity.update_attributes(commodity_params)\n format.html { redirect_to commodities_url, notice: 'Commodity was successfully updated.' }\n format.json { head :no_content }\n else\n format.h...
[ "0.70659274", "0.70275474", "0.66141903", "0.6241457", "0.6137007", "0.60896826", "0.60846996", "0.60583407", "0.60425067", "0.6035777", "0.5943537", "0.59056324", "0.5882299", "0.58812845", "0.58788496", "0.58717203", "0.5842476", "0.58403707", "0.5833222", "0.58244824", "0....
0.6697056
2
DELETE /commodities/1 DELETE /commodities/1.json
def destroy @commodity.destroy respond_to do |format| format.html { redirect_to commodities_url, flash: {success: '操作成功.' } } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @commodity = Commodity.find(params[:id])\n @commodity.destroy\n\n respond_to do |format|\n format.html { redirect_to commodities_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @commodity = Commodity.find(params[:id])\n @commodity.destroy\n\n re...
[ "0.78400135", "0.78400135", "0.70825875", "0.68719316", "0.674327", "0.65776396", "0.65577424", "0.6527304", "0.6523719", "0.6510812", "0.6504754", "0.65034646", "0.6488678", "0.646819", "0.64428866", "0.64417535", "0.6437164", "0.643199", "0.64151996", "0.63802296", "0.63757...
0.7336592
2
Use callbacks to share common setup or constraints between actions.
def set_commodity @commodity = Commodity.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 commodity_params params.require(:commodity).permit(:name, :code, :commodity_type_id, :bar_code, :specification, :unit, :cost, :sale, :low_stock, :high_stock) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strong_params\n params.require(:user).permit(param_whitelist)\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def allow_params_authentication!; end", "def allowed_params\n ALLOWED_PARAMS\n end", "def default_param_whitelist\n [\"mode\"]\n...
[ "0.69792545", "0.6781151", "0.67419964", "0.674013", "0.6734356", "0.6591046", "0.6502396", "0.6496313", "0.6480641", "0.6477825", "0.64565", "0.6438387", "0.63791263", "0.63740575", "0.6364131", "0.63192815", "0.62991166", "0.62978333", "0.6292148", "0.6290449", "0.6290076",...
0.0
-1
Delayed jobs are not yet supported with Redis backend
def enqueue(job:, method:, args:, delay: nil) meta = { "enqueued_at" => Time.now.to_i } task = Task.new(self, generate_task_id, job, method, args, meta) client_push(task) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def queue_job; end", "def redis_pool; end", "def delayed_jobs\n # The double-checks here are so that we won't blow up if the config stops using redis-namespace\n timestamps = (Array(Resque.redis.zrange(\"resque:delayed_queue_schedule\",0,-1)) + \n Array(Resque.redis.zrange(\"delayed_queu...
[ "0.61874324", "0.6115342", "0.6074833", "0.60078037", "0.58725166", "0.58628356", "0.5778365", "0.57309747", "0.56849873", "0.5674684", "0.5670709", "0.5653935", "0.5630518", "0.55452037", "0.5497987", "0.5493746", "0.54778796", "0.5468209", "0.5463209", "0.54517955", "0.5346...
0.0
-1
Output: [2,3] Approach 3: Hash map Complexity Analysis Time complexity: O(n) average case.
def find_duplicates(array) result_hash = {} result_array = [] array.each do |num| if result_hash[num].nil? result_hash[num] = 1 else result_hash[num] += 1 end end result_hash.each do |k, v| result_array.push(k) if v > 1 end result_array end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def hash_two_sum(arr,target_sum)\n #creates a new hash with each element that is satisfying the target_sum\n hash = Hash.new(0) #{|h,k| h[k] = []}\n (0...arr.length).each { |i| hash[i] = arr[i]} #O(n)\nend", "def hash_map_two_sum(arr,target_sum)\n count = {}\n arr.each do |ele|\n count[ele]...
[ "0.7060721", "0.66942304", "0.6630345", "0.6484438", "0.64232737", "0.6340076", "0.62901914", "0.6274769", "0.627441", "0.6247868", "0.62390167", "0.62355465", "0.6224337", "0.62183005", "0.6195109", "0.6187997", "0.61857194", "0.6136934", "0.61342776", "0.61342776", "0.61342...
0.0
-1
Update various attachments, then remove any that were not updated
def update_or_remove Event.transaction do clear_before_time = 1.second.ago yield remove_old_attachments(clear_before_time) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def remove_attachments_from_existing_note(note, attachments)\n attachments.each do |attach|\n logger.info \"Removing attachment '#{attach.file_name}' from note ID #{note.id}\"\n wait_for_update_and_click existing_note_attachment_delete_button(note, attach)\n confirm_delete\n existing_note_at...
[ "0.707795", "0.69840896", "0.6842216", "0.6807516", "0.6785506", "0.6785506", "0.6731242", "0.6606257", "0.65133536", "0.6494262", "0.64389175", "0.6319224", "0.6316524", "0.63062274", "0.6289922", "0.618119", "0.617752", "0.6173531", "0.61473244", "0.6080278", "0.6079415", ...
0.6908596
2
Magically update multivalue field associations from textarea input To add a new field, add its entry to attachments.json, and ensure that attachment_target supports its base association type
def magic_update(field) attachment = ATTACHMENTS.find { |a| a[:key] == field.to_s } clean_params[field].split("\n").map(&:squish).uniq.each do |item| create_attachment(attachment, item) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def populate_fields(target,data)\n data.each{|key,value|target.text_field(:name=>key).set value}\nend", "def update!(**args)\n @add_attachments = args[:add_attachments] if args.key?(:add_attachments)\n end", "def process_attachments!\n child_documents = parsed_form.dig('dependents_applicati...
[ "0.5902316", "0.5628702", "0.5626617", "0.5597691", "0.5563786", "0.5543971", "0.5534968", "0.54784775", "0.54414", "0.5433138", "0.5420685", "0.5413567", "0.5413567", "0.53953", "0.5328849", "0.5213273", "0.5212476", "0.51692575", "0.5123383", "0.512225", "0.51111287", "0....
0.55792487
4
brackets at SET for single value
def update() sql = "UPDATE countries SET name = $1 WHERE id = $2" values = [@name, @id] SqlRunner.run(sql, values) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set(index, val)\n \n end", "def []=(string, value); end", "def []=(string, value); end", "def set(value)\n execute_only(:set, value)\n end", "def set(object, value); end", "def set=(_arg0); end", "def value=(val); end", "def value=(_); end", "def set(item, value)\n ru...
[ "0.6529487", "0.6489435", "0.6489435", "0.6469051", "0.6466106", "0.6461412", "0.64169127", "0.63620573", "0.630727", "0.6268195", "0.6232322", "0.6225457", "0.62039995", "0.62039995", "0.61888295", "0.61847246", "0.6141522", "0.61349905", "0.60952437", "0.60952437", "0.60716...
0.0
-1
Check whether this range proof is valid or not.
def valid? # Check tx = <lx, rx> unless FIELD.mod(lx.zip(rx).map { |a, b| FIELD.mod(a * b) }.sum) == tx return false end return false unless valid_poly_t? p = vec_g .zip(lx) .map { |a, b| a * b } .zip(vec_h2.zip(rx).map { |a, b| a * b }) .map { |a, b| a + b } .sum(GROUP.infinity) p1 == p2 && p2 == p end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def valid?\n return false if @range_start_index.nil?\n return false if @range_end_index.nil?\n true\n end", "def valid? _e = self.e\n _e and _e.between?(2, self.p-2) and _e.bits_set > 1\n end", "def valid?\n x.between?(0, 6) && y.between?(-1, 6)\n end", "def valid? _e ...
[ "0.71757114", "0.684487", "0.6843913", "0.6772827", "0.674743", "0.67094177", "0.6706939", "0.6704488", "0.66463506", "0.6628334", "0.6627253", "0.6624542", "0.65926594", "0.64792097", "0.64792097", "0.64658296", "0.64633846", "0.6460021", "0.6445712", "0.6417783", "0.6417542...
0.0
-1
The content of the proof is made into a Hash object.
def to_h { V: v.hex, A: p_a.hex, S: p_s.hex, T1: p_t1.hex, T2: p_t2.hex, tx: "0x#{tx.hex}", txbf: "0x#{tx_bf.hex}", e: "0x#{e.hex}", lx: { n: ORDER_HEX, elems: lx.map { |x| "0x#{x.hex}" } }, rx: { n: ORDER_HEX, elems: rx.map { |x| "0x#{x.hex}" } }, G: GENERATOR_G.hex, order: ORDER_HEX } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def hash\n [anchor, cv, nullifier, proof, rk, spend_auth_sig].hash\n end", "def hash() end", "def hash() end", "def hash() end", "def hash() end", "def hash() end", "def hash() end", "def hash() end", "def hash\n @content.hash\n end", "def hash; end", "def hash; end", "def hash; e...
[ "0.7096036", "0.6494298", "0.6494298", "0.6494298", "0.6494298", "0.6494298", "0.6494298", "0.6494298", "0.62755364", "0.6173896", "0.6173896", "0.6173896", "0.6173896", "0.6173896", "0.6173896", "0.6173896", "0.6173896", "0.6173896", "0.6173896", "0.6147524", "0.61399823", ...
0.0
-1
Convert compressed range proof using inner product.
def to_compress a = lx.dup b = rx.dup ts = transcript.dup w = ts.challenge_scalar("w") q = GENERATOR_BJ * w a_sum = a.dup b_sum = b.dup g_sum = vec_g.dup h_sum = vec_h2.dup terms = [] until a_sum.length == 1 a_lo = [] b_lo = [] g_lo = [] h_lo = [] a_hi = [] b_hi = [] g_hi = [] h_hi = [] half = a_sum.length / 2 a_sum.each.with_index do |_, i| if i < half a_lo << a_sum[i] b_lo << b_sum[i] g_lo << g_sum[i] h_lo << h_sum[i] else a_hi << a_sum[i] b_hi << b_sum[i] g_hi << g_sum[i] h_hi << h_sum[i] end end alo_bhi = a_lo.zip(b_hi).map { |x, y| FIELD.mod(x * y) }.sum ahi_blo = a_hi.zip(b_lo).map { |x, y| FIELD.mod(x * y) }.sum l_k = g_hi.zip(a_lo).map { |x, y| x * y }.sum(INFINITY_J) + h_lo.zip(b_hi).map { |x, y| x * y }.sum(INFINITY_J) + q * alo_bhi r_k = g_lo.zip(a_hi).map { |x, y| x * y }.sum(INFINITY_J) + h_hi.zip(b_lo).map { |x, y| x * y }.sum(INFINITY_J) + q * ahi_blo ts.points << l_k ts.points << r_k uk = ts.challenge_scalar("uk") uk_inv = FIELD.inverse(uk) terms << { L: l_k, R: r_k } a_sum = [] b_sum = [] g_sum = [] h_sum = [] a_lo.each.with_index do |_, i| a_sum << (a_lo[i] * uk + a_hi[i] * uk_inv) b_sum << (b_lo[i] * uk_inv + b_hi[i] * uk) g_sum << (g_lo[i] * uk_inv + g_hi[i] * uk) h_sum << (h_lo[i] * uk + h_hi[i] * uk_inv) end end a0 = a_sum.first b0 = b_sum.first Compressed.new(v, p_a, p_s, p_t1, p_t2, tx, tx_bf, e, a0, b0, terms) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def mult(other_range)\n xlo = first\n xhi = last\n ylo = other_range.first\n yhi = other_range.last\n pos = ->(x) { x >= 0 }\n neg = ->(x) { x <= 0 }\n return (xlo * ylo)..(xhi * yhi) if [xlo, xhi, ylo, yhi].all?(&pos)\n return (xhi * ylo)..(xhi * yhi) if [xlo, xhi, yhi].all?(&pos) and [ylo...
[ "0.53129953", "0.51936966", "0.5123207", "0.5123207", "0.5113586", "0.50973785", "0.50620395", "0.5046364", "0.50194764", "0.5015838", "0.5008503", "0.5004842", "0.49989852", "0.4994211", "0.49884263", "0.497221", "0.4961087", "0.49530277", "0.49439105", "0.4938097", "0.49367...
0.5961378
0
This method is called after all identities have been moved from `other` to `self`, but before `other` has been destroyed and before the end of the transaction. By default, it does nothing.
def perform_additional_merge_operations!(other) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def swap_with(other)\n self.class.base_class.transaction do\n old_position = position\n update_attribute(:position, other.position)\n other.update_attribute(:position, old_position)\n end\n end", "def absorb other\n self.about = other.about if self.about.blank?\n ...
[ "0.5760911", "0.5438817", "0.53730154", "0.5307102", "0.52858746", "0.5108874", "0.51039845", "0.5095332", "0.50722384", "0.50710714", "0.5052705", "0.5049128", "0.50425255", "0.5033477", "0.50249666", "0.5020485", "0.50151", "0.5012812", "0.5012812", "0.50072485", "0.4974553...
0.48784542
34
GET /shipping_options/1 GET /shipping_options/1.json
def show @shipping_option = ShippingOption.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render json: @shipping_option } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def shipping_options\n Hash.new\n end", "def new\n @shipping_option = ShippingOption.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @shipping_option }\n end\n end", "def shipping_fee\n @admin_options = Admin::Option.where(\"id = ?\" , 4...
[ "0.72764933", "0.7117327", "0.6745459", "0.6532361", "0.64822257", "0.63974637", "0.6379292", "0.6358732", "0.6284373", "0.6206988", "0.6145065", "0.61441195", "0.61408645", "0.61267304", "0.6120737", "0.6118218", "0.6104784", "0.6083203", "0.6074076", "0.6053882", "0.6050322...
0.76127625
0
GET /shipping_options/new GET /shipping_options/new.json
def new @shipping_option = ShippingOption.new respond_to do |format| format.html # new.html.erb format.json { render json: @shipping_option } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @shipping_option = ShippingOption.new(params[:shipping_option])\n\n respond_to do |format|\n if @shipping_option.save\n format.html { redirect_to @shipping_option, notice: 'Shipping option was successfully created.' }\n format.json { render json: @shipping_option, status: :cre...
[ "0.75195396", "0.7092113", "0.7014411", "0.68997157", "0.6854294", "0.6833646", "0.6670023", "0.6609017", "0.65135556", "0.648711", "0.648711", "0.643037", "0.64238375", "0.63948464", "0.6372058", "0.6372058", "0.63628006", "0.63560814", "0.6337575", "0.6335904", "0.6334768",...
0.8196601
0
POST /shipping_options POST /shipping_options.json
def create @shipping_option = ShippingOption.new(params[:shipping_option]) respond_to do |format| if @shipping_option.save format.html { redirect_to @shipping_option, notice: 'Shipping option was successfully created.' } format.json { render json: @shipping_option, status: :created, location: @shipping_option } else format.html { render action: "new" } format.json { render json: @shipping_option.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def shipping_options\n Hash.new\n end", "def shipping_method_params\n # params.require(:shipping_method).permit(:name, :admin_name, :display_on, :shipping_categories)\n params.require(:shipping_method).permit(:name, :admin_name, :display_on, :shipping_category_ids => [])\n end", "def add_s...
[ "0.6891033", "0.66590875", "0.64115906", "0.641141", "0.6390521", "0.63499707", "0.63313067", "0.63216096", "0.63127196", "0.6252297", "0.62448317", "0.62297773", "0.6093281", "0.6087907", "0.60523325", "0.60504204", "0.60492456", "0.6045949", "0.6006122", "0.5944607", "0.594...
0.7298239
0
PUT /shipping_options/1 PUT /shipping_options/1.json
def update @shipping_option = ShippingOption.find(params[:id]) respond_to do |format| if @shipping_option.update_attributes(params[:shipping_option]) format.html { redirect_to @shipping_option, notice: 'Shipping option was successfully updated.' } format.json { head :no_content } else format.html { render action: "edit" } format.json { render json: @shipping_option.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @shipping_option = ShippingOption.new(params[:shipping_option])\n\n respond_to do |format|\n if @shipping_option.save\n format.html { redirect_to @shipping_option, notice: 'Shipping option was successfully created.' }\n format.json { render json: @shipping_option, status: :cre...
[ "0.6716322", "0.65077084", "0.64580584", "0.6420317", "0.6414997", "0.63914895", "0.6363216", "0.6355999", "0.63348055", "0.62984604", "0.62516844", "0.6240664", "0.623425", "0.6220395", "0.61370414", "0.61319315", "0.6125961", "0.61213094", "0.61127245", "0.610799", "0.61030...
0.74950427
0
DELETE /shipping_options/1 DELETE /shipping_options/1.json
def destroy @shipping_option = ShippingOption.find(params[:id]) @shipping_option.destroy respond_to do |format| format.html { redirect_to shipping_options_url } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @shipping_method.destroy\n respond_to do |format|\n format.html { redirect_to admin_shipping_methods_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @shipping_detail.destroy\n respond_to do |format|\n format.html { redirect_to shipping_details_ur...
[ "0.7427041", "0.7112162", "0.70128614", "0.69396985", "0.688937", "0.68504006", "0.68322504", "0.6824092", "0.6779067", "0.677389", "0.67732257", "0.6763765", "0.6734603", "0.67255276", "0.6657145", "0.6647442", "0.6646464", "0.66054416", "0.6589272", "0.656056", "0.65575373"...
0.80193347
0
GET /variations GET /variations.json
def index if @indexer.present? @variations = @indexer.variations render json: @variations else render json: ErrorSerializer.to_404('Indexer'), status: :not_found end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def all(product_id, params = {})\n response, status = BeyondApi::Request.get(@session, \"/products/#{product_id}/variations\", params)\n\n handle_response(response, status)\n end", "def index\n @variations = Variation.all\n end", "def index\n @variations = Variation.all\n end", "def show...
[ "0.7173117", "0.6954198", "0.6954198", "0.6881798", "0.6810022", "0.6711844", "0.66704345", "0.66340417", "0.64411163", "0.62418133", "0.6041744", "0.60115874", "0.5977257", "0.5946519", "0.5925508", "0.5916899", "0.5857388", "0.5843686", "0.58338875", "0.5817141", "0.5812605...
0.6581413
8
POST /variations POST /variations.json
def create if @indexer.present? @variation = Variation.new(variation_params) if @variation.save render json: @variation, status: :created # Ver como resolver o location else render json: ErrorSerializer.to_422('Variation', @variation.errors.messages), status: :unprocessable_entity end else render json: ErrorSerializer.to_404('Indexer'), status: :not_found end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @variety = Variety.new(variety_params)\n\n respond_to do |format|\n if @variety.save\n format.html { redirect_to admin_varieties_path, notice: 'La variedad fue creada' }\n format.json { render :show, status: :created, location: @variety }\n format.js{}\n else\n ...
[ "0.6731026", "0.6665459", "0.65123886", "0.6409058", "0.63312393", "0.62752223", "0.6267235", "0.61545205", "0.6154145", "0.61067826", "0.6077112", "0.6059716", "0.60490584", "0.60006464", "0.5938976", "0.5919521", "0.5910436", "0.587525", "0.58142024", "0.5803933", "0.580274...
0.59614366
14
DELETE /variations/1 DELETE /variations/1.json
def destroy if @indexer.present? if @indexer.belongs_to(@variation) @variation.destroy head :no_content else render json: ErrorSerializer.to_404('Variation'), status: :not_found end else render json: ErrorSerializer.to_404('Indexer'), status: :not_found end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @variety = Variety.find(params[:id])\n @variety.destroy\n\n respond_to do |format|\n format.html { redirect_to varieties_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @variation.destroy\n respond_to do |format|\n format.html { redirect_to va...
[ "0.7356382", "0.73307234", "0.7236511", "0.704547", "0.7022853", "0.7014466", "0.6995624", "0.6934989", "0.6920931", "0.6867219", "0.6842477", "0.6826637", "0.6779561", "0.67754567", "0.66830385", "0.6619788", "0.65975", "0.6590745", "0.65842605", "0.6575495", "0.6573792", ...
0.65309983
24
order the rectangles as per assumptions
def order_rectangles(rec1, rec2) r1 = Rectangle.new(rec1) r2 = Rectangle.new(rec2) r1 = order_coord_of_rectangles(r1) r2 = order_coord_of_rectangles(r2) if r2.A.X < r1.A.X temp = r1 r1 = r2 r2 = temp end ret = [r1, r2] return ret end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def determine_rects(rect, spacing)\n rects = []\n \n # Rects Initialization\n rects[0] = [Rect.new(rect.x,rect.y,24,24),\n Rect.new(rect.x,rect.y,80,24),\n Rect.new(rect.x,rect.y,rect.width,24)]\n rects[1] = [Rect.new(rect.x,rect.y,24,24),\n Rect.new(rect...
[ "0.6826875", "0.6623872", "0.6600286", "0.648778", "0.648778", "0.64299035", "0.6417485", "0.6112955", "0.5999371", "0.5987383", "0.5915914", "0.59156555", "0.58682764", "0.58656216", "0.58424985", "0.5837189", "0.5820636", "0.5820636", "0.5787926", "0.5780684", "0.57240295",...
0.74052614
0
get a script session id
def get_session_id @agent.get( @root_url + '/dwr/engine.js') do |page| @session_id = extract_session_id(page.body) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def id\n @id ||= scgi.session_id\n end", "def session_id; end", "def session_id; end", "def session_id; end", "def get_session_id\n check_lisitng_id\n calendar_frame = get_vrbo_calendar_page.iframes.first.src\n page = @agent.get calendar_frame\n link = page.links[3].href\n uri = Addr...
[ "0.72828907", "0.7209385", "0.7209385", "0.7209385", "0.72038054", "0.7065345", "0.70478994", "0.7008191", "0.6987341", "0.69795215", "0.69387335", "0.6931841", "0.6925708", "0.6917141", "0.6916633", "0.6915339", "0.6912884", "0.6894368", "0.6856121", "0.6816429", "0.67322457...
0.78841764
0
find the ID of the top headlines element, which is in a script element that looks like this: DM.has("r0c1p15", "headlines");
def get_headline_div_id(page) script = page.parser.css('script').select { |script| script.text =~ /DM\.has\(\".*\"\,\ \"headlines\"\)/ } /DM\.has\(\"(.*)\"\,\ \"headlines\"\)/.match(script[0].to_s)[1] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def head\n @head ||= node.attr(:head).to_i\n end", "def headliner\n @headliner ||= artists.detect {|a| a.name == headliner_raw }\n end", "def read_head_id\n File.read(head_path).strip if File.exists?(head_path)\n end", "def id\n return @doc.xpath('//mets:metsHdr/@ID').to_s\...
[ "0.5985805", "0.59420973", "0.5580789", "0.548702", "0.54617065", "0.54027736", "0.539868", "0.53349596", "0.53338015", "0.530045", "0.5147233", "0.51387066", "0.5123056", "0.5123056", "0.5123056", "0.51198745", "0.5116149", "0.51076233", "0.5077348", "0.50618815", "0.5049796...
0.76688844
0
extract article id from the uri
def get_article_id(urn) /\/(.*)\/article\-(.*)\/.*/.match(urn)[2].to_i end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def find_id(uri)\n Addressable::URI.parse(uri).basename\n end", "def extract_id_uri\n @id_uri = @meta.at_xpath('./a:identification/a:FRBRWork/a:FRBRuri', a: NS)['value']\n empty, @country, @nature, date, @num = @id_uri.split('/')\n\n # yyyy-mm-dd\n @year = date.split('-', 2)[0]\n end",...
[ "0.74195385", "0.72079074", "0.71480155", "0.7111334", "0.69423306", "0.68857217", "0.68857217", "0.6804149", "0.67912287", "0.6776286", "0.66437405", "0.6629898", "0.66148144", "0.655658", "0.6547822", "0.64951754", "0.6484113", "0.64748013", "0.64595467", "0.6423391", "0.64...
0.82634616
0
extract a meta tag value from the page
def get_metatag(page, tag) page.parser.css("meta[name='#{tag}']").first['content'] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def content_for_meta_tag(attribute_selector, html)\n html.xpath(\"//head/meta[@#{attribute_selector}]/@content\").first.try(:content)\n end", "def extract_meta\n end", "def get_tag(meta)\n sanitize_tag parse_tag_metadata_vars(meta)\n end", "def get_meta(property, prptfile)\n meta_doc = ge...
[ "0.7258221", "0.6716201", "0.66033334", "0.6501697", "0.6474944", "0.6412844", "0.6277703", "0.62498915", "0.6245625", "0.6232757", "0.6206824", "0.6184546", "0.6146254", "0.61297274", "0.61200905", "0.61134243", "0.6070692", "0.6048937", "0.60113454", "0.60113454", "0.599297...
0.76771367
0
Show the most recent images
def latest @photos = @region.photos.order("id DESC").limit(18) respond_to do |format| format.html { render :template => @template } format.json { render json: @photos } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n # most recent picture first!\n @title = \"Latest photos\"\n @photos = Photo.all.order(created_at: :desc)\n end", "def index\n @imgs = Img.order(created_at: :desc).limit(20)\n end", "def index\n @recent_objects = Image.recent_from_project_id($project_id).order(updated_at: :desc).lim...
[ "0.7246279", "0.7193732", "0.7173222", "0.685053", "0.6738076", "0.67314905", "0.67102146", "0.6678358", "0.6583362", "0.6579719", "0.6561391", "0.6553216", "0.65126586", "0.6499532", "0.64647305", "0.6424361", "0.63947105", "0.6359862", "0.6342885", "0.63407385", "0.62854546...
0.604605
35
Show the toprated images from the past 48 hours
def popular @limit = params[:limit] || 50; @photos = @region.photos.where("created_at > ? AND score > 0", now - 48 * 3600).order("score DESC").limit(@limit) if not @photos.any? @photos = @region.photos.where("score < 100 AND score > 20").order("score DESC").limit(@limit) end respond_to do |format| format.html { render :template => @template } format.json { render json: @photos } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n @altitude_file = \"graphs/#{@track.id}-altitude.png\"\n @altitude_thumbnail_file = \"graphs/#{@track.id}-altitude-thumbnail.png\"\n altitude_path = File.expand_path(\"images/#{@altitude_file}\", Rails.public_path)\n altitude_thumbnail_path = File.expand_path(\"images/#{@altitude_thumbnail_fi...
[ "0.5808573", "0.57663786", "0.57663786", "0.57470036", "0.56493276", "0.55144185", "0.54969543", "0.5410911", "0.5398591", "0.53833866", "0.5354306", "0.5332395", "0.53243417", "0.5320529", "0.52673286", "0.5266716", "0.52583545", "0.52530414", "0.5252351", "0.52515656", "0.5...
0.0
-1
Show the best images
def top @limit = params[:limit] || 50; @photos = @region.photos.where("score > 0").order("score DESC").limit(@limit) respond_to do |format| format.html { render :template => @template } format.json { render json: @photos } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n if params[:method] == 'euclidean'\n if params[:threshold].blank?\n @threshold = 0.5\n else\n @threshold = params[:threshold].to_f\n end\n @pictures = Picture.all.to_a\n @pictures.each do |picture|\n picture.m = @picture.match(picture, @threshold)\n e...
[ "0.6460681", "0.6364586", "0.6218618", "0.6197685", "0.6127764", "0.609799", "0.60435635", "0.59243995", "0.5874635", "0.5873022", "0.5816592", "0.5795879", "0.57858586", "0.57765824", "0.57743907", "0.5773743", "0.5767515", "0.5762214", "0.57542896", "0.5733784", "0.5670172"...
0.54717237
41
Show the images by an ID
def show @limit = params[:limit] || 24; @photos = @region.photos.where("id <= ?", params[:id]).order("id DESC").limit(@limit) if @region.name == "artstech" @og_title = "Styleblaster @ Arts/Tech NYC" else @og_title = "Styleblaster" end if @photos.any? @og_image = @photos.first.photo.url @og_url = "http://styleblaster.net/#{@region.name}/p/#{@photos.first.id}/" end respond_to do |format| format.html { render :template => @template } format.json { render json: @photos } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def display id\n get_image(id).display\n end", "def show\n @id = params[:id]\n @image = Image.find(@id)\n end", "def show\r\n\t\tbegin\r\n\t\t\t@image = Image.find(params[:id])\r\n\t\trescue ActiveRecord::RecordNotFound\r\n\t\t\trender :text => \"Image ##{params[:id].to_s} not found\"\r\n\t\tend\r\n...
[ "0.81350785", "0.7725066", "0.7464046", "0.74391973", "0.7371636", "0.735456", "0.7167137", "0.709756", "0.7092669", "0.7017839", "0.70171493", "0.69977516", "0.6984865", "0.6972654", "0.6957121", "0.69379497", "0.69279194", "0.69264853", "0.69031394", "0.6900149", "0.6840053...
0.0
-1
Show images by a random ID
def random @limit = params[:limit] || 1; @photos = @region.photos.order(sql_rand).limit(@limit) respond_to do |format| format.html { render :template => @template } format.json { render json: @photos } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n if current_user.id.to_s == params[:id]\n random_picture_generator\n end\n\n @pictures = Picture.pictures_by_user(params[:id])\n end", "def display id\n get_image(id).display\n end", "def show\n if @current_user.nil? and (!params[:id].to_i.zero? or User.find_by_username(params[:...
[ "0.7557411", "0.7292666", "0.71763915", "0.68948567", "0.6842437", "0.681356", "0.6791631", "0.6731747", "0.66986704", "0.6571749", "0.65645045", "0.6527514", "0.6512736", "0.65032476", "0.65014976", "0.64475197", "0.6437598", "0.64323455", "0.635937", "0.6353477", "0.6349581...
0.6112831
43
/upload API used by processing, returns url to image
def create @region = Region.find_by_name(params[:name]) # if @region.secret != params[:secret] # render :text => "404" # return # end @photo = Photo.create( :photo => params[:test], :score => 1, :region => @region ) render :text => @photo.photo.url # render :text => "http://localhost:3000/gallery/" + @photo.id.to_s end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def upload_url\n return unless @data['image']\n # Isn't actually displayed in-app without this set\n return unless image['property'] == 'image'\n file(@data['image'])\n end", "def upload_url\n _get(\"/files/upload_url\") { |json| json }\n end", "def upload_file_url\...
[ "0.76762915", "0.76309806", "0.7230602", "0.7212467", "0.7100774", "0.7009256", "0.6970784", "0.69499105", "0.68149436", "0.68149436", "0.67911583", "0.6778094", "0.673239", "0.6729469", "0.6695691", "0.667052", "0.6664613", "0.664523", "0.6636087", "0.663372", "0.6615889", ...
0.0
-1
GET /ad_domains GET /ad_domains.json
def index #@ad_domains = AdDomain.all @ad_domains = AdDomain.order("name asc").paginate :page => params[:page], :per_page => 25 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show_domains\n render json: dme.show_domains\n end", "def domains\n\tfetch(\"/Domain.List\")\nend", "def domains_list\n call('domains.list')[:domains]\n end", "def domains\n get()[\"app\"][\"domains\"]\n end", "def index\n\t\t@domains = Domain.all\n\t\trespond_to do |format|\n\t\t\t...
[ "0.7707752", "0.76426905", "0.74041206", "0.7386878", "0.7279645", "0.7222806", "0.7068997", "0.70481753", "0.69936115", "0.6979934", "0.6912498", "0.6842025", "0.6822738", "0.68227273", "0.68019074", "0.67960876", "0.6770521", "0.6767098", "0.6765649", "0.6753531", "0.670958...
0.61448765
50
GET /ad_domains/1 GET /ad_domains/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show_domains\n render json: dme.show_domains\n end", "def domains\n\tfetch(\"/Domain.List\")\nend", "def show_domain\n render json: dme.show_domain(\"#{params[:domain]}\")\n end", "def index\n\t\t@domains = Domain.all\n\t\trespond_to do |format|\n\t\t\tformat.json { render json: @domains }\n\t\te...
[ "0.7409508", "0.7155722", "0.70655483", "0.7014493", "0.6839358", "0.6675204", "0.66522604", "0.66339266", "0.6592849", "0.6574667", "0.65659446", "0.65580225", "0.65531814", "0.6524862", "0.651711", "0.6517048", "0.64981836", "0.64917034", "0.6484045", "0.64769214", "0.64749...
0.0
-1
POST /ad_domains POST /ad_domains.json
def create @ad_domain = AdDomain.new(ad_domain_params) #authorize! :create, @ad_domain respond_to do |format| if @ad_domain.save format.html { redirect_to @ad_domain, notice: 'Active Directory domain was successfully created.' } format.json { render :show, status: :created, location: @ad_domain } else format.html { render :new } format.json { render json: @ad_domain.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_agent_domain\n return false unless validate_params\n puts '########## CREATING DOMAIN ##########'\n dme.create_domain(params[:domain])\n puts '########## CREATING DEFAULT RECORDS ##########'\n create_default_records\n puts '########## CREATING ADDITIONAL RECORDS ##########'\n create...
[ "0.6632935", "0.6578056", "0.6368173", "0.6293478", "0.60988146", "0.60834527", "0.60630584", "0.6025382", "0.5943322", "0.58792007", "0.5857681", "0.5857312", "0.58540356", "0.58126026", "0.58043593", "0.57285047", "0.57284164", "0.567969", "0.5673843", "0.5659294", "0.56592...
0.65196174
2
PATCH/PUT /ad_domains/1 PATCH/PUT /ad_domains/1.json
def update authorize! :update, @ad_domain respond_to do |format| if @ad_domain.update(ad_domain_params) format.html { redirect_to @ad_domain, notice: 'Active Directory domain was successfully updated.' } format.json { render :show, status: :ok, location: @ad_domain } else format.html { render :edit } format.json { render json: @ad_domain.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @domain = Domain.find(params[:id])\n\n if @domain.update(domain_params)\n head :no_content\n else\n render json: @domain.errors, status: :unprocessable_entity\n end\n end", "def update\n respond_to do |format|\n if @domain.update(domain_params)\n format.html { r...
[ "0.71034247", "0.6570461", "0.6513877", "0.6490646", "0.6346449", "0.6333242", "0.6294404", "0.6265997", "0.61892194", "0.6174989", "0.6146322", "0.61300796", "0.608417", "0.6057645", "0.604849", "0.60423124", "0.60218257", "0.5990034", "0.5987713", "0.592205", "0.59196925", ...
0.6770255
1
DELETE /ad_domains/1 DELETE /ad_domains/1.json
def destroy authorize! :destroy, @ad_domain @ad_domain.destroy respond_to do |format| format.html { redirect_to ad_domains_url, notice: 'Active Directory domain was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete_agent_domain\n return false unless validate_domain\n render json: dme.delete_domain(params[:domain])\n end", "def destroy\n @domain = Domain.find(params[:id])\n @domain.destroy\n\n respond_to do |format|\n format.html { redirect_to domains_url }\n format.json { head :ok }\n ...
[ "0.7554419", "0.71615237", "0.71452945", "0.7079409", "0.70446527", "0.70075154", "0.69847095", "0.695375", "0.6878732", "0.6815567", "0.677915", "0.6765168", "0.67313164", "0.66974014", "0.6670479", "0.66543275", "0.664836", "0.66335446", "0.6631375", "0.65705687", "0.656287...
0.7128267
3
Use callbacks to share common setup or constraints between actions.
def set_ad_domain @ad_domain = AdDomain.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.6163443", "0.604317", "0.5943409", "0.59143174", "0.5887026", "0.58335453", "0.57738566", "0.5701527", "0.5701527", "0.56534666", "0.5618685", "0.54237175", "0.5407991", "0.5407991", "0.5407991", "0.5394463", "0.5376582", "0.5355932", "0.53376216", "0.5337122", "0.5329516"...
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def ad_domain_params params.require(:ad_domain).permit(:name, :description, :active) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strong_params\n params.require(:user).permit(param_whitelist)\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def allow_params_authentication!; end", "def allowed_params\n ALLOWED_PARAMS\n end", "def default_param_whitelist\n [\"mode\"]\n...
[ "0.69792545", "0.6781151", "0.67419964", "0.674013", "0.6734356", "0.6591046", "0.6502396", "0.6496313", "0.6480641", "0.6477825", "0.64565", "0.6438387", "0.63791263", "0.63740575", "0.6364131", "0.63192815", "0.62991166", "0.62978333", "0.6292148", "0.6290449", "0.6290076",...
0.0
-1
+cache+ must behave like a hash (Hash and Monkeyshines::Store::TyrantRdbKeyStore are both cromulent choices).
def initialize _options self.options = DEFAULT_OPTIONS.deep_merge(_options) self.cache = Monkeyshines::Store.create(options[:cache]) self.store = Monkeyshines::Store.create(options[:store]) self.misses = 0 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cache_store; end", "def cache_store; end", "def cache_key; @cache.to_sym; end", "def cache_store=(_arg0); end", "def cache_store=(_arg0); end", "def cache; shrine_class.new(cache_key); end", "def [](*args)\n args = args.first if (args.size == 1)\n return super(args) if args.is_a?(...
[ "0.72714496", "0.72714496", "0.70328534", "0.69505024", "0.69505024", "0.6944917", "0.69408226", "0.6904367", "0.68752587", "0.6856064", "0.67527133", "0.6676023", "0.66746426", "0.66718924", "0.666134", "0.666134", "0.666134", "0.666134", "0.666134", "0.666134", "0.666134", ...
0.0
-1
If key is absent, save the result of calling the block. If key is present, block is never called. Ex: rt_store.set(url) do fetcher.get url will only be called if url isn't in rt_store end
def set key, force=nil, &block return if (!force) && cache.include?(key) cache_val, store_val = block.call() return unless cache_val cache.set_nr key, cache_val # update cache store << store_val # save value self.misses += 1 # track the cache miss store_val end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def fetch(key, &block)\n store.compute_if_absent(key, &block)\n end", "def do_cached( key, &block )\n \n # have a look in the cache\n value = fetch( key )\n\n # Cache HIT?\n return value unless value.nil?\n\n # Cache MISS : execute the block\n value = block.call( key )\n\n # Store value...
[ "0.68902004", "0.65900046", "0.65330905", "0.6531008", "0.6495434", "0.64840317", "0.6365966", "0.63627434", "0.6342997", "0.6243094", "0.61999434", "0.6132791", "0.6023812", "0.6022675", "0.60095876", "0.600445", "0.5999143", "0.59828645", "0.5979067", "0.59119284", "0.59112...
0.6650979
1
def play until false loop do
def notify_players if board.in_check?(@player.color) puts "#{@player.color} is in Check" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def play\n\t# while $game_end == false\n\t\t9.times { \n\t\t\tif $game_end == false\n\t\t\t\tturns\n\t\t\tend\n\t\t}\nend", "def play\n while true\n speel_game\n break unless speel_opnieuw?\n end\n puts \"Bedankt voor het spelen!\"\nend", "def play\n #turns = 0\n until over?\n turn\n end\nend", ...
[ "0.7760705", "0.7715208", "0.7688533", "0.76789904", "0.7612812", "0.7521134", "0.75184214", "0.7391951", "0.73531836", "0.7338305", "0.7336207", "0.7334072", "0.7314915", "0.72655636", "0.7262928", "0.7254327", "0.72448736", "0.72273165", "0.7197829", "0.719666", "0.7184366"...
0.0
-1
================== sending invoices =============================
def send_invoices change_date @options = session[:invoice_options] || {} [ :s_username, :s_first_name, :s_last_name, :s_number, :s_period_start, :s_period_end, :s_issue_date, :s_sent_email, :s_sent_manually, :s_paid, :s_invoice_type ].each do |key| @options[key] = params[key].try(:to_s).try(:strip) || @options[key].to_s end @invoices = Invoice.for_send(corrected_user_id, @options) MorLog.my_debug("*************Invoice sending, found : #{@invoices.size.to_i}", 1) @number = 0 not_sent = 0 params[:email_or_not] = 1 session[:invoice_options] = @options email_from = Confline.get_value('Email_from', correct_owner_id) if @invoices.size.to_i > 0 @invoices.each { |invoice| user = invoice.user attach = [] params[:id] = invoice.id prepaid = invoice.invoice_type.to_s == 'prepaid' ? 'Prepaid_' : '' @invoice = user.send_invoice_types.to_i if @invoice.to_i != 0 if (user.email).length > 0 @invoice -= if @invoice >= 512 xlsx = { file: export_invoice_to_xlsx, content_type: 'application/octet-stream', filename: "#{_('invoice_xlsx')}.xlsx" } attach << xlsx 512 else 0 end if !(user.postpaid == 0 && invoice.invoicedetails.first.try(:name).to_s == "Manual Payment") if (@invoice % 2) == 1 @invoice = Confline.get_value("#{prepaid}Invoice_default", correct_owner_id).to_i end @invoice -= if @invoice >= 256 calls_cvs = {} calls_cvs[:file] = get_prepaid_user_calls_csv(user, invoice) calls_cvs[:content_type] = 'text/csv' calls_cvs[:filename] = "#{_('Calls')}.csv" attach << calls_cvs 256 else 0 end @invoice -= if @invoice >= 128 csv = {} csv[:file] = generate_invoice_by_cid_csv csv[:content_type] = 'text/csv' csv[:filename] = "#{_('Invoice_by_CallerID_csv')}.csv" attach << csv 128 else 0 end @invoice -= if @invoice >= 64 csv = {} csv[:file] = generates_invoice_destinations_csv unless csv[:file] redirect_to :root unless performed? return false end csv[:content_type] = 'text/csv' csv[:filename] = "#{_('Invoice_destinations_csv')}.csv" attach << csv 64 else 0 end @invoice -= if @invoice >= 32 pdf = {} pdf[:file] = generate_invoice_by_cid_pdf pdf[:content_type] = 'application/pdf' pdf[:filename] = "#{_('Invoice_by_CallerID_pdf')}.pdf" attach << pdf 32 else 0 end @invoice -= if @invoice >= 16 csv = { file: generate_invoice_detailed_csv, content_type: 'text/csv', filename: "#{_('Invoice_detailed_csv')}.csv" } attach << csv 16 else 0 end @invoice -= if @invoice >= 8 pdf = { file: generate_invoice_detailed_pdf, content_type: 'application/pdf', filename: "#{_('Invoice_detailed_pdf')}.pdf" } attach << pdf 8 else 0 end end @invoice -= if @invoice >= 4 csv = { file: generate_invoice_csv, content_type: 'text/csv', filename: "#{_('Invoice_csv')}.csv" } attach << csv 4 else 0 end if @invoice >= 2 pdf = { file: generate_invoice_pdf, content_type: 'application/pdf', filename: "#{_('Invoice_pdf')}.pdf" } attach << pdf end variables = email_variables(user) email= Email.where(["name = 'invoices' AND owner_id = ?", user.owner_id]).first MorLog.my_debug("Try send invoice to : #{user.address.email}, Invoice : #{invoice.id}, User : #{user.id}, Email : #{email.id}", 1) # @num = EmailsController.send_email_with_attachment(email, email_from, # user, attach, variables) variables = Email.email_variables(user) email.body = nice_email_sent(email, variables) @num = EmailsController.send_invoices(email, user.email.to_s, email_from, attach, invoice.number.to_s) MorLog.my_debug ("Invoice email was send to : #{user.address.email} ? : #{@num}") if @num == 'true' @number += 1 invoice.sent_email = 1 invoice.save Action.create_email_sending_action(user, 'email_sent', email) else not_sent += 1 Action.create_email_sending_action(user, 'error', email, {er_type: 1, err_message: @num}) end else not_sent += 1 email= Email.where(["name = 'invoices' AND owner_id = ?", user.owner_id]).first Action.create_email_sending_action(user, 'error', email, {er_type: 1}) end end } end flash[:notice] = _('ERROR') + ': ' + @num[1].to_s if @num && @num[0] == 0 if @number.to_i > 0 flash[:status] = _('Invoices_sent') + ': ' + @number.to_s else flash[:notice] = _('Invoices_not_sent') + ': ' + not_sent.to_s if not_sent.to_i > 0 end flash[:notice] = _('No_invoices_found_in_selected_period') if @invoices.size.to_i == 0 redirect_to(action: :invoices) unless performed? return false end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def invoice\n NotificationsMailer.invoice\n end", "def send_freshbooks_invoice!\n raise SignalCloud::ClientInvoiceNotCreatedError.new unless self.has_invoice?\n \n response = FreshBooks.account.invoice.sendByEmail( invoice_id: self.freshbooks_invoice_id )\n raise SignalCloud::FreshBooksError.new(...
[ "0.7500561", "0.7233134", "0.7184405", "0.7183869", "0.71239305", "0.7119951", "0.70375514", "0.70187014", "0.6966581", "0.6958223", "0.6949742", "0.6936296", "0.6897574", "0.68448067", "0.68393326", "0.6816709", "0.6802644", "0.6801469", "0.6792376", "0.6742171", "0.6741441"...
0.82193315
0
================= generate invoices ===============================
def generate_invoices_status MorLog.my_debug " ********* \n for period #{session_from_date} - #{session_till_date}" change_date MorLog.my_debug "for period #{session_from_date} - #{session_till_date}" unless params[:invoice] dont_be_so_smart redirect_to(:root) && (return false) end owner_id = correct_owner_id if params[:date_issue].present? issue_date = Time.mktime(params[:date_issue][:year], params[:date_issue][:month], params[:date_issue][:day]) end type = %W[postpaid prepaid user].include?(params[:invoice][:type].downcase)? params[:invoice][:type] : 'postpaid' from_time = Time.parse(session_from_datetime_no_timezone) till_time = Time.parse(session_till_datetime_no_timezone) if type == 'user' @user = User.where(['users.id = ?', params[:s_user_id]]).first if params[:s_user_id] unless @user flash[:notice] = _('User_not_found') redirect_to(action: :generate_invoices) && (return false) end valid_period = validate_period_user(@user, till_time) else valid_period = validate_period(type, till_time) end redirect_to(action: :generate_invoices) && (return false) unless valid_period if from_time > till_time flash[:notice] = _('Date_from_greater_thant_date_till') redirect_to(action: :generate_invoices) && (return false) end invoice_type_confline = (type == 'prepaid' && (admin? || accountant?)) ? 'Prepaid_' : '' invoice_number_type = Confline.get_value("#{invoice_type_confline}Invoice_Number_Type", owner_id).to_i unless [1, 2].include?(invoice_number_type) flash[:notice] = _('Please_set_invoice_params') usertype = session[:usertype].to_s unless accountant? if %w(reseller partner).include?(usertype) redirect_to(controller: 'functions', action: "#{usertype}_settings") && (return false) else redirect_to(controller: 'functions', action: 'settings') && (return false) end else redirect_to(action: 'generate_invoices') && (return false) end end BackgroundTask.create( task_id: 5, owner_id: owner_id, created_at: Time.now, status: 'WAITING', user_id: params[:s_user_id].present? ? params[:s_user_id].to_i : -2, data1: session_from_datetime_no_timezone, data2: session_till_datetime_no_timezone, data3: type, data4: issue_date.to_s, data5: params[:currency] ) system("/usr/local/mor/mor_invoices elasticsearch &") flash[:status] = _('bg_task_for_generating_invoice_successfully_created') if admin? redirect_to(controller: 'functions', action: 'background_tasks') && (return false) else redirect_to(action: 'invoices') && (return false) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def generate\n invoices.each do |invoice|\n if date_range.in_range?(invoice.issue_date)\n items << InvoiceItem.new(invoice.customer_id, invoice.issue_date, invoice.total)\n end\n end\n end", "def print_generate_invoices_info\n puts \"\\n==============================2.TEST generateInvo...
[ "0.76258516", "0.75981605", "0.7328746", "0.7234681", "0.723045", "0.72195935", "0.7205239", "0.7142577", "0.71110326", "0.7075352", "0.70709187", "0.6981617", "0.6968688", "0.6959774", "0.6930603", "0.69261795", "0.69030565", "0.6875517", "0.6847351", "0.68450534", "0.675193...
0.0
-1
================================ end of PDF ========================================================================
def generate_invoice_csv if @invoice.is_a?(Fixnum) invoice = Invoice.includes([:tax, :user]).where(id: params[:id]).first else invoice = @invoice end user = invoice.user @invoices_status = user.get_invoices_status status = (@invoices_status[1] == 4) if not_authorized_generate_pdf_or_csv(user, status) == 1 redirect_to :root unless performed? return false end sep, dec = user.csv_params nice_number_hash = {:change_decimal => session[:change_decimal], :global_decimal => session[:global_decimal]} dc, ex = manage_exchange_rates(invoice) csv_string = ["number#{sep}user_id#{sep}period_start#{sep}period_end#{sep}issue_date#{sep}price (#{dc})#{sep}price_with_tax (#{dc})#{sep}accounting_number"] csv_string << "#{invoice.number.to_s}#{sep}" + "#{nice_user(user)}#{sep}" + "#{nice_date(invoice.period_start, 0)}#{sep}" + "#{nice_date(invoice.period_end, 0)}#{sep}" + "#{nice_date(invoice.issue_date)}#{sep}" + "#{invoice.nice_invoice_number(invoice.converted_price(ex), nice_number_hash).to_s.gsub(".", dec).to_s}#{sep}" + "#{invoice.nice_invoice_number(invoice.converted_price_with_vat(ex), nice_number_hash).to_s.gsub(".", dec).to_s}#{sep}" + "#{user.accounting_number}" # my_debug csv_string prepaid, prep = invoice_type(invoice, user) filename = invoice.filename(prep, 'csv', nil, dc) if params[:email_or_not] return csv_string.join("\n") else if params[:test].to_i == 1 render :text => (["Filename: #{filename}"] + csv_string).join("\n") else send_data(csv_string.join("\n"), :type => 'text/csv; charset=utf-8; header=present', :filename => filename) end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def end_document; end", "def end_document; end", "def on_end_document\n end", "def finalize_standard_report\n render_pdf\n end", "def close\n @pdf_doc.close\n @pdf_doc.isClosed\n end", "def flush\n @scrap.start_new_page\n oldy = @scrap.y\n render @scrap\n ...
[ "0.7499543", "0.7499543", "0.71484303", "0.71289474", "0.6847863", "0.6818039", "0.6768234", "0.6695455", "0.66131705", "0.6513222", "0.64334816", "0.6389421", "0.63696873", "0.6354285", "0.63372016", "0.62761074", "0.6250081", "0.62422544", "0.6223955", "0.6174627", "0.61210...
0.0
-1
Based on what params user selected or if they were not passed based on params saved in session return user_id, that should be filtered for financial statements. if user passed clear as param return nil Params +session_options+ hash including :user_id, might be nil Return +user_id+ integer or nil
def financial_statements_user_id(session_options) not_params_clear = !params[:clear] params_user_id, session_user_id = [params[:s_user_id], session_options.try(:[], :s_user_id)] if current_user.usertype == 'user' user_id = current_user_id elsif params_user_id && not_params_clear user_id = params_user_id || 'all' user_id = -1 if params[:s_user].present? && params_user_id.to_i == -2 elsif session_options && session_user_id && not_params_clear user_id = session_user_id else user_id = nil end user_id end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def find_user_id\n if (params[:user_id])\n return params[:user_id].to_i\n else\n return params[:id].to_i\n end\n end", "def extract_user_id(params)\n User.find_by_id(params[:user_id]) || User.find_by_email(params[:email]) || nil\n end", "def get_user_from_session\r\n return User.find(s...
[ "0.6422591", "0.62700105", "0.62198734", "0.6164427", "0.6103503", "0.60974437", "0.6082344", "0.6071978", "0.6061947", "0.60134", "0.60076153", "0.5993115", "0.59782684", "0.59635365", "0.5921999", "0.5921999", "0.58947784", "0.58933336", "0.5872266", "0.58480287", "0.584386...
0.8250601
0