text:
//
//   Copyright 2013 Pixar
//
//   Licensed under the Apache License, Version 2.0 (the "Apache License")
//   with the following modification; you may not use this file except in
//   compliance with the Apache License and the following modification to it:
//   Section 6. Trademarks. is deleted and replaced with:
//
//   6. Trademarks. This License does not grant permission to use the trade
//      names, trademarks, service marks, or product names of the Licensor
//      and its affiliates, except as required to comply with Section 4(c) of
//      the License and to reproduce the content of the NOTICE file.
//
//   You may obtain a copy of the Apache License at
//
//       http://www.apache.org/licenses/LICENSE-2.0
//
//   Unless required by applicable law or agreed to in writing, software
//   distributed under the Apache License with the above modification is
//   distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
//   KIND, either express or implied. See the Apache License for the specific
//   language governing permissions and limitations under the Apache License.
//

#include "../version.h"

#include <stdio.h>
#ifdef _MSC_VER
#define snprintf _snprintf
#endif

#include "../osd/debug.h"
#include "../osd/error.h"
#include "../osd/glslTransformFeedbackKernelBundle.h"
#include "../osd/vertex.h"

#include "../far/subdivisionTables.h"

#include "../osd/opengl.h"

#include <cassert>
#include <string>
#include <sstream>

namespace OpenSubdiv {
namespace OPENSUBDIV_VERSION {

static const char *shaderSource =
#include "../osd/glslTransformFeedbackKernel.gen.h"
;

static const char *shaderDefines = ""
#ifdef OPT_CATMARK_V_IT_VEC2
"#define OPT_CATMARK_V_IT_VEC2\n"
#endif
#ifdef OPT_E0_IT_VEC4
"#define OPT_E0_IT_VEC4\n"
#endif
#ifdef OPT_E0_S_VEC2
"#define OPT_E0_S_VEC2\n"
#endif
;

OsdGLSLTransformFeedbackKernelBundle::OsdGLSLTransformFeedbackKernelBundle()
    : _program(0),
      _numVertexElements(0),
      _vertexStride(0),
      _numVaryingElements(0),
      _varyingStride(0),
      _interleaved(false) {
}

OsdGLSLTransformFeedbackKernelBundle::~OsdGLSLTransformFeedbackKernelBundle() {
    if (_program)
        glDeleteProgram(_program);
}

bool
OsdGLSLTransformFeedbackKernelBundle::Compile(
    OsdVertexBufferDescriptor const &vertexDesc,
    OsdVertexBufferDescriptor const &varyingDesc,
    bool interleaved) {

    _numVertexElements = vertexDesc.length;
    _vertexStride = vertexDesc.stride;
    _numVaryingElements = varyingDesc.length;
    _varyingStride = varyingDesc.stride;
    _interleaved = interleaved;

    // modulo of vbo offset
    _vertexOffsetMod = (_vertexStride ? vertexDesc.offset % _vertexStride : 0);
    _varyingOffsetMod = (_varyingStride ? varyingDesc.offset % _varyingStride : 0);

    _program = glCreateProgram();

    GLuint shader = glCreateShader(GL_VERTEX_SHADER);

    std::ostringstream defines;
    defines << "#define NUM_VERTEX_ELEMENTS "  << _numVertexElements << "\n"
            << "#define VERTEX_STRIDE "        << _vertexStride << "\n"
            << "#define NUM_VARYING_ELEMENTS " << _numVaryingElements << "\n"
            << "#define VARYING_STRIDE "       << _varyingStride << "\n";
    std::string defineStr = defines.str();

    const char *shaderSources[3];
    shaderSources[0] = defineStr.c_str();
    shaderSources[1] = shaderDefines;
    shaderSources[2] = shaderSource;
    glShaderSource(shader, 3, shaderSources, NULL);
    glCompileShader(shader);
    glAttachShader(_program, shader);

    std::vector<std::string> outputs;

    /*
      output attribute array

      - interleaved
      outVertexData[0]
      outVertexData[1]
      outVertexData[2]
      (gl_SkipComponents1)
      outVaryingData[0]
      outVaryingData[1]
      outVaryingData[2]
      outVaryingData[3]
      (gl_SkipComponents1)
      ...

      - non-interleaved
      outVertexData[0]
      outVertexData[1]
      outVertexData[2]
      gl_NextBuffer
      outVaryingData[0]
      outVaryingData[1]
      outVaryingData[2]
      outVaryingData[3]

     */

    if (_interleaved) {
        assert(_vertexStride == _varyingStride);
        assert(_numVertexElements + _numVaryingElements <= _vertexStride);
        char attrName[32];

        for (int i = 0; i < _vertexStride; ++i) {
            int vertexElem = i - _vertexOffsetMod;
            int varyingElem = i - _varyingOffsetMod;

            if (vertexElem >= 0 and vertexElem < _numVertexElements) {
                snprintf(attrName, 32, "outVertexData[%d]", vertexElem);
                outputs.push_back(attrName);
            } else if (varyingElem >= 0 and varyingElem <= _numVaryingElements) {
                snprintf(attrName, 32, "outVaryingData[%d]", varyingElem);
                outputs.push_back(attrName);
            } else {
                outputs.push_back("gl_SkipComponents1");
            }
        }
    } else {
        // non-interleaved
        char attrName[32];

        // vertex data (may include custom vertex data) and varying data
        // are stored into the same buffer, interleaved.
        for (int i = 0; i < _vertexOffsetMod; ++i)
            outputs.push_back("gl_SkipComponents1");
        for (int i = 0; i < _numVertexElements; ++i) {
            snprintf(attrName, 32, "outVertexData[%d]", i);
            outputs.push_back(attrName);
        }
        for (int i = _numVertexElements + _vertexOffsetMod; i < _vertexStride; ++i)
            outputs.push_back("gl_SkipComponents1");

        // varying
        if (_numVaryingElements) {
            outputs.push_back("gl_NextBuffer");
        }
        for (int i = 0; i < _varyingOffsetMod; ++i) {
            outputs.push_back("gl_SkipComponents1");
        }
        for (int i = 0; i < _numVaryingElements; ++i) {
            snprintf(attrName, 32, "outVaryingData[%d]", i);
            outputs.push_back(attrName);
        }
        for (int i = _numVaryingElements + _varyingOffsetMod; i < _varyingStride; ++i) {
            outputs.push_back("gl_SkipComponents1");
        }
    }

    // convert to char* array
    std::vector<const char *> pOutputs;
    for (size_t i = 0; i < outputs.size(); ++i) {
        pOutputs.push_back(&outputs[i][0]);
    }

    glTransformFeedbackVaryings(_program, (GLsizei)outputs.size(),
                                &pOutputs[0], GL_INTERLEAVED_ATTRIBS);

    OSD_DEBUG_CHECK_GL_ERROR("Transform feedback initialize\n");

    GLint linked = 0;
    glLinkProgram(_program);
    glGetProgramiv(_program, GL_LINK_STATUS, &linked);

    if (linked == GL_FALSE) {
        char buffer[1024];
        glGetShaderInfoLog(shader, 1024, NULL, buffer);
        OsdError(OSD_GLSL_LINK_ERROR, buffer);

        glGetProgramInfoLog(_program, 1024, NULL, buffer);
        OsdError(OSD_GLSL_LINK_ERROR, buffer);

        glDeleteProgram(_program);
        _program = 0;
        // XXX ERROR HANDLE
        return false;
    }

    glDeleteShader(shader);

    _uniformVertexBuffer         = glGetUniformLocation(_program, "vertexData");
    _uniformVaryingBuffer        = glGetUniformLocation(_program, "varyingData");

    _subComputeFace = glGetSubroutineIndex(_program, GL_VERTEX_SHADER, "catmarkComputeFace");
    _subComputeQuadFace = glGetSubroutineIndex(_program, GL_VERTEX_SHADER, "catmarkComputeQuadFace");
    _subComputeTriQuadFace = glGetSubroutineIndex(_program, GL_VERTEX_SHADER, "catmarkComputeTriQuadFace");
    _subComputeEdge = glGetSubroutineIndex(_program, GL_VERTEX_SHADER, "catmarkComputeEdge");
    _subComputeBilinearEdge = glGetSubroutineIndex(_program, GL_VERTEX_SHADER, "bilinearComputeEdge");
    _subComputeVertex = glGetSubroutineIndex(_program, GL_VERTEX_SHADER, "bilinearComputeVertex");
    _subComputeVertexA = glGetSubroutineIndex(_program, GL_VERTEX_SHADER, "catmarkComputeVertexA");
    _subComputeCatmarkVertexB = glGetSubroutineIndex(_program, GL_VERTEX_SHADER, "catmarkComputeVertexB");
    _subComputeLoopVertexB = glGetSubroutineIndex(_program, GL_VERTEX_SHADER, "loopComputeVertexB");

    _uniformVertexPass   = glGetUniformLocation(_program, "vertexPass");
    _uniformVertexOffset = glGetUniformLocation(_program, "vertexOffset");
    _uniformTableOffset  = glGetUniformLocation(_program, "tableOffset");
    _uniformIndexStart   = glGetUniformLocation(_program, "indexStart");
    _uniformVertexBaseOffset  = glGetUniformLocation(_program, "vertexBaseOffset");
    _uniformVaryingBaseOffset = glGetUniformLocation(_program, "varyingBaseOffset");

    _uniformTables[FarSubdivisionTables::F_IT]  = glGetUniformLocation(_program, "_F0_IT");
    _uniformTables[FarSubdivisionTables::F_ITa] = glGetUniformLocation(_program, "_F0_ITa");
    _uniformTables[FarSubdivisionTables::E_IT]  = glGetUniformLocation(_program, "_E0_IT");
    _uniformTables[FarSubdivisionTables::V_IT]  = glGetUniformLocation(_program, "_V0_IT");
    _uniformTables[FarSubdivisionTables::V_ITa] = glGetUniformLocation(_program, "_V0_ITa");
    _uniformTables[FarSubdivisionTables::E_W]   = glGetUniformLocation(_program, "_E0_S");
    _uniformTables[FarSubdivisionTables::V_W]   = glGetUniformLocation(_program, "_V0_S");

    // set unfiorm locations for edit
    _subEditAdd               = glGetSubroutineIndex(_program,
                                                     GL_VERTEX_SHADER, "editAdd");

    _uniformEditPrimVarOffset = glGetUniformLocation(_program, "editPrimVarOffset");
    _uniformEditPrimVarWidth  = glGetUniformLocation(_program, "editPrimVarWidth");

    _uniformEditIndices       = glGetUniformLocation(_program, "_editIndices");
    _uniformEditValues        = glGetUniformLocation(_program, "_editValues");
    _uniformVertexBufferImage = glGetUniformLocation(_program, "_vertexBufferImage");

    return true;
}

void
OsdGLSLTransformFeedbackKernelBundle::transformGpuBufferData(
    GLuint vertexBuffer, GLuint varyingBuffer,
    int vertexOffset, int varyingOffset,
    int offset, int tableOffset, int start, int end) const {

    int count = end - start;
    if (count <= 0) return;

    // set batch range
    glUniform1i(_uniformIndexStart, start);
    glUniform1i(_uniformVertexOffset, offset);
    glUniform1i(_uniformTableOffset, tableOffset);

    // XXX: end is not used here now
    OSD_DEBUG_CHECK_GL_ERROR("Uniform index set at offset=%d. start=%d\n",
                             offset, start);

    int vertexOrigin = vertexOffset - _vertexOffsetMod;
    int varyingOrigin = varyingOffset - _varyingOffsetMod;

    // set transform feedback buffer
    if (_interleaved) {
        int vertexStride = _vertexStride*sizeof(float);
        glBindBufferRange(GL_TRANSFORM_FEEDBACK_BUFFER, 0, vertexBuffer,
                          (start + offset)*vertexStride + vertexOrigin*sizeof(float),
                          count*vertexStride);
    } else {
        if (vertexBuffer) {
            int vertexStride = _vertexStride*sizeof(float);
            glBindBufferRange(GL_TRANSFORM_FEEDBACK_BUFFER, 0, vertexBuffer,
                              (start + offset)*vertexStride + vertexOrigin*sizeof(float),
                              count*vertexStride);
        }
        if (varyingBuffer){
            int varyingStride = _varyingStride*sizeof(float);
            glBindBufferRange(GL_TRANSFORM_FEEDBACK_BUFFER, 1, varyingBuffer,
                              (start + offset)*varyingStride + varyingOrigin*sizeof(float),
                              count*varyingStride);
        }
    }

    OSD_DEBUG_CHECK_GL_ERROR("transformGpuBufferData glBindBufferRange\n");

    glBeginTransformFeedback(GL_POINTS);

    OSD_DEBUG_CHECK_GL_ERROR("transformGpuBufferData glBeginTransformFeedback\n");

    // draw array -----------------------------------------
    glDrawArrays(GL_POINTS, 0, count);

    OSD_DEBUG_CHECK_GL_ERROR("transformGpuBufferData DrawArray (%d)\n", count);

    glEndTransformFeedback();
    glBindBuffer(GL_TRANSFORM_FEEDBACK_BUFFER, 0);
}

void
OsdGLSLTransformFeedbackKernelBundle::ApplyBilinearFaceVerticesKernel(
    GLuint vertexBuffer, GLuint varyingBuffer,
    int vertexOffset, int varyingOffset,
    int offset, int tableOffset, int start, int end) {

    glUniformSubroutinesuiv(GL_VERTEX_SHADER, 1, &_subComputeFace);
    transformGpuBufferData(vertexBuffer, varyingBuffer,
                           vertexOffset, varyingOffset,
                           offset, tableOffset, start, end);
}

void
OsdGLSLTransformFeedbackKernelBundle::ApplyBilinearEdgeVerticesKernel(
    GLuint vertexBuffer, GLuint varyingBuffer,
    int vertexOffset, int varyingOffset,
    int offset, int tableOffset, int start, int end) {

    glUniformSubroutinesuiv(GL_VERTEX_SHADER, 1, &_subComputeBilinearEdge);
    transformGpuBufferData(vertexBuffer, varyingBuffer,
                           vertexOffset, varyingOffset,
                           offset, tableOffset, start, end);
}

void
OsdGLSLTransformFeedbackKernelBundle::ApplyBilinearVertexVerticesKernel(
    GLuint vertexBuffer, GLuint varyingBuffer,
    int vertexOffset, int varyingOffset,
    int offset, int tableOffset, int start, int end) {

    glUniformSubroutinesuiv(GL_VERTEX_SHADER, 1, &_subComputeVertex);
    transformGpuBufferData(vertexBuffer, varyingBuffer,
                           vertexOffset, varyingOffset,
                           offset, tableOffset, start, end);
}

void
OsdGLSLTransformFeedbackKernelBundle::ApplyCatmarkQuadFaceVerticesKernel(
    GLuint vertexBuffer, GLuint varyingBuffer,
    int vertexOffset, int varyingOffset,
    int offset, int tableOffset, int start, int end) {

    glUniformSubroutinesuiv(GL_VERTEX_SHADER, 1, &_subComputeQuadFace);
    transformGpuBufferData(vertexBuffer, varyingBuffer,
                           vertexOffset, varyingOffset,
                           offset, tableOffset, start, end);
}

void
OsdGLSLTransformFeedbackKernelBundle::ApplyCatmarkTriQuadFaceVerticesKernel(
    GLuint vertexBuffer, GLuint varyingBuffer,
    int vertexOffset, int varyingOffset,
    int offset, int tableOffset, int start, int end) {

    glUniformSubroutinesuiv(GL_VERTEX_SHADER, 1, &_subComputeTriQuadFace);
    transformGpuBufferData(vertexBuffer, varyingBuffer,
                           vertexOffset, varyingOffset,
                           offset, tableOffset, start, end);
}

void
OsdGLSLTransformFeedbackKernelBundle::ApplyCatmarkFaceVerticesKernel(
    GLuint vertexBuffer, GLuint varyingBuffer,
    int vertexOffset, int varyingOffset,
    int offset, int tableOffset, int start, int end) {

    glUniformSubroutinesuiv(GL_VERTEX_SHADER, 1, &_subComputeFace);
    transformGpuBufferData(vertexBuffer, varyingBuffer,
                           vertexOffset, varyingOffset,
                           offset, tableOffset, start, end);
}

void
OsdGLSLTransformFeedbackKernelBundle::ApplyCatmarkEdgeVerticesKernel(
    GLuint vertexBuffer, GLuint varyingBuffer,
    int vertexOffset, int varyingOffset,
    int offset, int tableOffset, int start, int end) {

    glUniformSubroutinesuiv(GL_VERTEX_SHADER, 1, &_subComputeEdge);
    transformGpuBufferData(vertexBuffer, varyingBuffer,
                           vertexOffset, varyingOffset,
                           offset, tableOffset, start, end);
}

void
OsdGLSLTransformFeedbackKernelBundle::ApplyCatmarkVertexVerticesKernelB(
    GLuint vertexBuffer, GLuint varyingBuffer,
    int vertexOffset, int varyingOffset,
    int offset, int tableOffset, int start, int end) {

    glUniformSubroutinesuiv(GL_VERTEX_SHADER, 1, &_subComputeCatmarkVertexB);
    transformGpuBufferData(vertexBuffer, varyingBuffer,
                           vertexOffset, varyingOffset,
                           offset, tableOffset, start, end);
}

void
OsdGLSLTransformFeedbackKernelBundle::ApplyCatmarkVertexVerticesKernelA(
    GLuint vertexBuffer, GLuint varyingBuffer,
    int vertexOffset, int varyingOffset,
    int offset, int tableOffset, int start, int end, bool pass) {

    glUniformSubroutinesuiv(GL_VERTEX_SHADER, 1, &_subComputeVertexA);
    glUniform1i(_uniformVertexPass, pass ? 1 : 0);
    transformGpuBufferData(vertexBuffer, varyingBuffer,
                           vertexOffset, varyingOffset,
                           offset, tableOffset, start, end);
}

void
OsdGLSLTransformFeedbackKernelBundle::ApplyLoopEdgeVerticesKernel(
    GLuint vertexBuffer, GLuint varyingBuffer,
    int vertexOffset, int varyingOffset,
    int offset, int tableOffset, int start, int end) {

    glUniformSubroutinesuiv(GL_VERTEX_SHADER, 1, &_subComputeEdge);
    transformGpuBufferData(vertexBuffer, varyingBuffer,
                           vertexOffset, varyingOffset,
                           offset, tableOffset, start, end);
}

void
OsdGLSLTransformFeedbackKernelBundle::ApplyLoopVertexVerticesKernelB(
    GLuint vertexBuffer, GLuint varyingBuffer,
    int vertexOffset, int varyingOffset,
    int offset, int tableOffset, int start, int end) {

    glUniformSubroutinesuiv(GL_VERTEX_SHADER, 1, &_subComputeLoopVertexB);
    transformGpuBufferData(vertexBuffer, varyingBuffer,
                           vertexOffset, varyingOffset,
                           offset, tableOffset, start, end);
}

void
OsdGLSLTransformFeedbackKernelBundle::ApplyLoopVertexVerticesKernelA(
    GLuint vertexBuffer, GLuint varyingBuffer,
    int vertexOffset, int varyingOffset,
    int offset, int tableOffset, int start, int end, bool pass) {

    glUniformSubroutinesuiv(GL_VERTEX_SHADER, 1, &_subComputeVertexA);
    glUniform1i(_uniformVertexPass, pass ? 1 : 0);
    transformGpuBufferData(vertexBuffer, varyingBuffer,
                           vertexOffset, varyingOffset,
                           offset, tableOffset, start, end);
}

void
OsdGLSLTransformFeedbackKernelBundle::ApplyEditAdd(
    GLuint /* vertexBuffer */, GLuint /* varyingBuffer */,
    int /* vertexOffset */, int /* varyingOffset */,
    int primvarOffset, int primvarWidth,
    int offset, int tableOffset, int start, int end) {

    if (end - start <= 0) return;
    glUniformSubroutinesuiv(GL_VERTEX_SHADER, 1, &_subEditAdd);
    glUniform1i(_uniformEditPrimVarOffset, primvarOffset);
    glUniform1i(_uniformEditPrimVarWidth, primvarWidth);

    glUniform1i(_uniformIndexStart, start);
    glUniform1i(_uniformVertexOffset, offset);
    glUniform1i(_uniformTableOffset, tableOffset);
    glDrawArrays(GL_POINTS, 0, end - start);
}

void
OsdGLSLTransformFeedbackKernelBundle::UseProgram(int vertexBaseOffset,
                                                 int varyingBaseOffset) const
{
    glUseProgram(_program);

    glUniform1i(_uniformVertexBaseOffset, vertexBaseOffset);
    glUniform1i(_uniformVaryingBaseOffset, varyingBaseOffset);
}

}  // end namespace OPENSUBDIV_VERSION
}  // end namespace OpenSubdiv


text:
require 'json'

module Graphite
  class Graph < Graphite::Base
    attr_accessor :name,:id,:allow_children,:leaf,:url

    def self.find_by_query_and_path(query,path)
      graph_type = "#{self}" == "Graphite::MyGraph" ? "mygraph" : "usergraph"
      return JSON.parse(self.get("/browser/#{graph_type}/",{:format => "treejson",:query => query,:path =>path}).body).map do |graphic_hash|
        graphic = MyGraph.new
        graphic.url            = graphic_hash["graphUrl"]
        graphic.name           = graphic_hash["id"]
        graphic.leaf           = graphic_hash["leaf"] == 1
        graphic.allow_children = graphic_hash["allowChildren"] == 1
        graphic
      end
    end

    def self.descend_to_leaf(query,path)
      result = []
      self.find_by_query_and_path(query,path).each do |graph|
        if graph.leaf
          return graph
        else
          result << self.descend_to_leaf(graph.name + "*",graph.name)
        end
      end
      return result
    end

    def self.find_all_by_query(query)
      result = []
      self.find_by_query_and_path(query,"").each do |graph|
        result << self.descend_to_leaf(graph.name + "*",graph.name)
      end
      return result.flatten
    end
  end
end

redpajama_set_name: RedPajamaGithub


text:
require "rubygems"
require "bundler/setup"

$:.push File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib'))
require "share_checker"

# Load support files
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }

RSpec.configure do |config|
  # Remove this line if you don't want RSpec's should and should_not
  # methods or matchers
  require 'rspec/expectations'
  config.include RSpec::Matchers

  # == Mock Framework
  config.mock_with :rspec
end


text:
layout: post
title: Lær Noget Nyt
date: '2013-09-27 16:45:33'
---
Jeg har en baggrund som C# backend developer og har et stykke tid haft lyst til at få et indblik i moderne open source webudvikling. Dette blog indlæg er det første i en serie af indlæg hvor fokus vil være at lære noget nyt. Det er mit håb, at det bliver et længerevarende projekt med undertitlen "Lær noget nyt".

<!--more-->

Første del af serien vil være om moderne webudvikling. Mere specifikt om en web applikation skrevet 100% i Javascript for både server og klient. Server-delen vil være baseret på Node.js mens klient-delen bliver et MVC framework som fx Angular.js.

For at få en smule struktur på projekterne vil jeg bruge disse retningslinier:

* 'Lær noget nyt' projekterne skal ikke opfattes som 'best practice' eller produktionskode. Fokus er på at få indblik i for mig nye teknologier, programmeringssprog, værktøjer m.v.
* Når man taler webudvikling kommer man ikke uden om UI men forvent ikke gennemarbejdede UI designs.
* Dette er et 'Do it yourself' projekt, og jeg kommer derfor til at begå fejl og/eller bevæge mig i den forkerte retning. Hvis du som læser bemærker dette og har viden på området, så hører jeg meget gerne fra dig med konstruktion kritik.
* Blog indlæg vil __IKKE__ være 'yet another tutorial' men vil mere blive brugt til at dokumentere en læringsproces.
* Source koden til projekter findes på GitHub.
* Jeg skriver for mig selv til mig selv. Men alle er naturligvis velkommen til at læse med og give feedback.


text:
package dk.javacode.srsm.testmodel;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import dk.javacode.srsm.annotations.Column;
import dk.javacode.srsm.annotations.Table;
import dk.javacode.srsm.converters.BooleanCharJdbcConverter;

@Table(name = "persons")
public class Person implements Serializable {

	/**
	 *
	 */
	private static final long serialVersionUID = 2L;

	@Column(primaryKey = true, name = "id")
	private Integer id;

	@Column(name = "name")
	private String name;

	@Column(name = "age", dataConverter = NumberJdbcConverter.class)
	private int age;

	@Column(name = "smoker", dataConverter = BooleanCharJdbcConverter.class)
	private boolean smoker;

	private String randomProperty;

	@Column(name = "address_id", fieldReference = "id2")
	private Address address;

	@Column(name = "car_person_id", columnReference = "person_id", collection = true, collectionType = Car.class)
	private List<Car> cars = new ArrayList<Car>();

	public Person() {
		super();
	}

	public Person(String name, int age) {
		super();
		this.name = name;
		this.age = age;
	}

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public Address getAddress() {
		return address;
	}

	public void setAddress(Address address) {
		this.address = address;
	}

	public int getAge() {
		return age;
	}

	public String getName() {
		return name;
	}

	public void setAge(int age) {
		this.age = age;
	}

	public void setName(String name) {
		this.name = name;
	}

	public List<Car> getCars() {
		return cars;
	}

	public void setCars(List<Car> cars) {
		this.cars = cars;
	}

	public void addCar(Car c) {
		this.cars.add(c);
	}

	public boolean isSmoker() {
		return smoker;
	}

	public void setSmoker(boolean smoker) {
		this.smoker = smoker;
	}

	public String getRandomProperty() {
		return randomProperty;
	}

	public void setRandomProperty(String randomProperty) {
		this.randomProperty = randomProperty;
	}

	@Override
	public String toString() {
		return "Person [id=" + id + ", name=" + name + ", age=" + age + ", smoker=" + smoker + ", address=" + address
				+ ", cars=" + cars + "]";
	}

}


text:
var app = app || {};

// var classProfileView = Backbone.View.extend({
// render: function() {
// },
// initialize: function() {
// },
// events: {
// }
// });

//saved for future update


text:
module.exports = function(grunt) {

	// Define project configuration
	var project = {
		paths: {
			get config() {
				return this.grunt + 'config/';
			},
			dist: 'dist/',
			doc: 'doc/',
			grunt: 'grunt/',
			js: 'js/',
			scss: 'scss/',
			assets: 'assets/',
			vendor: grunt.file.readJSON('.bowerrc').directory + '/'
		},
		files: {
			get config() {
				return project.paths.config + '*.js';
			},
			grunt: 'Gruntfile.js',
			js: ['js/*.js'],
			scss: ['scss/nodes.scss']
		},
		pkg: grunt.file.readJSON('package.json')
	};

	// Load Grunt configurations and tasks
	require('load-grunt-config')(grunt, {
		configPath: require('path').join(process.cwd(), project.paths.config),
		data: project,
		jitGrunt: {
			staticMappings: {
				useminPrepare: 'grunt-usemin'
			}
		}
	});

};


text:
package org.neo4j.cypher.internal.helpers

/**
 * Subclasses prefer to use StringBuilders to render themselves
 */
// TODO: This is only here for accomodating cypher-compiler-1.9. Do not touch, do not import, purge it with fire post 2.3
trait StringRenderingSupport {
  override def toString = {
    val builder = new StringBuilder
    render(builder)
    builder.toString()
  }

  def render(builder: StringBuilder) {
    builder ++= super.toString
  }
}


text:
package main

import (
	"context"
	"flag"
	"fmt"
	"net/http"
	"os"
	"os/signal"
	"strconv"
	"syscall"
	"time"

	"github.com/spf13/cobra"
	"github.com/spf13/pflag"
	"k8s.io/klog/v2"
	"sigs.k8s.io/apiserver-network-proxy/pkg/util"
)

func main() {
	testServer := &TestServer{}
	o := newTestServerRunOptions()
	command := newTestServerCommand(testServer, o)
	flags := command.Flags()
	flags.AddFlagSet(o.Flags())
	local := flag.NewFlagSet(os.Args[0], flag.ExitOnError)
	klog.InitFlags(local)
	local.VisitAll(func(fl *flag.Flag) {
		fl.Name = util.Normalize(fl.Name)
		flags.AddGoFlag(fl)
	})
	if err := command.Execute(); err != nil {
		klog.Errorf("error: %v\n", err)
		klog.Flush()
		os.Exit(1)
	}
}

type TestServerRunOptions struct {
	// Port we listen for server connections on.
	serverPort uint
}

func (o *TestServerRunOptions) Flags() *pflag.FlagSet {
	flags := pflag.NewFlagSet("proxy-server", pflag.ContinueOnError)
	flags.UintVar(&o.serverPort, "server-port", o.serverPort, "Port we listen for server connections on. Set to 0 for UDS.")
	return flags
}

func (o *TestServerRunOptions) Print() {
	klog.Warningf("Server port set to %d.\n", o.serverPort)
}

func (o *TestServerRunOptions) Validate() error {
	if o.serverPort > 49151 {
		return fmt.Errorf("please do not try to use ephemeral port %d for the server port", o.serverPort)
	}
	if o.serverPort < 1024 {
		return fmt.Errorf("please do not try to use reserved port %d for the server port", o.serverPort)
	}

	return nil
}

func newTestServerRunOptions() *TestServerRunOptions {
	o := TestServerRunOptions{
		serverPort: 8000,
	}
	return &o
}

func newTestServerCommand(p *TestServer, o *TestServerRunOptions) *cobra.Command {
	cmd := &cobra.Command{
		Use:  "test http server",
		Long: `A test http server, url determines behavior for certain tests.`,
		RunE: func(cmd *cobra.Command, args []string) error {
			return p.run(o)
		},
	}

	return cmd
}

type TestServer struct {
}

type StopFunc func()

func (p *TestServer) run(o *TestServerRunOptions) error {
	o.Print()
	if err := o.Validate(); err != nil {
		return fmt.Errorf("failed to validate server options with %v", err)
	}
	ctx, cancel := context.WithCancel(context.Background())
	defer cancel()

	klog.Info("Starting test http server for client requests.")
	testStop, err := p.runTestServer(ctx, o)
	if err != nil {
		return fmt.Errorf("failed to run the test server: %v", err)
	}

	stopCh := SetupSignalHandler()
	<-stopCh
	klog.Info("Shutting down server.")

	if testStop != nil {
		testStop()
	}

	return nil
}

var shutdownSignals = []os.Signal{os.Interrupt, syscall.SIGTERM}

func SetupSignalHandler() (stopCh <-chan struct{}) {
	stop := make(chan struct{})
	c := make(chan os.Signal, 2)
	signal.Notify(c, shutdownSignals...)
	go func() {
		<-c
		close(stop)
		<-c
		os.Exit(1) // second signal. Exit directly.
	}()

	return stop
}

func returnSuccess(w http.ResponseWriter, req *http.Request) {
	fmt.Fprintf(w, "<!DOCTYPE html>\n\n    \n        <title>Success</title>\n    \n    \n
The success test page!
\n    \n")
}

func returnError(w http.ResponseWriter, req *http.Request) {
	http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
}

func closeNoResponse(w http.ResponseWriter, req *http.Request) {
	hj, ok := w.(http.Hijacker)
	if !ok {
		http.Error(w, "webserver doesn't support hijacking", http.StatusInternalServerError)
		return
	}
	conn, _, err := hj.Hijack()
	if err != nil {
		http.Error(w, err.Error(), http.StatusInternalServerError)
		return
	}
	err = conn.Close()
	if err != nil {
		klog.ErrorS(err, "failed to close connection")
	}
}

func sleepReturnSuccess(w http.ResponseWriter, req *http.Request) {
	sleepArr := req.URL.Query()["time"]
	sleepInt := 10
	var err error
	if len(sleepArr) == 1 {
		sleepStr := sleepArr[0]
		sleepInt, err = strconv.Atoi(sleepStr)
		if err != nil {
			sleepInt = 10
			klog.Warningf("Failed to parse sleep time (%s), default to %d, got error %v.", sleepStr, sleepInt, err)
		}
	} else {
		klog.Warningf("Sleep time(%v) was length %d defaulting to sleep %d.", sleepArr, len(sleepArr), sleepInt)
	}
	sleep := time.Duration(sleepInt) * time.Second
	time.Sleep(sleep)
	returnSuccess(w, req)
}

func (p *TestServer) runTestServer(ctx context.Context, o *TestServerRunOptions) (StopFunc, error) {
	muxHandler := http.NewServeMux()
	muxHandler.HandleFunc("/success", returnSuccess)
	muxHandler.HandleFunc("/sleep", sleepReturnSuccess)
	muxHandler.HandleFunc("/error", returnError)
	muxHandler.HandleFunc("/close", closeNoResponse)
	server := &http.Server{
		Addr:              fmt.Sprintf("127.0.0.1:%d", o.serverPort),
		Handler:           muxHandler,
		MaxHeaderBytes:    1 << 20,
		ReadHeaderTimeout: 60 * time.Second,
	}

	go func() {
		err := server.ListenAndServe()
		if err != nil {
			klog.Warningf("HTTP test server received %v.\n", err)
		}
		klog.Warningf("HTTP test server stopped listening\n")
	}()

	stop := func() {
		err := server.Shutdown(ctx)
		if err != nil {
			klog.ErrorS(err, "failed to shutdown server")
		}
	}
	return stop, nil
}