text:
layout: page
title: "JavaScript rad2deg function"
comments: true
sharing: true
footer: true
alias:
- /functions/view/rad2deg:497
- /functions/view/rad2deg
- /functions/view/497
- /functions/rad2deg:497
- /functions/497
---
<!-- Generated by Rakefile:build -->
A JavaScript equivalent of PHP's rad2deg

{% codeblock math/rad2deg.js lang:js https://raw.github.com/kvz/phpjs/master/functions/math/rad2deg.js raw on github %}
function rad2deg (angle) {
  // From: http://phpjs.org/functions
  // +   original by: Enrique Gonzalez
  // +      improved by: Brett Zamir (http://brett-zamir.me)
  // *     example 1: rad2deg(3.141592653589793);
  // *     returns 1: 180
  return angle * 57.29577951308232; // angle / Math.PI * 180
}
{% endcodeblock %}

 - [Raw function on GitHub](https://github.com/kvz/phpjs/blob/master/functions/math/rad2deg.js)

Please note that php.js uses JavaScript objects as substitutes for PHP arrays, they are
the closest match to this hashtable-like data structure.

Please also note that php.js offers community built functions and goes by the
[McDonald's Theory](https://medium.com/what-i-learned-building/9216e1c9da7d). We'll put online
functions that are far from perfect, in the hopes to spark better contributions.
Do you have one? Then please just:

 - [Edit on GitHub](https://github.com/kvz/phpjs/edit/master/functions/math/rad2deg.js)

### Example 1
This code
{% codeblock lang:js example %}
rad2deg(3.141592653589793);
{% endcodeblock %}

Should return
{% codeblock lang:js returns %}
180
{% endcodeblock %}

### Other PHP functions in the math extension
{% render_partial _includes/custom/math.html %}


text:
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package javarmi.servidor;
import java.rmi.Remote;
import java.rmi.RemoteException;
/**
 *
 * @author waflessnet
 */
public interface InterfazRemota extends Remote {
  public String[]  obtenerArrString() throws RemoteException;
  public String  obtenerHash() throws RemoteException;
  public void  resultado(String r) throws RemoteException;
  public boolean recorrer() throws RemoteException;
}

redpajama_set_name: RedPajamaGithub


text:
// independent from idl_parser, since this code is not needed for most clients

#include <string>
#include <unordered_set>

#include "flatbuffers/code_generators.h"
#include "flatbuffers/flatbuffers.h"
#include "flatbuffers/idl.h"
#include "flatbuffers/util.h"

namespace flatbuffers {
namespace lua {

// Hardcode spaces per indentation.
const CommentConfig def_comment = { nullptr, "--", nullptr };
const char *Indent = "    ";
const char *Comment = "-- ";
const char *End = "end\n";
const char *EndFunc = "end\n";
const char *SelfData = "self.view";
const char *SelfDataPos = "self.view.pos";
const char *SelfDataBytes = "self.view.bytes";

class LuaGenerator : public BaseGenerator {
 public:
  LuaGenerator(const Parser &parser, const std::string &path,
               const std::string &file_name)
      : BaseGenerator(parser, path, file_name, "" /* not used */,
                      "" /* not used */, "lua") {
    static const char *const keywords[] = {
      "and",      "break",  "do",   "else", "elseif", "end",  "false", "for",
      "function", "goto",   "if",   "in",   "local",  "nil",  "not",   "or",
      "repeat",   "return", "then", "true", "until",  "while"
    };
    keywords_.insert(std::begin(keywords), std::end(keywords));
  }

  // Most field accessors need to retrieve and test the field offset first,
  // this is the prefix code for that.
  std::string OffsetPrefix(const FieldDef &field) {
    return std::string(Indent) + "local o = " + SelfData + ":Offset(" +
           NumToString(field.value.offset) + ")\n" + Indent +
           "if o ~= 0 then\n";
  }

  // Begin a class declaration.
  void BeginClass(const StructDef &struct_def, std::string *code_ptr) {
    std::string &code = *code_ptr;
    code += "local " + NormalizedName(struct_def) + " = {} -- the module\n";
    code += "local " + NormalizedMetaName(struct_def) +
            " = {} -- the class metatable\n";
    code += "\n";
  }

  // Begin enum code with a class declaration.
  void BeginEnum(const std::string &class_name, std::string *code_ptr) {
    std::string &code = *code_ptr;
    code += "local " + class_name + " = {\n";
  }

  std::string EscapeKeyword(const std::string &name) const {
    return keywords_.find(name) == keywords_.end() ? name : "_" + name;
  }

  std::string NormalizedName(const Definition &definition) const {
    return EscapeKeyword(definition.name);
  }

  std::string NormalizedName(const EnumVal &ev) const {
    return EscapeKeyword(ev.name);
  }

  std::string NormalizedMetaName(const Definition &definition) const {
    return EscapeKeyword(definition.name) + "_mt";
  }

  // A single enum member.
  void EnumMember(const EnumDef &enum_def, const EnumVal &ev,
                  std::string *code_ptr) {
    std::string &code = *code_ptr;
    code += std::string(Indent) + NormalizedName(ev) + " = " +
            enum_def.ToString(ev) + ",\n";
  }

  // End enum code.
  void EndEnum(std::string *code_ptr) {
    std::string &code = *code_ptr;
    code += "}\n";
  }

  void GenerateNewObjectPrototype(const StructDef &struct_def,
                                  std::string *code_ptr) {
    std::string &code = *code_ptr;

    code += "function " + NormalizedName(struct_def) + ".New()\n";
    code += std::string(Indent) + "local o = {}\n";
    code += std::string(Indent) +
            "setmetatable(o, {__index = " + NormalizedMetaName(struct_def) +
            "})\n";
    code += std::string(Indent) + "return o\n";
    code += EndFunc;
  }

  // Initialize a new struct or table from existing data.
  void NewRootTypeFromBuffer(const StructDef &struct_def,
                             std::string *code_ptr) {
    std::string &code = *code_ptr;

    code += "function " + NormalizedName(struct_def) + ".GetRootAs" +
            NormalizedName(struct_def) + "(buf, offset)\n";
    code += std::string(Indent) +
            "local n = flatbuffers.N.UOffsetT:Unpack(buf, offset)\n";
    code += std::string(Indent) + "local o = " + NormalizedName(struct_def) +
            ".New()\n";
    code += std::string(Indent) + "o:Init(buf, n + offset)\n";
    code += std::string(Indent) + "return o\n";
    code += EndFunc;
  }

  // Initialize an existing object with other data, to avoid an allocation.
  void InitializeExisting(const StructDef &struct_def, std::string *code_ptr) {
    std::string &code = *code_ptr;

    GenReceiver(struct_def, code_ptr);
    code += "Init(buf, pos)\n";
    code +=
        std::string(Indent) + SelfData + " = flatbuffers.view.New(buf, pos)\n";
    code += EndFunc;
  }

  // Get the length of a vector.
  void GetVectorLen(const StructDef &struct_def, const FieldDef &field,
                    std::string *code_ptr) {
    std::string &code = *code_ptr;

    GenReceiver(struct_def, code_ptr);
    code += MakeCamel(NormalizedName(field)) + "Length()\n";
    code += OffsetPrefix(field);
    code +=
        std::string(Indent) + Indent + "return " + SelfData + ":VectorLen(o)\n";
    code += std::string(Indent) + End;
    code += std::string(Indent) + "return 0\n";
    code += EndFunc;
  }

  // Get the value of a struct's scalar.
  void GetScalarFieldOfStruct(const StructDef &struct_def,
                              const FieldDef &field, std::string *code_ptr) {
    std::string &code = *code_ptr;
    std::string getter = GenGetter(field.value.type);
    GenReceiver(struct_def, code_ptr);
    code += MakeCamel(NormalizedName(field));
    code += "()\n";
    code += std::string(Indent) + "return " + getter;
    code += std::string(SelfDataPos) + " + " + NumToString(field.value.offset) +
            ")\n";
    code += EndFunc;
  }

  // Get the value of a table's scalar.
  void GetScalarFieldOfTable(const StructDef &struct_def, const FieldDef &field,
                             std::string *code_ptr) {
    std::string &code = *code_ptr;
    std::string getter = GenGetter(field.value.type);
    GenReceiver(struct_def, code_ptr);
    code += MakeCamel(NormalizedName(field));
    code += "()\n";
    code += OffsetPrefix(field);
    getter += std::string("o + ") + SelfDataPos + ")";
    auto is_bool = field.value.type.base_type == BASE_TYPE_BOOL;
    if (is_bool) { getter = "(" + getter + " ~= 0)"; }
    code += std::string(Indent) + Indent + "return " + getter + "\n";
    code += std::string(Indent) + End;
    std::string default_value;
    if (is_bool) {
      default_value = field.value.constant == "0" ? "false" : "true";
    } else {
      default_value = field.value.constant;
    }
    code += std::string(Indent) + "return " + default_value + "\n";
    code += EndFunc;
  }

  // Get a struct by initializing an existing struct.
  // Specific to Struct.
  void GetStructFieldOfStruct(const StructDef &struct_def,
                              const FieldDef &field, std::string *code_ptr) {
    std::string &code = *code_ptr;
    GenReceiver(struct_def, code_ptr);
    code += MakeCamel(NormalizedName(field));
    code += "(obj)\n";
    code += std::string(Indent) + "obj:Init(" + SelfDataBytes + ", " +
            SelfDataPos + " + ";
    code += NumToString(field.value.offset) + ")\n";
    code += std::string(Indent) + "return obj\n";
    code += EndFunc;
  }

  // Get a struct by initializing an existing struct.
  // Specific to Table.
  void GetStructFieldOfTable(const StructDef &struct_def, const FieldDef &field,
                             std::string *code_ptr) {
    std::string &code = *code_ptr;
    GenReceiver(struct_def, code_ptr);
    code += MakeCamel(NormalizedName(field));
    code += "()\n";
    code += OffsetPrefix(field);
    if (field.value.type.struct_def->fixed) {
      code +=
          std::string(Indent) + Indent + "local x = o + " + SelfDataPos + "\n";
    } else {
      code += std::string(Indent) + Indent + "local x = " + SelfData +
              ":Indirect(o + " + SelfDataPos + ")\n";
    }
    code += std::string(Indent) + Indent + "local obj = require('" +
            TypeNameWithNamespace(field) + "').New()\n";
    code +=
        std::string(Indent) + Indent + "obj:Init(" + SelfDataBytes + ", x)\n";
    code += std::string(Indent) + Indent + "return obj\n";
    code += std::string(Indent) + End;
    code += EndFunc;
  }

  // Get the value of a string.
  void GetStringField(const StructDef &struct_def, const FieldDef &field,
                      std::string *code_ptr) {
    std::string &code = *code_ptr;
    GenReceiver(struct_def, code_ptr);
    code += MakeCamel(NormalizedName(field));
    code += "()\n";
    code += OffsetPrefix(field);
    code +=
        std::string(Indent) + Indent + "return " + GenGetter(field.value.type);
    code += std::string("o + ") + SelfDataPos + ")\n";
    code += std::string(Indent) + End;
    code += EndFunc;
  }

  // Get the value of a union from an object.
  void GetUnionField(const StructDef &struct_def, const FieldDef &field,
                     std::string *code_ptr) {
    std::string &code = *code_ptr;
    GenReceiver(struct_def, code_ptr);
    code += MakeCamel(NormalizedName(field)) + "()\n";
    code += OffsetPrefix(field);

    // TODO(rw): this works and is not the good way to it:
    // bool is_native_table = TypeName(field) == "*flatbuffers.Table";
    // if (is_native_table) {
    //  code += std::string(Indent) + Indent + "from flatbuffers.table import
    //  Table\n";
    //} else {
    //  code += std::string(Indent) + Indent +
    //  code += "from ." + TypeName(field) + " import " + TypeName(field) +
    //  "\n";
    //}
    code +=
        std::string(Indent) + Indent +
        "local obj = "
        "flatbuffers.view.New(require('flatbuffers.binaryarray').New(0), 0)\n";
    code += std::string(Indent) + Indent + GenGetter(field.value.type) +
            "obj, o)\n";
    code += std::string(Indent) + Indent + "return obj\n";
    code += std::string(Indent) + End;
    code += EndFunc;
  }

  // Get the value of a vector's struct member.
  void GetMemberOfVectorOfStruct(const StructDef &struct_def,
                                 const FieldDef &field, std::string *code_ptr) {
    std::string &code = *code_ptr;
    auto vectortype = field.value.type.VectorType();

    GenReceiver(struct_def, code_ptr);
    code += MakeCamel(NormalizedName(field));
    code += "(j)\n";
    code += OffsetPrefix(field);
    code +=
        std::string(Indent) + Indent + "local x = " + SelfData + ":Vector(o)\n";
    code += std::string(Indent) + Indent + "x = x + ((j-1) * ";
    code += NumToString(InlineSize(vectortype)) + ")\n";
    if (!(vectortype.struct_def->fixed)) {
      code +=
          std::string(Indent) + Indent + "x = " + SelfData + ":Indirect(x)\n";
    }
    code += std::string(Indent) + Indent + "local obj = require('" +
            TypeNameWithNamespace(field) + "').New()\n";
    code +=
        std::string(Indent) + Indent + "obj:Init(" + SelfDataBytes + ", x)\n";
    code += std::string(Indent) + Indent + "return obj\n";
    code += std::string(Indent) + End;
    code += EndFunc;
  }

  // Get the value of a vector's non-struct member. Uses a named return
  // argument to conveniently set the zero value for the result.
  void GetMemberOfVectorOfNonStruct(const StructDef &struct_def,
                                    const FieldDef &field,
                                    std::string *code_ptr) {
    std::string &code = *code_ptr;
    auto vectortype = field.value.type.VectorType();

    GenReceiver(struct_def, code_ptr);
    code += MakeCamel(NormalizedName(field));
    code += "(j)\n";
    code += OffsetPrefix(field);
    code +=
        std::string(Indent) + Indent + "local a = " + SelfData + ":Vector(o)\n";
    code += std::string(Indent) + Indent;
    code += "return " + GenGetter(field.value.type);
    code += "a + ((j-1) * ";
    code += NumToString(InlineSize(vectortype)) + "))\n";
    code += std::string(Indent) + End;
    if (IsString(vectortype)) {
      code += std::string(Indent) + "return ''\n";
    } else {
      code += std::string(Indent) + "return 0\n";
    }
    code += EndFunc;
  }

  // Begin the creator function signature.
  void BeginBuilderArgs(const StructDef &struct_def, std::string *code_ptr) {
    std::string &code = *code_ptr;

    code += "function " + NormalizedName(struct_def) + ".Create" +
            NormalizedName(struct_def);
    code += "(builder";
  }

  // Recursively generate arguments for a constructor, to deal with nested
  // structs.
  void StructBuilderArgs(const StructDef &struct_def, const char *nameprefix,
                         std::string *code_ptr) {
    for (auto it = struct_def.fields.vec.begin();
         it != struct_def.fields.vec.end(); ++it) {
      auto &field = **it;
      if (IsStruct(field.value.type)) {
        // Generate arguments for a struct inside a struct. To ensure names
        // don't clash, and to make it obvious these arguments are constructing
        // a nested struct, prefix the name with the field name.
        StructBuilderArgs(*field.value.type.struct_def,
                          (nameprefix + (NormalizedName(field) + "_")).c_str(),
                          code_ptr);
      } else {
        std::string &code = *code_ptr;
        code += std::string(", ") + nameprefix;
        code += MakeCamel(NormalizedName(field), false);
      }
    }
  }

  // End the creator function signature.
  void EndBuilderArgs(std::string *code_ptr) {
    std::string &code = *code_ptr;
    code += ")\n";
  }

  // Recursively generate struct construction statements and instert manual
  // padding.
  void StructBuilderBody(const StructDef &struct_def, const char *nameprefix,
                         std::string *code_ptr) {
    std::string &code = *code_ptr;
    code += std::string(Indent) + "builder:Prep(" +
            NumToString(struct_def.minalign) + ", ";
    code += NumToString(struct_def.bytesize) + ")\n";
    for (auto it = struct_def.fields.vec.rbegin();
         it != struct_def.fields.vec.rend(); ++it) {
      auto &field = **it;
      if (field.padding)
        code += std::string(Indent) + "builder:Pad(" +
                NumToString(field.padding) + ")\n";
      if (IsStruct(field.value.type)) {
        StructBuilderBody(*field.value.type.struct_def,
                          (nameprefix + (NormalizedName(field) + "_")).c_str(),
                          code_ptr);
      } else {
        code +=
            std::string(Indent) + "builder:Prepend" + GenMethod(field) + "(";
        code += nameprefix + MakeCamel(NormalizedName(field), false) + ")\n";
      }
    }
  }

  void EndBuilderBody(std::string *code_ptr) {
    std::string &code = *code_ptr;
    code += std::string(Indent) + "return builder:Offset()\n";
    code += EndFunc;
  }

  // Get the value of a table's starting offset.
  void GetStartOfTable(const StructDef &struct_def, std::string *code_ptr) {
    std::string &code = *code_ptr;
    code += "function " + NormalizedName(struct_def) + ".Start";
    code += "(builder) ";
    code += "builder:StartObject(";
    code += NumToString(struct_def.fields.vec.size());
    code += ") end\n";
  }

  // Set the value of a table's field.
  void BuildFieldOfTable(const StructDef &struct_def, const FieldDef &field,
                         const size_t offset, std::string *code_ptr) {
    std::string &code = *code_ptr;
    code += "function " + NormalizedName(struct_def) + ".Add" +
            MakeCamel(NormalizedName(field));
    code += "(builder, ";
    code += MakeCamel(NormalizedName(field), false);
    code += ") ";
    code += "builder:Prepend";
    code += GenMethod(field) + "Slot(";
    code += NumToString(offset) + ", ";
    // todo: i don't need to cast in Lua, but am I missing something?
    //    if (!IsScalar(field.value.type.base_type) && (!struct_def.fixed)) {
    //      code += "flatbuffers.N.UOffsetTFlags.py_type";
    //      code += "(";
    //      code += MakeCamel(NormalizedName(field), false) + ")";
    //    } else {
    code += MakeCamel(NormalizedName(field), false);
    //    }
    code += ", " + field.value.constant;
    code += ") end\n";
  }

  // Set the value of one of the members of a table's vector.
  void BuildVectorOfTable(const StructDef &struct_def, const FieldDef &field,
                          std::string *code_ptr) {
    std::string &code = *code_ptr;
    code += "function " + NormalizedName(struct_def) + ".Start";
    code += MakeCamel(NormalizedName(field));
    code += "Vector(builder, numElems) return builder:StartVector(";
    auto vector_type = field.value.type.VectorType();
    auto alignment = InlineAlignment(vector_type);
    auto elem_size = InlineSize(vector_type);
    code += NumToString(elem_size);
    code += ", numElems, " + NumToString(alignment);
    code += ") end\n";
  }

  // Get the offset of the end of a table.
  void GetEndOffsetOnTable(const StructDef &struct_def, std::string *code_ptr) {
    std::string &code = *code_ptr;
    code += "function " + NormalizedName(struct_def) + ".End";
    code += "(builder) ";
    code += "return builder:EndObject() end\n";
  }

  // Generate the receiver for function signatures.
  void GenReceiver(const StructDef &struct_def, std::string *code_ptr) {
    std::string &code = *code_ptr;
    code += "function " + NormalizedMetaName(struct_def) + ":";
  }

  // Generate a struct field, conditioned on its child type(s).
  void GenStructAccessor(const StructDef &struct_def, const FieldDef &field,
                         std::string *code_ptr) {
    GenComment(field.doc_comment, code_ptr, &def_comment);
    if (IsScalar(field.value.type.base_type)) {
      if (struct_def.fixed) {
        GetScalarFieldOfStruct(struct_def, field, code_ptr);
      } else {
        GetScalarFieldOfTable(struct_def, field, code_ptr);
      }
    } else {
      switch (field.value.type.base_type) {
        case BASE_TYPE_STRUCT:
          if (struct_def.fixed) {
            GetStructFieldOfStruct(struct_def, field, code_ptr);
          } else {
            GetStructFieldOfTable(struct_def, field, code_ptr);
          }
          break;
        case BASE_TYPE_STRING:
          GetStringField(struct_def, field, code_ptr);
          break;
        case BASE_TYPE_VECTOR: {
          auto vectortype = field.value.type.VectorType();
          if (vectortype.base_type == BASE_TYPE_STRUCT) {
            GetMemberOfVectorOfStruct(struct_def, field, code_ptr);
          } else {
            GetMemberOfVectorOfNonStruct(struct_def, field, code_ptr);
          }
          break;
        }
        case BASE_TYPE_UNION: GetUnionField(struct_def, field, code_ptr); break;
        default: FLATBUFFERS_ASSERT(0);
      }
    }
    if (IsVector(field.value.type)) {
      GetVectorLen(struct_def, field, code_ptr);
    }
  }

  // Generate table constructors, conditioned on its members' types.
  void GenTableBuilders(const StructDef &struct_def, std::string *code_ptr) {
    GetStartOfTable(struct_def, code_ptr);

    for (auto it = struct_def.fields.vec.begin();
         it != struct_def.fields.vec.end(); ++it) {
      auto &field = **it;
      if (field.deprecated) continue;

      auto offset = it - struct_def.fields.vec.begin();
      BuildFieldOfTable(struct_def, field, offset, code_ptr);
      if (IsVector(field.value.type)) {
        BuildVectorOfTable(struct_def, field, code_ptr);
      }
    }

    GetEndOffsetOnTable(struct_def, code_ptr);
  }

  // Generate struct or table methods.
  void GenStruct(const StructDef &struct_def, std::string *code_ptr) {
    if (struct_def.generated) return;

    GenComment(struct_def.doc_comment, code_ptr, &def_comment);
    BeginClass(struct_def, code_ptr);

    GenerateNewObjectPrototype(struct_def, code_ptr);

    if (!struct_def.fixed) {
      // Generate a special accessor for the table that has been declared as
      // the root type.
      NewRootTypeFromBuffer(struct_def, code_ptr);
    }

    // Generate the Init method that sets the field in a pre-existing
    // accessor object. This is to allow object reuse.
    InitializeExisting(struct_def, code_ptr);
    for (auto it = struct_def.fields.vec.begin();
         it != struct_def.fields.vec.end(); ++it) {
      auto &field = **it;
      if (field.deprecated) continue;

      GenStructAccessor(struct_def, field, code_ptr);
    }

    if (struct_def.fixed) {
      // create a struct constructor function
      GenStructBuilder(struct_def, code_ptr);
    } else {
      // Create a set of functions that allow table construction.
      GenTableBuilders(struct_def, code_ptr);
    }
  }

  // Generate enum declarations.
  void GenEnum(const EnumDef &enum_def, std::string *code_ptr) {
    if (enum_def.generated) return;

    GenComment(enum_def.doc_comment, code_ptr, &def_comment);
    BeginEnum(NormalizedName(enum_def), code_ptr);
    for (auto it = enum_def.Vals().begin(); it != enum_def.Vals().end(); ++it) {
      auto &ev = **it;
      GenComment(ev.doc_comment, code_ptr, &def_comment, Indent);
      EnumMember(enum_def, ev, code_ptr);
    }
    EndEnum(code_ptr);
  }

  // Returns the function name that is able to read a value of the given type.
  std::string GenGetter(const Type &type) {
    switch (type.base_type) {
      case BASE_TYPE_STRING: return std::string(SelfData) + ":String(";
      case BASE_TYPE_UNION: return std::string(SelfData) + ":Union(";
      case BASE_TYPE_VECTOR: return GenGetter(type.VectorType());
      default:
        return std::string(SelfData) + ":Get(flatbuffers.N." +
               MakeCamel(GenTypeGet(type)) + ", ";
    }
  }

  // Returns the method name for use with add/put calls.
  std::string GenMethod(const FieldDef &field) {
    return IsScalar(field.value.type.base_type)
               ? MakeCamel(GenTypeBasic(field.value.type))
               : (IsStruct(field.value.type) ? "Struct" : "UOffsetTRelative");
  }

  std::string GenTypeBasic(const Type &type) {
    // clang-format off
    static const char *ctypename[] = {
      #define FLATBUFFERS_TD(ENUM, IDLTYPE, \
              CTYPE, JTYPE, GTYPE, NTYPE, PTYPE, ...) \
        #PTYPE,
        FLATBUFFERS_GEN_TYPES(FLATBUFFERS_TD)
      #undef FLATBUFFERS_TD
    };
    // clang-format on
    return ctypename[type.base_type];
  }

  std::string GenTypePointer(const Type &type) {
    switch (type.base_type) {
      case BASE_TYPE_STRING: return "string";
      case BASE_TYPE_VECTOR: return GenTypeGet(type.VectorType());
      case BASE_TYPE_STRUCT: return type.struct_def->name;
      case BASE_TYPE_UNION:
        // fall through
      default: return "*flatbuffers.Table";
    }
  }

  std::string GenTypeGet(const Type &type) {
    return IsScalar(type.base_type) ? GenTypeBasic(type) : GenTypePointer(type);
  }

  std::string GetNamespace(const Type &type) {
    return type.struct_def->defined_namespace->GetFullyQualifiedName(
        type.struct_def->name);
  }

  std::string TypeName(const FieldDef &field) {
    return GenTypeGet(field.value.type);
  }

  std::string TypeNameWithNamespace(const FieldDef &field) {
    return GetNamespace(field.value.type);
  }

  // Create a struct with a builder and the struct's arguments.
  void GenStructBuilder(const StructDef &struct_def, std::string *code_ptr) {
    BeginBuilderArgs(struct_def, code_ptr);
    StructBuilderArgs(struct_def, "", code_ptr);
    EndBuilderArgs(code_ptr);

    StructBuilderBody(struct_def, "", code_ptr);
    EndBuilderBody(code_ptr);
  }

  bool generate() {
    if (!generateEnums()) return false;
    if (!generateStructs()) return false;
    return true;
  }

 private:
  bool generateEnums() {
    for (auto it = parser_.enums_.vec.begin(); it != parser_.enums_.vec.end();
         ++it) {
      auto &enum_def = **it;
      std::string enumcode;
      GenEnum(enum_def, &enumcode);
      if (!SaveType(enum_def, enumcode, false)) return false;
    }
    return true;
  }

  bool generateStructs() {
    for (auto it = parser_.structs_.vec.begin();
         it != parser_.structs_.vec.end(); ++it) {
      auto &struct_def = **it;
      std::string declcode;
      GenStruct(struct_def, &declcode);
      if (!SaveType(struct_def, declcode, true)) return false;
    }
    return true;
  }

  // Begin by declaring namespace and imports.
  void BeginFile(const std::string &name_space_name, const bool needs_imports,
                 std::string *code_ptr) {
    std::string &code = *code_ptr;
    code += std::string(Comment) + FlatBuffersGeneratedWarning() + "\n\n";
    code += std::string(Comment) + "namespace: " + name_space_name + "\n\n";
    if (needs_imports) {
      code += "local flatbuffers = require('flatbuffers')\n\n";
    }
  }

  // Save out the generated code for a Lua Table type.
  bool SaveType(const Definition &def, const std::string &classcode,
                bool needs_imports) {
    if (!classcode.length()) return true;

    std::string namespace_dir = path_;
    auto &namespaces = def.defined_namespace->components;
    for (auto it = namespaces.begin(); it != namespaces.end(); ++it) {
      if (it != namespaces.begin()) namespace_dir += kPathSeparator;
      namespace_dir += *it;
      // std::string init_py_filename = namespace_dir + "/__init__.py";
      // SaveFile(init_py_filename.c_str(), "", false);
    }

    std::string code = "";
    BeginFile(LastNamespacePart(*def.defined_namespace), needs_imports, &code);
    code += classcode;
    code += "\n";
    code +=
        "return " + NormalizedName(def) + " " + Comment + "return the module";
    std::string filename =
        NamespaceDir(*def.defined_namespace) + NormalizedName(def) + ".lua";
    return SaveFile(filename.c_str(), code, false);
  }

 private:
  std::unordered_set<std::string> keywords_;
};

}  // namespace lua

bool GenerateLua(const Parser &parser, const std::string &path,
                 const std::string &file_name) {
  lua::LuaGenerator generator(parser, path, file_name);
  return generator.generate();
}

}  // namespace flatbuffers


text:
SYNONYM

#### According to
Index Fungorum

#### Published in
null

#### Original name
Oceanites scuticella Kohlm.

### Remarks
null


text:
class TestMetaOutput : public TestRequiringOptions
{
protected:
    tilegen::TilesetGenerator tg;
    const metaoutput::MetaOutput& metaOutput;
    TestMetaOutput() :
        TestRequiringOptions(),
        tg(options,
           std::move(std::make_unique<tilegen::partition::TilePartitionerSquares>(options))),
        metaOutput(tg.metaOutput)
    {
        tg.generate([&](const sf::Texture& output, std::string filename) {});
    };
};

// TODO replace this test with something faster
TEST_F(TestMetaOutput, TestMetaOutputCorrect)
{
    const auto& td = metaOutput.getTileData();
    for (const auto& corner : td[0].corners)
    {
        EXPECT_EQ(corner, "g") << "Incorrect terrain id in TileData[0].corners";
    }

    for (const auto& corner : td[15].corners)
    {
        EXPECT_EQ(corner, "s") << "Incorrect terrain id in TileData[15].corners";
    }

    const auto& tsd = metaOutput.getTilesetData();
    EXPECT_TRUE(std::any_of(std::cbegin(tsd), std::cend(tsd),
                [](auto& t){return t.filename == "g.s.png";}));
    EXPECT_TRUE(std::all_of(std::begin(tsd), std::end(tsd),
                [](auto& t) {return t.resolution == sf::Vector2u(32, 32); })) << "Incorrect resolution";

    const auto& tgd = metaOutput.getTileGroups();
    EXPECT_TRUE(tgd.find("g.s.g.s") != tgd.end()) << "TileGroups is missing ""g.s.g.s""";
    EXPECT_TRUE(tgd.find("g.s.s.g") != tgd.end()) << "TileGroups is missing ""g.s.s.g""";

    const auto& ta = metaOutput.getTerrainHypergraph();
    EXPECT_NE(ta.find("g"), ta.end()) << R"("TerrainHypergraph is missing "g")";
    auto it = ta.at("g").cbegin();
    EXPECT_NE(std::find((*it).cbegin(), (*it).cend(), "s"), (*it).cend());
}


text:
const Application = OSjs.require('core/application');
const Window = OSjs.require('core/window');

class ApplicationEXAMPLEWindow extends Window {

  constructor(app, metadata) {
    super('ApplicationEXAMPLEWindow', {
      icon: metadata.icon,
      title: metadata.name,
      width: 400,
      height: 200
    }, app);
  }

  init(wmRef, app) {
    const root = super.init(...arguments);

    // Render our Scheme file fragment into this Window
    this._render('EXAMPLEWindow', require('osjs-scheme-loader!./scheme.html'));

    // Put your GUI code here (or make a new prototype function and call it):

    return root;
  }

}

class ApplicationEXAMPLE extends Application {

  constructor(args, metadata) {
    super('ApplicationEXAMPLE', args, metadata);
  }

  init(settings, metadata) {
    super.init(...arguments);

    this._addWindow(new ApplicationEXAMPLEWindow(this, metadata));

    // Example on how to call `api.js` methods
    this._api('test', {}).then((res) => {
      return console.log('Result from your server API method', res);
    })
  };
}

OSjs.Applications.ApplicationEXAMPLE = ApplicationEXAMPLE;


text:
/* ============================================= */
/* CSS for support popup window                  */
/* ============================================= */

.sapUiSupportBody {
	/*background-color: #F2F2F2;*/
	color: #000000;
	font-family: Arial, Helvetica, sans-serif;
	font-size: 12px;
	margin: 0;
	padding: 0;
	height: 100%;
	width: 100%;
	min-width: 700px;
}

.sapUiSupportHidden {
	display: none;
}

.sapUiSupportHdr {
	position: relative;
	border-top: 2px solid #009de0;
	border-bottom: 1px solid #009de0;
	background-color:#f5f5f5;
	height: 30px;
	margin: 0;
}

.sapUiSupportHdr > img {
	position: absolute;
	left: 10px;
	height: 29px;
	display: none;
}

.sapUiSupportHdr > div {
	color: #007DC0;
	font-size: 18px;
	font-weight: normal;
	left: 10px;
	position: absolute;
	top: 5px;
}

.sapUiSupportPnl {
	margin-left: 5px;
	margin-right: 5px;
	margin-bottom: 5px;
}

.sapUiSupportCntnt {
	position: absolute;
	top: 40px;
	bottom: 0;
	overflow: auto;
	width: 100%;
	min-width: 700px;
}

.sapUiSupportPnlHdr {
	margin-top: 0;
	margin-bottom: 5px;
	color: #555;
	border-bottom: 1px solid #007DC0;
	height: 25px;
	font-weight: normal;
	font-size: 18px;
	padding-left: 5px;
	padding-right: 5px;
	position: relative;
	cursor: pointer;
}

.sapUiSupportPnlHdr:hover {
	color: #007DC0; /* indicate it is clickable */
}

.sapUiSupportPnlHdrHdl {
	border-color: #444444;
	border-right: 1px solid #444444;
	border-style: solid;
	border-width: 3px 1px 1px;
	cursor: pointer;
	height: 7px;
	position: absolute;
	right: 5px;
	top: 8px;
	width: 10px;
}

.sapUiSupportPnlHdrHdl.sapUiSupportPnlHdrHdlClosed {
	border-width: 3px 0px 0px;
	width: 12px;
}

.sapUiSupportPnlCntnt {
	margin-bottom: 5px;
}

.sapUiSupportPnlCntntPad {
	padding-left: 5px;
	padding-right: 5px;
}

.sapUiSupportPlugin {
	overflow: auto;
	position: relative;
}

.sapUiSupportLink,
.sapUiSupportLink:active,
.sapUiSupportLink:focus,
.sapUiSupportLink:visited,
.sapUiSupportLink:hover {
	color: #0078BB;
	text-decoration: none;
	display: inline-block;
}

.sapUiSupportLink:hover {
	text-decoration: underline;
}

.sapUiSupportLink.sapUiSupportLinkDsbl,
.sapUiSupportLink.sapUiSupportLinkDsbl:active,
.sapUiSupportLink.sapUiSupportLinkDsbl:focus,
.sapUiSupportLink.sapUiSupportLinkDsbl:visited,
.sapUiSupportLink.sapUiSupportLinkDsbl:hover {
	color: #999999;
	text-decoration: underline;
	cursor: default;
}

.sapUiSupportLabel {
	font-weight: bold;
}

.sapUiSupportToolbar {
	background-color: #F2F2F2;
	height: 28px;
	margin-bottom: 5px;
	padding-left: 5px;
	padding-right: 5px;
}

.sapUiSupportTxtFld,
.sapUiSupportBtn {
	border: 1px solid #BFBFBF;
	font-size: 14px;
	height: 22px;
	-moz-box-sizing: border-box;
	-webkit-box-sizing: border-box;
	box-sizing: border-box;
}

.sapUiSupportTxtFld {
	background-color: #FFFFFF;
	padding: 1px;
}

.sapUiSupportTxtFld:hover,
.sapUiSupportTxtFld:focus {
	border-color: #007DC0;
}

.sapUiSupportBtn {
	background-color: #E2E2E2;
	border-color: #A3A3A3;
	padding-bottom: 3px;
	cursor: pointer;
}

.sapUiSupportBtn:hover,
.sapUiSupportBtn:focus,
.sapUiSupportBtn.active {
	color: #FFFFFF;
	border-color: #00689E;
	background-color: #007DC0;
}

.sapUiSupportBtn.active {
	cursor: default;
}

.sapUiSupportToolbar > .sapUiSupportBtn,
.sapUiSupportToolbar > .sapUiSupportTxtFld {
	margin-top: 3px;
	vertical-align: top;
}

.sapUiSupportToolbar > .sapUiSupportLink {
	margin-top: 6px;
	vertical-align: top;
}

.sapUiSupportToolbar > .sapUiSupportLabel {
	position: relative;
	top: 6px;
	vertical-align: top;
}

/** Plugins **/

#sapUiSupportTechInfo {
	height: 350px;
}

#sapUiSupportTechInfo > table {
	width: 100%;
}

#sapUiSupportTechInfo-tggleDbgSrc,
#sapUiSupportTechInfo-tggleStatistics {
	margin-left: 15px;
}

#sapUiSupportTechInfo-Refresh {
	position: absolute;
	right: 5px;
}

.sapUiSupportTechInfoBorder {
	border: 1px solid #E2E2E2;
}

#sapUiSupportTrace,
#sapUiSupportMessageTest {
	overflow: hidden;
}

#sapUiSupportMessageTest > .sapUiSupportToolbar > button {
	margin-left: 5px;
}

#sapUiSupportPerf .sapUiSupportPerfCntnt,
#sapUiSupportTechInfo .sapUiSupportTechInfoCntnt,
#sapUiSupportTrace .sapUiSupportTraceCntnt,
#sapUiSupportMessageTest .sapUiSupportMessageCntnt {
	overflow: auto;
	position: absolute;
	top: 33px;
	left: 5px;
	right: 5px;
	bottom: 0;
}

#sapUiSupportTrace .sapUiSupportTraceEntryTime,
#sapUiSupportTrace .sapUiSupportTraceEntryLevel {
	font-weight: bold;
	display: inline-block;
	vertical-align: top;
}

#sapUiSupportTrace .sapUiSupportTraceEntryMessage {
	display: inline-block;
	vertical-align: top;
}

#sapUiSupportTrace .sapUiSupportTraceEntryLevel {
	width: 70px;
}

#sapUiSupportTrace .sapUiSupportTraceEntry {
	border-bottom: 1px solid #BFBFBF;
}

#sapUiSupportTrace .sapUiSupportTraceEntryTime {
	width: 100px;
}

#sapUiSupportTrace > .sapUiSupportToolbar > .sapUiSupportLabel {
	margin-left: 10px;
	font-weight: normal;
}

#sapUiSupportTrace > .sapUiSupportToolbar > select,
#sapUiSupportTrace > .sapUiSupportToolbar > input {
	margin-left: 5px;
}

#sapUiSupportControlTree {
	height: 480px;
	overflow: hidden;
}

.sapUiSupportDottedContainer,
#sapUiSupportControlTreeArea,
#sapUiSupportControlPropertiesArea {
	height: 454px;
	width: 48%;
	border: 1px dotted black;
	background-color: white;
	padding: 5px;
	overflow: auto;
	float: left;
	position: relative;
}

#sapUiSupportControlPropertiesArea {
	float: right;
	height: 423px;
}

ul.sapUiSupportControlTreeList, ul.sapUiSupportControlTreeList ul {
	list-style-type: none;
	margin: 0;
	padding: 0;
}

ul.sapUiSupportControlTreeList li {
	margin: 2px 0 2px 11px;
	padding: 0;
}

#sapUiSupportControlTreeArea li {
	/*position: relative;*/
	overflow: hidden;
	cursor: pointer;
}

#sapUiSupportControlTreeArea li img.sapUiControlTreeIcon,
#sapUiSupportControlTreeArea li img.sapUiControlPicture {
	float: left;
}

#sapUiSupportControlTreeArea li img.sapUiControlTreeIcon {
	margin-top: 7px;
	margin-right: 4px;
}

#sapUiSupportControlTreeArea li img.sapUiControlPicture {
	margin-top: 5px;
	margin-right: 5px;
}

#sapUiSupportControlTreeArea li div {
	overflow: hidden;
	padding: 7px;
}

#sapUiSupportControlTreeArea li.sapUiControlTreeLink span {
	color: gray;
	text-decoration: underline;
}

#sapUiSupportControlTreeArea .sapUiSupportControlTreeSelected {
	background-color: #007DC0;
	color: white;
}

#sapUiSupportControlTreeArea .sapUiSupportControlTreeBreakpointCount {
	float: right;
}

#sapUiSupportControlTreeArea .sapUiSupportControlTreeBreakpointCount {
	color: black;
}

#sapUiSupportControlTreeArea .sapUiSupportControlTreeSelected .sapUiSupportControlTreeBreakpointCount {
	color: white;
}

#sapUiSupportControlTabs {
	width: 48%;
	height: 22px;
	padding: 3px 12px 6px 0;
	overflow: auto;
	float: right;
}

#sapUiSupportControlPropertiesArea ul.sapUiSupportControlTreeList li span {
	display: inline-block;
	padding: 5px 0;
	vertical-align: top;
}

#sapUiSupportControlPropertiesArea ul.sapUiSupportControlTreeList li {
	position: relative;
}

.sapUiSupportControlProperties {
	padding: 5px;
}

.sapUiSupportControlProperties table {
	width: 100%;
	border-spacing: 0;
	border-collapse: collapse;
}

.sapUiSupportControlProperties tr {
	height: 30px;
}

.sapUiSupportControlProperties tr:nth-child(even) {
	background-color: #F9F9F9;
}

.sapUiSupportControlProperties td {
	border: 1px solid #BFBFBF;
	padding: 0 6px;
}

.sapUiSupportControlProperties td div {
	/*padding: 0 5px;*/
}

.sapUiSupportControlProperties input[type="text"],
.sapUiSupportControlProperties select {
	width: 100%;
	box-sizing: border-box;
	-moz-box-sizing: border-box;
	-webkit-box-sizing: border-box;
}

#sapUiSupportPerf > .sapUiSupportToolbar > .sapUiSupportLabel {
	font-weight: normal;
}

#sapUiSupportPerf > .sapUiSupportToolbar > button {
	margin-right: 5px;
}

.sapUiSupportToolbar > input[type="checkbox"] {
	margin-top: 7px;
}

.sapUiSupportControlProperties td.methodLabel {
	vertical-align: middle;
	padding-left: 7px;
}

.sapUiSupportControlProperties td.methodLabel label {
	padding: 6px 0 6px 0;
	width: 100%;
	display: inline-block;
}

#sapUiSupportControlPropertiesArea ul li .get,
#sapUiSupportControlPropertiesArea ul li .set {
	position: absolute;
	top: 12px;
	font-weight: bold;
}

#sapUiSupportControlPropertiesArea ul li .get {
	right: 50px;
}

html[data-sap-ui-browser^="sf"] #sapUiSupportControlPropertiesArea ul li .get {
	right: 45px;
}

#sapUiSupportControlPropertiesArea ul li .set {
	right: 18px;
}

html[data-sap-ui-browser^="sf"] #sapUiSupportControlPropertiesArea ul li .set {
	right: 16px;
}

.sapUiSupportControlMethods {
	padding: 5px 2px 0 2px;
}

select.sapUiSupportAutocomplete {
	width: 198px;
	height: 22px;
	padding: 1px;
}

input[type="text"].sapUiSupportAutocomplete {
	margin-left: -197px;
	padding: 0 5px;
	width: 168px;
	height: 18px;
	border: none;
}

html[data-sap-ui-browser^="sf"] input[type="text"].sapUiSupportAutocomplete {
	height: 14px;
}

.sapUiSupportControlMethods button {
	margin-left: 28px;
}

html[data-sap-ui-browser^="ff"] .sapUiSupportControlMethods button {
	margin-left: 26px;
}

html[data-sap-ui-browser^="ie"] .sapUiSupportControlMethods button {
	margin-left: 24px;
}

html[data-sap-ui-browser^="sf"] .sapUiSupportControlMethods select.sapUiSupportAutocomplete {
	width: 189px;
}

html[data-sap-ui-browser^="sf"] .sapUiSupportControlMethods input[type="text"].sapUiSupportAutocomplete {
	width: 159px;
	margin-left: -188px;
}

hr.no-border {
	border-style: solid;
	border-color: #BFBFBF;
	border-bottom: none;
	margin: 10px 0 0 0;
}

ul.sapUiSupportList {
	list-style-type: none;
	padding: 0;
	margin: 0;
}

ul.sapUiSupportList li {
	position: relative;
}

ul.sapUiSupportBreakpointList li {
	border-bottom: 1px solid #BFBFBF;
}

ul.sapUiSupportBreakpointList li:last-child {
	border-bottom: none;
}

ul.sapUiSupportBreakpointList li:hover {
	background-color: #F9F9F9;
}

ul.sapUiSupportBreakpointList li span {
	font-weight: bold;
	padding: 7px 0 7px 10px;
	display: inline-block;
}

ul.sapUiSupportBreakpointList li img {
	position: absolute;
	display: none;
	right: 10px;
	top: 7px;
}

ul.sapUiSupportBreakpointList li:hover img {
	display: inline;
}

#sapUiSupportControlTabProperties,
#sapUiSupportControlTabBindingInfos {
	margin-right: 3px;
}

/* DEBUGGING */

#sapUiSupportDebugging {
	height: 400px;
}

#sapUiSupportDebugging > .sapUiSupportDottedContainer {
	height: 278px;
	margin: 6px 0;
}

#sapUiSupportDebugging > #sapUiSupportDebuggingRebootContainer {
	box-sizing: border-box;
	width: 100%;
	height: 82px;
}

#sapUiSupportDebuggingRebootSelect {
	width: 100%;
	margin: 6px 0;
}

#sapUiSupportDebuggingRebootInput {
	width: 533px;
	box-sizing: border-box;
	width: calc(100% - 142px);
}

#sapUiSupportDebuggingMethodContainer {
	float: right;
}

#sapUiSupportDebuggingClassSelect {
	width: 228px;
}

#sapUiSupportDebuggingClassInput {
	margin-left: -227px;
	width: 198px;
}

#sapUiSupportDebuggingMethodSelect {
	width: 150px;
}

html[data-sap-ui-browser^="sf"] #sapUiSupportDebuggingMethodSelect {
	width: 140px;
}

#sapUiSupportDebuggingMethodInput {
	margin-left: -149px;
	width: 120px;
}

html[data-sap-ui-browser^="sf"] #sapUiSupportDebuggingMethodInput {
	margin-left: -139px;
	width: 110px;
}

#sapUiSupportDebuggingAddClass,
#sapUiSupportDebuggingAddBreakpoint {
	margin-left: 32px;
}

html[data-sap-ui-browser^="ie"] #sapUiSupportDebuggingAddClass,
html[data-sap-ui-browser^="ie"] #sapUiSupportDebuggingAddBreakpoint {
	margin-left: 30px;
}

html[data-sap-ui-browser^="ff"] #sapUiSupportDebuggingAddClass,
html[data-sap-ui-browser^="ff"] #sapUiSupportDebuggingAddBreakpoint {
	margin-left: 28px;
}

#sapUiSupportDebuggingClassList li div {
	padding: 7px 0 7px 10px;
	margin-right: 35px;
	font-weight: bold;
}

#sapUiSupportDebuggingClassList li img.remove-class {
	top: 7px;
	right: 10px;
	position: absolute;
	display: none;
}

#sapUiSupportDebuggingClassList li.selected div,
#sapUiSupportDebuggingClassList li div:hover {
	color: #fff;
	background-color: #007dc0;
	cursor: pointer;
}

#sapUiSupportDebuggingClassList li:hover img.remove-class {
	display: inline;
}

#sapUiSupportDebuggingClassList li span.breakpoints {
	float: right;
	margin-right: 10px;
}

/* ==========================================================================
   Performance
   ========================================================================== */
.sapUiSupportBody,
.sapUiSupportCntnt,
.sapUiSupportPerf-PanelContent,
#sapUiSupportPerf-Panel,
#sapUiSupportPerf-PanelContent not(.sapUiSupportHidden) {
	display: -webkit-box;
	display: -webkit-flex;
	display: -ms-flexbox;
	display: flex;

	-webkit-box-direction: normal;
	-webkit-box-orient: vertical;
	-webkit-flex-direction: column;
	-ms-flex-direction: column;
	flex-direction: column;

	-webkit-box-flex: 1;
	-webkit-flex-grow: 1;
	-ms-flex: 1 1;
	flex-grow: 1;
}

#sapUiSupportPerf-PanelContent {
	visibility: visible;
	min-height: 400px;
	position: relative;
}

#sapUiSupportPerf-PanelContent.sapUiSupportHidden {
	visibility: hidden;
}

/* ================================================================================================================== */
#sapUiSupportPerf {
	bottom: 0;
	left: 0;
	overflow: hidden;
	position: absolute;
	right: 0;
	top: 0;
	background: #fff;
}

#sapUiSupportPerf ol,
#sapUiSupportPerf li {
	list-style: none;
	margin: 0;
	padding: 0;
}

.flex-spacer {
	-webkit-box-flex: 1;
	-webkit-flex-grow: 1;
	-ms-flex: 1 1;
	flex-grow: 1;
}

/* ==========================================================================
   Performance Header
   ========================================================================== */
#sapUiSupportPerfHeader {
	display: -webkit-box;
	display: -webkit-flex;
	display: -ms-flexbox;
	display: flex;

	-webkit-box-direction: normal;
	-webkit-box-orient: vertical;
	-webkit-flex-direction: column;
	-ms-flex-direction: column;
	flex-direction: column;

	height: 80px;
	left: 0;
	position: absolute;
	right: 0;
	top: 0;
	z-index: 10;

	-webkit-user-select: none;
	-moz-user-select: none;
	-ms-user-select: none;
	user-select: none;
}

.sapUiSupportPerfHeaderFilters {
	background: #eee;
	border-bottom: solid 1px #ddd;
	display: -webkit-box;
	display: -webkit-flex;
	display: -ms-flexbox;
	display: flex;
	height: 30px;
	line-height: 30px;
	padding: 0 5px;
}

.sapUiSupportPerfHeaderFilters > div {
	padding-left: 5px;
}

#sapUiSupportPerfHeaderTimelineOverview {
	border-bottom: solid 1px #ddd;
	border-bottom: solid 1px #ddd;
	padding-left: 250px;
	position: relative;
	-webkit-box-flex: 1;
	-webkit-flex-grow: 1;
	-ms-flex: 1 1;
	flex-grow: 1;
}

#sapUiSupportPerfHeaderTimelineOverview .timeline {
	background: #fafafa;
	bottom: 0;
	display: -webkit-box;
	display: -webkit-flex;
	display: -ms-flexbox;
	display: flex;
	left: 0;
	position: absolute;
	right: 0;
	top: 0;
}

#sapUiSupportPerfHeaderTimelineOverview .timeline ol {
	bottom: 0;
	display: -webkit-box;
	display: -webkit-flex;
	display: -ms-flexbox;
	display: flex;
	left: 250px;
	position: absolute;
	right: 0;
	top: 2px;
}

#sapUiSupportPerfHeaderTimelineOverview .timeline li {
	display: -webkit-box;
	display: -webkit-flex;
	display: -ms-flexbox;
	display: flex;
	position: relative;
	flex: 1;
}

#sapUiSupportPerfHeaderTimelineOverview .timeline li .duration,
#sapUiSupportPerfHeaderTimelineOverview .timeline li .time {
	display: flex;
	flex-direction: column;
	-webkit-box-pack: end;
	-webkit-justify-content: flex-end;
	-ms-flex-pack: end;
	justify-content: flex-end;
}

#sapUiSupportPerfHeaderTimelineOverview .timeline li .duration {
	margin-right: 1px;
	width: 4px;
}

#sapUiSupportPerfHeaderTimelineOverview .timeline li .time {
	opacity: 0.5;
	width: 2px;
}

#sapUiSupportPerfHeaderTimelineOverview .bars-wrapper {
	bottom: 0;
	display: flex;
	left: 0;
	position: absolute;
	right: 0;
	top: 0;
	-webkit-box-align: end;
	-webkit-align-items: flex-end;
	-ms-flex-align: end;
	align-items: flex-end;
	-webkit-box-pack: center;
	-webkit-justify-content: center;
	-ms-flex-pack: center;
	justify-content: center;
}

/* ================================================================================================================== */

#sapUiSupportNoDataOverlay {
	position: absolute;
	top: 90px;
	bottom: 0;
	left: 0;
	right: 0;
	background: #fff;
	z-index: 100;
	display: none;
}

/* ================================================================================================================== */

.line {
	font-size: 11px;
	height: 20px;
	line-height: 20px;
	white-space: nowrap;
}

.nodata {
	border-bottom: solid 1px #eee;
	overflow: hidden;
	box-sizing: border-box;
}

/* Filters
   ========================================================================== */

.filters > div {
	padding-right: 20px;
	white-space: nowrap;
}

#categories {
	display: -webkit-box;
	display: -webkit-flex;
	display: -ms-flexbox;
	display: flex;
	max-width: 440px;
	padding-right: 0;
}

#categories > label {
	cursor: pointer;
	margin-right: 8px;
	overflow: hidden;
	text-overflow: ellipsis;
	text-transform: capitalize;
	white-space: nowrap;
}

#categories input {
	bottom: 1px;
	margin: 0 3px 0;
	position: relative;
	vertical-align: middle;
}

#categories input::after {
	background: #fff;
	border: solid 1px #666;
	border-radius: 3px;
	box-sizing: border-box;
	color: #fff;
	content: '✓';
	cursor: pointer;
	display: inline-block;
	font-size: 10px;
	font-weight: bolder;
	height: 13px;
	line-height: 10px;
	padding-left: 1px;
	padding-top: 1px;
	position: absolute;
	width: 13px;
}

#categories input:checked::after {
	background: #666;
}

.timeline .requireModuleType,
#categories input.requireModuleType:checked::after {
	background: hotpink;
}

.timeline .requestType,
#categories input.requestType:checked::after {
	background: blue;
}

.timeline .afterRenderingType,
#categories input.afterRenderingType:checked::after {
	background: orange;
}

.timeline .renderingType,
#categories input.renderingType:checked::after {
	background: green;
}

.timeline .unknownType,
#categories input.unknownType:checked::after {
	background: #666;
}

#sapUiSupportPerfHeaderFilterMinDuration {
	width: 50px;
}

#sapUiSupportPerfHeaderFilterSort {
	margin-right: 8px;
}

/* ==========================================================================
   Timeline
   ========================================================================== */

#sapUiSupportPerfHeaderTimeline {
	display: -webkit-box;
	display: -webkit-flex;
	display: -ms-flexbox;
	display: flex;
	bottom: 0;
	left: 0;
	overflow: auto;
	position: absolute;
	right: 0;
	top: 100px;
	z-index: 1;
}

#sapUiSupportPerfHeaderTimelineBarWrapper {
	-webkit-box-flex: 1;
	-webkit-flex-grow: 1;
	-ms-flex-positive: 1;
	flex-grow: 1;
	position: relative;
	-webkit-user-select: none;
	-moz-user-select: none;
	-ms-user-select: none;
	user-select: none;
}

#sapUiSupportPerfHeaderTimelineBarWrapper ol {
	background-image: linear-gradient(90deg, #ddd 1px, transparent 1px),
	linear-gradient(90deg, #efefef 1px, transparent 1px),
	linear-gradient(90deg, #fafafa 1px, transparent 1px);
	z-index: 0;
}

#sapUiSupportPerfHeaderTimelineBarWrapper li {
	box-sizing: border-box;
	padding-top: 6px;
}

/* ================================================================================================================== */
#sapUiSupportPerfHeaderTimelineBarInfoWrapper {
	-webkit-box-flex: 0;
	-webkit-flex-grow: 0;
	-ms-flex-positive: 0;
	flex-grow: 0;
	-webkit-flex-shrink: 0;
	-ms-flex-negative: 0;
	flex-shrink: 0;
	-webkit-flex-basis: 250px;
	-ms-flex-preferred-size: 250px;
	flex-basis: 250px;
}

#sapUiSupportPerfHeaderTimelineBarInfoWrapper li {
	overflow-x: hidden;
}

#sapUiSupportPerfHeaderTimelineBarInfoWrapper .info:before {
	background: #eee;
	content: '';
	display: inline-block;
	height: 9px;
	margin-left: 4px;
	margin-right: 4px;
	width: 8px;
}

#sapUiSupportPerfHeaderTimeline li.hover {
	background: rgba(0, 0, 0, 0.025);
}

/* ================================================================================================================== */

#sapUiSupportPerfHeaderTimeline .requireModuleType .info:before {
	background: hotpink;
}

#sapUiSupportPerfHeaderTimeline .requestType .info:before {
	background: blue;
}

#sapUiSupportPerfHeaderTimeline .afterRenderingType .info:before {
	background: orange;
}

#sapUiSupportPerfHeaderTimeline .renderingType .info:before {
	background: green;
}

#sapUiSupportPerfHeaderTimeline .unknownType .info:before {
	background: #eee;
}

.timeline {
	display: -webkit-box;
	display: -webkit-flex;
	display: -ms-flexbox;
	display: flex;
	overflow: hidden;
}

.flattenBarOffset .bar {
	margin-left: 0 !important;
}

.bar {
	background-color: #88BF49;
	height: 6px;
	position: relative;
}

.sub-bar {
	background-color: #88BF49;
	bottom: -3px;
	height: 2px;
	left: 0;
	opacity: 0.5;
	position: absolute;
}

/* ================================================================================================================== */

.defaultTimeStyle {
	background-color: #aebf4d;
}

.oneTimeStyle {
	background-color: #aebf4d;
}

.twoTimeStyle {
	background-color: #bfac4f;
}

.threeTimeStyle {
	background-color: #bf8c4c;
}

.fourTimeStyle {
	background-color: #bf784b;
}

.fiveTimeStyle {
	background-color: #bf5e3f;
}

.sixTimeStyle {
	background-color: #bf3020;
}

/* ================================================================================================================== */

#slider {
	position: absolute;
	top: 0;
	right: 0;
	bottom: 0;
	left: 250px;
	cursor: pointer;
	overflow: hidden;
	-webkit-user-select: none;
	-moz-user-select: none;
	-ms-user-select: none;
	user-select: none;
}

#slideHandle,
#leftHandle,
#rightHandle {
	display: inline-block;
}

#slideHandle {
	position: relative;
	height: 50px;
	box-sizing: border-box;
	border: 1px solid #aaa;
	top: -1px;
}

#slideHandle::before,
#slideHandle::after {
	content: '';
	position: absolute;
	top: 0;
	bottom: 0;
	background: rgba(0, 0, 0, 0.25);
	width: 10000px;
	pointer-events: none;
}

#slideHandle::before {
	margin-right: 100%;
	right: 1px;
}

#slideHandle::after {
	margin-left: 100%;
	left: 1px;
}

#leftHandle,
#rightHandle {
	position: absolute;
	height: 100%;
	width: 5px;
	cursor: ew-resize;
	overflow: hidden;
	background: #aaa;
}

#leftHandle {
	left: 0;
}

#rightHandle {
	right: 0;
}

#leftHandle::after,
#rightHandle::after {
	content: '...';
	position: absolute;
	top: 0;
	left: 0;
	font-weight: bold;
	color: #fff;
}

#leftHandle::after {
	transform: rotate(90deg) translate(15px, 0);
}

#rightHandle::after {
	transform: rotate(90deg) translate(15px, -1px);
}

/* ================================================================================================================== */
/* Timeline grid */
/* ================================================================================================================== */

#grid {
	position: absolute;
	top: 90px;
	right: 0;
	bottom: 0;
	left: 250px;
	display: -webkit-box;
	display: -webkit-flex;
	display: -ms-flexbox;
	display: flex;
	-webkit-box-orient: vertical;
	-webkit-box-direction: normal;
	-webkit-flex-direction: column;
	-ms-flex-direction: column;
	flex-direction: column;
	pointer-events: none;
	border-left: 1px solid #eee;
}

#grid .header {
	width: 100%;
	display: -webkit-box;
	display: -webkit-flex;
	display: -ms-flexbox;
	display: flex;
	box-sizing: border-box;
}

#grid .body {
	display: -webkit-box;
	display: -webkit-flex;
	display: -ms-flexbox;
	display: flex;
	webkit-box-flex: 1;
	-webkit-flex-grow: 1;
	-ms-flex-positive: 1;
	flex-grow: 1;
}

#grid .header > div,
#grid .body > div {
	webkit-box-flex: 1;
	-webkit-flex-grow: 1;
	-ms-flex-positive: 1;
	flex-grow: 1;
	-webkit-flex-shrink: 1;
	-ms-flex-negative: 1;
	flex-shrink: 1;
	-webkit-flex-basis: 0;
	-ms-flex-preferred-size: 0;
	flex-basis: 0;
	box-sizing: border-box;
	position: relative;
	white-space: nowrap;
	font-size: 80%;
}

#grid .body > div:nth-child(5n) {
	border-right: 1px solid #fafafa;
}

#grid .body > div:nth-child(10n) {
	border-right: 1px solid #eee;
}

#grid .header > div:first-child::after,
#grid .header > div:nth-child(5n)::after,
#grid .header > div:nth-child(10n)::after {
	display: block;
	content: attr(data-time);
	position: absolute;
	top: 0;
	right: 0;
	padding-right: 5px;
}

#grid .header > div:nth-child(5n) {
	color: #aaa;
}

#grid .header > div:first-child,
#grid .header > div:nth-child(10n) {
	color: #666;
}

#grid .header > div:first-child::after {
	right: 100%;
}

#sapUiSupportPerfToggleRecordingBtn {
	background: none;
	border: none;
	cursor: pointer;
	font-size: 100%;
	font-weight: bold;
	left: 12px;
	outline: none;
	padding: 0;
	position: absolute;
	top: 18px;
}

.sapUiSupportIntToggleRecordingBtn {
	line-height: 30px;
	margin-right: 5px;
	background: none;
	border: none;
	cursor: pointer;
	font-size: 100%;
	font-weight: bold;
	outline: none;
	padding: 0;
}

.sapUiSupportIntToggleRecordingBtn::before,
#sapUiSupportPerfToggleRecordingBtn::before {
	border: solid 5px #bf3020;
	border-radius: 5px;
	content: '';
	display: inline-block;
	height: 0;
	margin-right: 4px;
	width: 0;
}

.sapUiSupportIntToggleRecordingBtn::after,
#sapUiSupportPerfToggleRecordingBtn::after {
	color: #bf3020;
	content: attr(data-state);
}

.sapUiSupportIntToggleRecordingBtn[data-state^="Start recording"]::before,
#sapUiSupportPerfToggleRecordingBtn[data-state^="Start recording"]::before {
	border-color: transparent transparent transparent #333;
	border-radius: 0;
	border-style: solid;
	border-width: 5px 0 5px 10px;
	height: 0;
	width: 0;
}

.sapUiSupportIntToggleRecordingBtn[data-state^="Start recording"]::after,
#sapUiSupportPerfToggleRecordingBtn[data-state^="Start recording"]::after {
	color: #333;
}

.sapUiSupportIntRecordingInfo {
	margin-right: 5px;
	margin-top: 8px;
	float: right;
}

.sapUiSupportIntClearBtn{
	background-color: #F2F2F2;
	border-radius: 3px;
}

.sapUiSupportIntExportBtn {
	margin-left: 5px;
}

.sapUiSupportIntImportBtn {
	margin-left: 5px;
}

.sapUiSupportIntImportExportBtn {
	background-color: #417BAB;
	color: white;
	border-radius: 3px;
	border-color: #417BAB;
	float: right;
}

.sapUiFormResGridCont > .sapUiFormElementLbl.sapUiRespGridBreak {
	min-height: 15px;
}

/* ================================================================================================================== */
/* FileUpload control used in Interaction tab */
/* ================================================================================================================== */

.sapUiSupportIntFupInputMask {  /* the element masking the real (but hidden) file input, so the clickable area has exactly the same size as the visible control */
	display: inline-block;
	position: absolute;
	right: 0;
	overflow: hidden;
	width: 60px;
	float: right;
	height: 26px;
}

.sapUiSupportIntFupInputMask > input { /* the real, but hidden file input */
	position: absolute;
	opacity: 0;
	top: 0px;
	bottom: 0px;
	cursor: pointer;
	cursor: hand;
	left: -4em;       /* avoid the input field behind the file chooser */
	font-size: 500px; /* to make the field high enough for most themes; for themes with very large fonts this needs to be increased further */
}

html[data-sap-ui-browser^="ie"] .sapUiSupportIntFup > form input {
	display: block;
}

html[data-sap-ui-browser^="sf"] .sapUiSupportIntFupInputMask > input, /* for Safari and Chrome the file input is not clickable with opacity "0" */
html[data-sap-ui-browser^="cr"] .sapUiSupportIntFupInputMask > input {
	position: relative;
	left: auto;
	opacity: 0.01;
}

html[data-sap-ui-browser^="cr"] .sapUiSupportIntFupInputMask > input {
	float: right;
}

.sapUiSupportIntODataLbl input[type=checkbox] {
	position: relative;
	vertical-align: middle;
	bottom: 1px;
}


text:
class CreateApplications < ActiveRecord::Migration[5.0]
  def change
    create_table :applications do |t|
      t.integer :status
      t.datetime :first_submitted_on
      t.datetime :approved_on
      t.references :friend, index: true
      t.string :category

      t.timestamps
    end
  end
end


text:
<?php

namespace Admin\Form;

use Landing\Entity\Menu as MenuEntity;
use Zend\Filter;
use Zend\Form\Element;
use Zend\Form\Form as ZendForm;
use Zend\InputFilter;

class Menu extends ZendForm
{
    public function __construct(\Application\Controller\AbstractActionController $controller, $name = 'new')
    {
        parent::__construct();
        $this->setAttribute('method', 'post');
        $this->setAttribute('role', 'form');
        $this->setAttribute('class', 'form form-horizontal');
        $this->setAttribute('id', 'menuForm');
        $this->getInputFilter();

        $this->add([
            'name'  => 'id',
            'type'  => 'hidden',
        ]);

        $this->add([
            'type'       => 'Zend\Form\Element\Select',
            'name'       => 'type',
            'attributes' => [
                'class'    => 'form-control col-xs-7',
                'required' => true,
            ],
            'options' => [
                'label'         => 'Type',
                'value_options' => [
                    'static'   => 'Static',
                    'article'  => 'Article',
                    'category' => 'Category',
                    'external' => 'External',
                ],
            ],
        ]);

        $this->add([
            'type'       => 'Zend\Form\Element\Text',
            'name'       => 'label',
            'attributes' => [
                'class'    => 'form-control col-xs-7',
                'required' => true,
            ],
            'options' => [
                'label' => 'Label',
            ],
        ]);

        $this->add([
            'type'    => 'Zend\Form\Element\Text',
            'name'    => 'labelAr',
            'options' => [
                'label' => 'Arabic Label',
            ],
            'attributes' => [
                'class'    => 'form-control col-xs-7',
                'required' => true,
            ],
        ]);

        $this->add([
            'type'    => 'Zend\Form\Element\Text',
            'name'    => 'value',
            'options' => [
                'label' => 'Url Key',
            ],
            'attributes' => [
                'class'    => 'form-control col-xs-7 custom-modal',
                'required' => true,
            ],
        ]);

        $this->add([
            'type'    => 'Zend\Form\Element\Text',
            'name'    => 'valueAr',
            'options' => [
                'label' => 'Arabic Url Key',
            ],
            'attributes' => [
                'class'    => 'form-control col-xs-7 custom-modal',
                'required' => true,
            ],
        ]);

        $this->add([
            'type'       => 'Zend\Form\Element\Number',
            'name'       => 'orderNumber',
            'attributes' => [
                'class'    => 'form-control col-xs-7',
                'required' => true,
            ],
            'options' => [
                'label' => 'Order Number',
            ],
            /*
            'validators' => [
                'name' => 'Callback',
                'options' => [
                    'callback' => function($orderNumber) {
                        if ($orderNumber == 1) {
                            return 'abc';
                        }
                    }
                ],
            ],
            */
        ]);

        $em = $controller->getEntityManager();
        $rootMenus = $em->getRepository('Landing\Entity\Menu')->findBy(['parentMenu' => null]);
        $parentMenuOptions = [];
        $parentMenuOptions['0'] = 'No parent menu';
        foreach ($rootMenus as $menu) {
            $parentMenuOptions[$menu->getId()] = $menu->getLabel();
        }
        $this->add([
            'type'       => 'Zend\Form\Element\Select',
            'name'       => 'parentMenu',
            'attributes' => [
                'class'    => 'form-control col-xs-7',
                'required' => true,
            ],
            'options' => [
                'label'         => 'Parent Menu',
                'value_options' => $parentMenuOptions,
            ],
        ]);

        $this->add([
            'type'       => 'Zend\Form\Element\Checkbox',
            'name'       => 'showMenu',
            'attributes' => [
                'class' => '',
            ],
            'options' => [
                'label' => 'Show in top menu',
            ],
        ]);

        $this->add(new Element\Csrf('security'));

        $this->add([
            'name'       => 'send',
            'type'       => 'Submit',
            'attributes' => [
                'value' => 'Submit',
                'class' => 'btn btn-primary',
            ],
        ]);

        // set input filter
        $this->setInputFilter($this->createInputFilter());
    }

    public function createInputFilter()
    {
        $inputFilter = new InputFilter\InputFilter();

        $type = new InputFilter\Input('type');
        $type->setRequired(true);
        $inputFilter->add($type);

        $value = new InputFilter\Input('value');
        $value->setRequired(true);
        $inputFilter->add($value);

        $valueAr = new InputFilter\Input('valueAr');
        $valueAr->setRequired(true);
        $inputFilter->add($valueAr);

        $label = new InputFilter\Input('label');
        $label->setRequired(true);
        $inputFilter->add($label);

        $labelAr = new InputFilter\Input('labelAr');
        $labelAr->setRequired(true);
        $inputFilter->add($labelAr);

        $orderNumber = new InputFilter\Input('orderNumber');
        $orderNumber->setRequired(true);
        $inputFilter->add($orderNumber);

        return $inputFilter;
    }

    public function save($controller)
    {
        $data = $this->getData();
        //var_dump($data);die;
        if ($data['type'] == 'static') {
            try {
                $url = $controller->url()->fromRoute($data['value']);
                $urlAr = $controller->url()->fromRoute($data['valueAr']);
                //var_dump($url);die;
            } catch (\Exception $e) {
                $controller->flashMessenger()->addErrorMessage('Your static route is not found.');

                return $controller->redirect()->toRoute('zfcadmin/menu');
            }
        }
        if ((int) $data['id'] > 0) {
            $menu = $controller->getEntityManager()->getRepository('Landing\Entity\Menu')->find((int) $data['id']);
        } else {
            $menu = new MenuEntity();
        }

        $data['parentMenu'] = $controller->find('Landing\Entity\Menu', (int) $data['parentMenu']);

        $menu->setData($data);
        if ((int) $data['id'] > 0) {
            $controller->getEntityManager()->merge($menu);
        } else {
            $controller->getEntityManager()->persist($menu);
        }
        $controller->getEntityManager()->flush();
    }
}


text:
<?php

namespace PiApp\AdminBundle\Manager;

use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\HttpFoundation\RedirectResponse;

use PiApp\AdminBundle\Builder\PiFormBuilderManagerInterface;
use PiApp\AdminBundle\Exception\FormbuilderException;

/**
* Description of the Abstract Form builder manager
*
* @category   Admin_Managers
* @package    Manager
*
* @author Etienne de Longeaux <etienne.delongeaux@gmail.com>
*/
class PiFormBuilderManager extends AbstractType implements PiFormBuilderManagerInterface
{
    /**
     * Variable names of the various blocks of the form.
     */
    const CONTENT_RENDER_TITLE    = 'renderTitle';
    const CONTENT_RENDER_DESC    = 'renderDescriptif';
    const CONTENT_RENDER_FORM    = 'renderForm';
    const SCRIPT_RENDER_FORM    = 'renderScript';

    /**
     * @var \Symfony\Component\DependencyInjection\ContainerInterface
     */
    protected $container;

    /**
     * @var \Doctrine\ORM\EntityManager
     */
    protected $_em;

    /**
     * @var string locale value
     */
    protected $_locale;

    /**
     * @var \
     */
    protected $_form;
    protected $_data;
    protected $_createentity;

    protected $_view;
    protected $_id_widget;
    protected $_id_block;
    protected $_id_form;
    protected $_performName;
    protected $_message;
    protected $_xmlconfig;

    protected $_form_template;
    protected $_form_name;

    /**
     * @var \
     */
    protected $_controls;

    /**
     * Type of the form
     *
     * @var string
     * @access  protected
     */
    protected $_type_form;

    /**
     * @var array
     * @static
     */
    protected static $_types_form = array('zend', 'symfony');

    /**
     * @var ARRAY
     */
    protected static $_content = array();

    /**
     * Constructor.
     *
     * @param ContainerInterface $container The service container
     * @param  string         $container            name of formbuiler container.
     * @param  string         $actionName            name of action.
     *
     * @author (c) Etienne de Longeaux <etienne_delongeaux@hotmail.com>
     * @since 2012-06-26
     */
    public function __construct(ContainerInterface $containerService, $container = '', $actionName = '', $type_form = '', $form_template = 'model_form_builder.html.twig', $form_name = "myform")
    {
        $this->container        = $containerService;
        $this->_em                = $this->container->get('doctrine')->getManager();
        $this->_locale            = $this->container->get('request')->getLocale();
        $this->_id_widget        = $this->container->get('request')->get('id_widget', null);
        $this->_id_block        = $this->container->get('request')->get('id_block', null);
        $this->_id_form            = $this->container->get('request')->get('id_form', null);
        $this->_form_template    = $form_template;
        $this->_form_name        = $form_name;

        if (!empty($container) && !empty($actionName) && $this->isServiceSupported($container, $actionName)){
            $this->_type_form = $type_form;
        }
    }

    /**
     * Create the render script.
     *
     * @access private
     * @return void
     *
     * @author (c) Etienne de Longeaux <etienne_delongeaux@hotmail.com>
     */
    public function renderScript(array $option){}

    /**
     *
     *
     * @access public
     * @return void
     *
     * @author (c) Etienne de Longeaux <etienne_delongeaux@hotmail.com>
     * @since 2012-09-11
     */
    public function preEventBindRequest(){}

    /**
     *
     *
     * @access public
     * @return void
     *
     * @author (c) Etienne de Longeaux <etienne_delongeaux@hotmail.com>
     * @since 2012-09-11
     */
    public function preEventActionForm(array $data){}

    /**
     *
     *
     * @access public
     * @return void
     *
     * @author (c) Etienne de Longeaux <etienne_delongeaux@hotmail.com>
     * @since 2012-09-11
     */
    public function postEventActionForm(array $data){}

    /**
     *
     *
     * @access public
     * @return void
     *
     * @author (c) Etienne de Longeaux <etienne_delongeaux@hotmail.com>
     * @since 2012-09-11
     */
    public function XmlConfigWidget(array $data){
        throw FormbuilderException::MethodUnDefined('createXmlConfig');
    }

    /**
     * Sets the service and the action names and return true if the service is supported.
     *
     * @param  string         $container            name of widget container.
     * @param  string         $actionName            name of action.
     * @return boolean
     * @access private
     *
     * @author (c) Etienne de Longeaux <etienne_delongeaux@hotmail.com>
     * @since 2012-06-26
     */
    private function isServiceSupported($container, $actionName)
    {
        if (!isset($GLOBALS['FORM'][strtoupper($container)][strtolower($actionName)]))
            throw FormbuilderException::serviceUndefined(strtolower($actionName), 'FORM', __CLASS__);
        elseif (!$this->container->has($GLOBALS['FORM'][strtoupper($container)][strtolower($actionName)]))
            throw FormbuilderException::serviceNotSupported($GLOBALS['FORM'][strtoupper($container)][strtolower($actionName)]);

        return true;
    }

    /**
     * Return the name form.
     *
     * @access public
     * @return string
     *
     * @author (c) Etienne de Longeaux <etienne_delongeaux@hotmail.com>
     * @since 2012-09-11
     */
    final public function getName()
    {
        return strtolower(str_replace("\\", "", get_class($this)));
    }

    /**
     * Get $_type_form attribut
     *
     * @access public
     * @final
     * @return string
     *
     * @author (c) Etienne de Longeaux <etienne_delongeaux@hotmail.com>
     * @since 2012-09-11
     */
    final public function getTypeForm()
    {
        return $this->_type_form;
    }

    /**
     * Set the block index
     *
     * @param string    index of a block of a page.
     * @access public
     * @final
     * @return void
     *
     * @author (c) Etienne de Longeaux <etienne_delongeaux@hotmail.com>
     * @since 2012-09-11
     */
    final public function setIndexBlock($index)
    {
        $this->_id_block = $index;
    }

    /**
     * Set the widget index
     *
     * @param string    index of a block of a page.
     * @access public
     * @final
     * @return void
     *
     * @author (c) Etienne de Longeaux <etienne_delongeaux@hotmail.com>
     * @since 2012-09-11
     */
    final public function setIndexWidget($index)
    {
        $this->_id_widget = $index;
    }

    /**
     * Set the form name
     *
     * @param string    form name wgich has been submit.
     * @access public
     * @final
     * @return void
     *
     * @author (c) Etienne de Longeaux <etienne_delongeaux@hotmail.com>
     * @since 2012-09-11
     */
    final public function setIndexForm($index)
    {
        $this->_id_form = $index;
    }

    /**
     * Execute the form manager for all models of a container.
     *
     * @param  string         $container            name of widget container.
     * @return boolean
     * @access public
     * @final
     *
     * @author (c) Etienne de Longeaux <etienne_delongeaux@hotmail.com>
     * @since 2012-06-26
     */
    final public function executeAllFormByContainer($container)
    {
        if (!isset($GLOBALS['FORM'][strtoupper($container)]))
            throw FormbuilderException::serviceUndefined(strtolower($container), 'FORM', __CLASS__);

        $results_form = null;
        $all_services = $GLOBALS['FORM'][strtoupper($container)];

        foreach($all_services as $key => $service){
            if ($this->container->has($service)){
                $options = array(
                        'formName'        => $this->_form_name,
                        'formAction'    => $this->container->get('router')->generate('public_importmanagement_widget', array('NoLayout' => true)),
                        'formTitle'        => $this->container->get('translator')->trans('pi.title'),
                        'formSubmit'    => $this->container->get('translator')->trans('pi.register'),
                        //'formDecorator'    => 'ElementFormGenerate.phtml',
                        'DisplayGroup'    => true,
                        //                     'populate'        => array(
                                //                                           'name1'    => 'Mon nom',
                                //                                           'name2'    => 'Mon prénom',
                                //                                           'date'    => App_Tools_Date::dayDatetime()
                                //                                        ),
                );
                $this->container->get($service)->setIndexWidget($this->_id_widget);
                $this->container->get($service)->setIndexBlock($this->_id_block);
                $this->container->get($service)->setIndexForm($this->_id_form);
                $results_form[$key]        = $this->container->get($service)->getContents();
                $results_form[$key][PiFormBuilderManager::CONTENT_RENDER_FORM]    = $this->container->get($service)->execute($options);
                $results_form[$key][PiFormBuilderManager::SCRIPT_RENDER_FORM]    = $this->container->get($service)->renderScript($options);
            }else
                throw FormbuilderException::serviceNotSupported($service);
        }

        return $results_form;
    }

    /**
     * Execute the form builder.
     *
     * <code>
     *  $options = array(
     *             'formName'        => 'myform',
     *             'formAction'    => '/admin/acl/add/type/role',
     *             'formTitle'        => $this->container->get('translator')->trans('List Roles'),
     *             'formSubmit'    => $this->container->get('translator')->trans('Register'),
     *             'formDecorator'    => 'ElementForm.phtml',
     *             'DisplayGroup'    => true,
     *            'populate'        => array(
     *                                  'name1'    => 'Mon nom',
     *                                  'name2'    => 'Mon prénom',
     *                                  'date'    => App_Tools_Date::dayDatetime()
     *                               ),
     *    );
     *   $resultform    = $this->container->get('pi_app_admin.formbuilder_manager.model.activity')->run($options);
     * </code>
     *
     * @param  array        $options    validator options.
     * @return string                    form builder result
     * @access public
     * @final
     *
     * @author (c) Etienne de Longeaux <etienne_delongeaux@hotmail.com>
     * @since 2012-06-26
     */
    final public function execute($options)
    {
        // Chargement de l'action du formulaire.
        if (!isset($options['formAction']) || empty($options['formAction']))
            throw FormbuilderException::optionValueNotSpecified($options['formAction']);

        self::$_content = $options;

        return $this->_execute();

//         try{
//             return $this->_execute();
//         } catch (\Exception $e) {
//             throw FormbuilderException::formbuilderNotConfiguredCorrectly();
//         }
    }

    /**
     * Execute all steps of the form builder.
     *
     * @access private
     * @return
     *
     * @author (c) Etienne de Longeaux <etienne_delongeaux@hotmail.com>
     * @since 2012-06-26
     */
    private function _execute()
    {
        if ($this->getTypeForm() == "zend"){
            // Loading of view
            $this->setView();
            // Set the perform.
            $this->setPerformControls();
        }elseif ($this->getTypeForm() == "symfony"){
            // Initialisation du formulaire
            $this->setForm();
        }

        // Execute the populate or the actions of the form builder validated.
        $this->setControlAction();
        // Create the render form.
        $this->renderForm();

        // It returns the content of the form builder.
        return self::$_content['_form_'];
    }

    /**
     * Loading of view zend_view
     *
     * @access private
     * @return void
     *
     * @author (c) Etienne de Longeaux <etienne_delongeaux@hotmail.com>
     * @since 2012-06-26
     */
    private function setView()
    {
        if ($this->getTypeForm() == "zend"){
            $foundBundle     = $this->container->get('kernel')->getBundle('PiAppTemplateBundle');
            $path             = $foundBundle->getPath() . '/Resources/views/Template/';

            $this->_view      = new \Zend_View(array('basePath' => $path));
            $viewRenderer     = \Zend_Controller_Action_HelperBroker::getStaticHelper('ViewRenderer');
            $viewRenderer->setView($this->_view);
        }
    }

    /**
     * Set the perform.
     *
     * @access private
     * @return
     *
     * @author (c) Etienne de Longeaux <etienne_delongeaux@hotmail.com>
     * @since 2012-06-26
     */
    private function setPerformControls()
    {
        // Set configuration
        $this->setConfig();

        // Loading controls of type "piControl" a form template.
        $this->setControls();

        // Form initialization
        $this->setForm();

        // Loading Decorator
        $this->setDecorators();

        // Loading form.
        $this->setFormByControls();
    }

    /**
     * Set Configuration.
     *
     * @access private
     * @return void
     *
     * @author (c) Etienne de Longeaux <etienne_delongeaux@hotmail.com>
     * @since 2012-06-26
     */
    private function setConfig()
    {
        // Chargement du titre du formulaire.
        if (isset(self::$_content['formTitle']) && !empty(self::$_content['formTitle']))
            $this->_view->formTitle = self::$_content['formTitle'];

        // Chargement du nom du bouton submit.
        if (isset(self::$_content['formSubmit']) && !empty(self::$_content['formSubmit']))
            $this->_view->formSubmit = self::$_content['formSubmit'];

        //$this->_view->translate = $this->container->get('translator');
    }

    /**
     * Loading controls of type "piControl" a form template.
     *
     * @access private
     * @return void
     *
     * @author (c) Etienne de Longeaux <etienne_delongeaux@hotmail.com>
     * @since 2012-06-26
     */
    private function setControls()
    {
        if ($this->getTypeForm() == "zend")
            $this->_controls = $this->getControls();
    }

    /**
     * Loading controls of type "piControl" a form template.
     *
     * @access private
     * @return string    $template    Chemin du template du formulaire à générer.
     *
     * @author (c) Etienne de Longeaux <etienne_delongeaux@hotmail.com>
     * @since 2012-06-26
     */
    private function getControls()
    {
        $template = $this->load();
        return $template->xpath('//piControl');
    }

    /**
     * Loading a template form.
     *
     * @access    private
     * @return    SimpleXMLElement     Objet comportant tous les contrôles du template à parser.
     *
     * @author (c) Etienne de Longeaux <etienne_delongeaux@hotmail.com>
     * @since 2012-06-26
     */
    private function load()
    {
        $buildFormContents     = $this->buildFormZend();
        $cleanContent         = preg_replace('/(<\?{1}[pP\s]{1}.+\?>)/', '', $buildFormContents);
        return simplexml_load_string($cleanContent);
    }

    /**
     * Form initialization.
     *
     * @access private
     * @return void
     *
     * @author (c) Etienne de Longeaux <etienne_delongeaux@hotmail.com>
     * @since 2012-06-26
     */
    private function setForm()
    {
        if ($this->getTypeForm() == "zend")
            $this->_form     = new \Zend_Form();
        elseif ($this->getTypeForm() == "symfony"){
            $parent_class    = "\\" . get_class($this);
            $this->_form    = $this->container->get('form.factory')->create(new $parent_class($this->container));
        }
    }

    /**
     * Create the render form.
     *
     * @access private
     * @return void
     *
     * @author (c) Etienne de Longeaux <etienne_delongeaux@hotmail.com>
     */
    private function renderForm()
    {
        if ($this->getTypeForm() == "zend"){
            self::$_content['_form_'] = $this->_form->render();
        }elseif ($this->getTypeForm() == "symfony"){
            $response    = $this->container->get('templating')->renderResponse("PiAppTemplateBundle:Template\\Form:{$this->_form_template}", array(
                    'form'        => $this->_form->createView(),
                    'id_form'    => $this->_form->getName(),
                    'id_block'    => $this->_id_block,
                    'id_widget'    => $this->_id_widget,
                    'form_name' => $this->_form_name,
            ));
            self::$_content['_form_'] = $response->getContent();
        }
    }

    /**
     * Initialisation du formulaire
     *
     * @access private
     * @return void
     *
     * @author (c) Etienne de Longeaux <etienne_delongeaux@hotmail.com>
     * @since 2012-06-26
     */
    private function setDecorators()
    {
        if (isset(self::$_content['formDecorator']) && !empty(self::$_content['formDecorator']))
            $this->_form->setDecorators( array( array('ViewScript', array('viewScript' => 'Form/'. self::$_content['formDecorator']))));
        else
            $this->_form->setDecorators( array( array('ViewScript', array('viewScript' => 'Form/'. $this->_form_template))));
    }

    /**
     * Chargement des contrôles via un template de formulaire.
     *
     * @access    private
     * @return    Zend_Form     Objet du formulaire une foix le template parsé et le formulaire initialisé.
     *
     * @author Etienne de Longeaux <etienne.delongeaux@gmail.com>
     * @since 2012-06-26
     */
    private function setFormByControls()
    {
        //set instance
        $Allgroup            = array();

//         $instance             = $this->_session->_addInstance();
//         $instanceElement     = $this->_form->createElement('hidden', 'form_instance');
//         $instanceElement->setValue($instance);
//         $this->_form->addElement($instanceElement);

        if ($this->_controls) {
            foreach ($this->_controls as $control) {
                $attribs     = $control->attributes();
                $id         = (string)$attribs['id'];
                $type         = (string)$attribs['type'];

                $this->_AllTypesControls[$type] = $type;

                if ( ($type == "select")) {
                    $opts            = explode(';', (string)$attribs['opt']);
                    foreach ($opts as $opts => $values) {
                        $v    = explode('_', $values);
                        $_o = $v[0];
                        $_v = $v[1];
                        $options[$_o]         = $_v;
                    }
                }

                unset($attribs['id']);
                unset($attribs['type']);

                if (isset($attribs['label'])) {
                    $label = (string)$attribs['label'];
                    unset($attribs['label']);
                } else {
                    $label = $id; // $view->getTranslation($id);
                    $label = str_replace('_', '_', $label);
                }

                $elet_attrib = array();
                if (isset($attribs['size'])) {
                    $elet_attrib['size'] = (string)$attribs['size'];
                }

                $control = $this->_form->createElement($type, $id, $elet_attrib);
                $control->setLabel($this->container->get('translator')->trans($label))
                ->addFilter('StripTags')
                ->addFilter('StringTrim');

                if (isset($attribs['desc']) && ((string)$attribs['desc'] != '')) {
                    $control->setDescription((string)$attribs['desc']);
                }

                if (isset($attribs['required']) && ((string)$attribs['required'] == 'true')) {
                    $control->setAttrib('required', 'required');
                    $control->setRequired(true);
                }

                if (isset($attribs['pattern']))
                    $control->setAttrib('pattern', (string)$attribs['pattern']);
                if (isset($attribs['maxlength']))
                    $control->setAttrib('maxlength', (string)$attribs['maxlength']);
                if (isset($attribs['minlength']))
                    $control->setAttrib('minlength', (string)$attribs['minlength']);
                if (isset($attribs['data-equals']))
                    $control->setAttrib('data-equals', (string)$attribs['data-equals']);
                if (isset($attribs['rows']))
                    $control->setAttrib('rows', (string)$attribs['rows']);
                if (isset($attribs['cols']))
                    $control->setAttrib('cols', (string)$attribs['cols']);
                if (isset($attribs['width']))
                    $control->setAttrib('width', (string)$attribs['width']);
                if (isset($attribs['class']) && ((string)$attribs['class'] != ''))
                    $control->setAttrib('class', (string)$attribs['class']);
                if (isset($attribs['step']))
                    $control->setAttrib('step', (string)$attribs['step']);

                if ($type == "select")
                    $control->addMultiOptions($options);

                if (isset($attribs['value']))
                    $control->setValue($attribs['value']);

                $control->setAttrib('rel', isset($attribs['group']) ? (string)$attribs['group'] : 'main');

                $this->_form->addElement($control);

                if (isset(self::$_content['DisplayGroup']) && (self::$_content['DisplayGroup'] == true )) {
                    // set the display group
                    $NameGroup = (isset($attribs['group']))? (string)$attribs['group'] : 'main';
                    //$this->_form->addDisplayGroup(array($id), $NameGroup, array('legend' => 'Role'));
                    if (isset($Allgroup[$NameGroup]) && !empty($Allgroup[$NameGroup]))
                        $Allgroup[$NameGroup] = array_merge(array($id), $Allgroup[$NameGroup]);
                    else
                        $Allgroup[$NameGroup] = array($id);
                }
            }
        } else
            throw new \Zend_Exception("Les controls du formulaire n'ont pas pu être chargés !");

        foreach ($Allgroup as $Name => $elements) {
            $elements = array_reverse($elements);
            $this->_form->addDisplayGroup($elements, $Name, array('legend' => 'Role'));
        }
    }

    /**
     * Execute the populate or the actions of the form builder validated.
     *
     * @access private
     * @return Void
     *
     * @author Etienne de Longeaux <etienne.delongeaux@gmail.com>
     * @since 2012-09-11
     */
    private function setControlAction()
    {
        // if the form builder is validated after validation.
        if ( ($this->isSubmitted()) ) {
            // We execute the actions after submitting the form.
            $this->actionSubmit();
            // Redirection
            $new_url     = $this->container->get('bootstrap.RouteTranslator.factory')->getRoute();
            return new RedirectResponse($new_url);
        } else {
            // we create the form builder with populated form values.
            $this->populateForm();
        }
    }

    /**
     * Checks whether the form builder is validated after validation.
     *
     * @access    private
     * @return    boolean
     *
     * @author Etienne de Longeaux <etienne.delongeaux@gmail.com>
     * @since 2012-09-11
     */
    private function isSubmitted()
    {
        if ($this->getName() == $this->_id_form){
            if ($this->getTypeForm() == "zend"){
                $form_instance = $this->container->get('request')->query->get('form_instance');

                if ($form_instance) {
                    $instance = App_Tools_Post::get('form_instance');
                    if ($this->_session->_isValidInstance($instance)) {
                        // IMPORTANT :: permet d'éviter qu'une instance soit utilisé par un robot pour lancer x fois un même formulaire
                        $this->_session->_removeInstance($instance);
                        return true;
                    }
                }
                return false;
            }elseif ($this->getTypeForm() == "symfony"){
                $request = $this->container->get('request');
                if ($request->getMethod() == 'POST') {
                    // we apply the pre event bind request
                    $this->preEventBindRequest();

                    // we bind the form
                    $this->_form->bind($request);

                    if ($this->_form->isValid())
                        return true;
                    else
                        return false;
                }
                return false;
            }
        }
        return false;
    }

    /**
     * Execute the actions after submitting the form.
     *
     * @access private
     * @return void
     *
     * @author Etienne de Longeaux <etienne.delongeaux@gmail.com>
     * @since 2012-06-26
     */
    private function actionSubmit()
    {
        // Checks whether the widget has been to be created or updated.
        $this->getPerformName();

        // Execute the actions of the form builder validated.
        $this->dispatchAction();

        // we set the succes message
        $this->setFlash($this->_message);
    }

    /**
     * Checks whether the widget has been to be created or updated.
     *
     * @access private
     * @return void
     *
     * @author Etienne de Longeaux <etienne.delongeaux@gmail.com>
     * @since 2012-06-26
     */
    private function getPerformName()
    {
        $is_Index_exist = $this->is_Index_exist();

        if ( $is_Index_exist && ($this->_performName == '') ) {
            $this->_performName = 'update';
        }elseif (!$is_Index_exist) {
            $this->_performName = 'insert';
        }
    }

    /**
     * Execute the actions of the form builder validated.
     *
     * @access private
     * @return void
     *
     * @author Etienne de Longeaux <etienne.delongeaux@gmail.com>
     * @since 2012-09-11
     */
    private function dispatchAction()
    {
        // we get the values of the form builder validated.
        if ($this->getTypeForm() == "zend"){
            $this->_data = null;
        }elseif ($this->getTypeForm() == "symfony"){
            $this->_data = $this->_form->getData();
        }

        // we only Execute the actions of the form builder validated.
        if ($this->getName() == $this->_id_form){
            // we Execute the pre event action of the form builder validated.
            $this->preEventActionForm($this->_data);

            // we create the xml config value if it is defined in the form builder validated.
            try {
                $XmlConfigWidget = $this->XmlConfigWidget($this->_data);
                if ( is_array($XmlConfigWidget) && (count($XmlConfigWidget)>=1) ){
                    \PiApp\AdminBundle\Util\PiArrayManager::init('1.0', 'UTF-8');
                    $this->_xmlconfig = \PiApp\AdminBundle\Util\PiArrayManager::createXML('config', $XmlConfigWidget['xml'])->saveXML();
                }else
                    $this->_xmlconfig = null;
            } catch (\Exception $e) {
                $this->_xmlconfig = null;
            }

            // we create/update a widget if the xml config value is defined.
            try {
                if (!is_null($this->_xmlconfig) && $this->_performName == "insert")
                    $this->insertWidget($XmlConfigWidget['plugin'], $XmlConfigWidget['action']);
                elseif (!is_null($this->_xmlconfig) && $this->_performName == "update") {
                    $this->updateWidget($XmlConfigWidget['plugin'], $XmlConfigWidget['action']);
                }
            } catch (\Exception $e) {
            }

            // we throw the post event action of the form builder validated.
            $this->postEventActionForm($this->_data);
        }
    }

    /**
     * Sets the flash message.
     *
     * @param string $message
     * @param string $type
     *
     * @return void
     * @access private
     *
     * @author Etienne de Longeaux <etienne.delongeaux@gmail.com>
     * @since 2012-09-11
     */
    private function setFlash($message, $type = "notice")
    {
        $this->container->get('request')->getSession()->getFlashBag()->add($type, $message);
    }

    /**
     * Checks whether the identifier of a widget is blank.
     *
     * @access private
     * @return boolean
     *
     * @author Etienne de Longeaux <etienne.delongeaux@gmail.com>
     * @since 2012-09-11
     */
    private function is_Index_exist()
    {
        if (is_null($this->_id_widget) || empty($this->_id_widget))
            return false;
        else
            return true;
    }

    /**
     * Populate the form builder validated.
     *
     * @access private
     * @return void
     *
     * @author Etienne de Longeaux <etienne.delongeaux@gmail.com>
     * @since 2012-06-26
     */
    private function populateForm(){}

    /**
     * Insert widget.
     *
     * @param string        $plugin
     * @param string        $action
     * @param string        $message
     * @access private
     * @return boolean        if the insertion is correct.
     *
     * @author Etienne de Longeaux <etienne.delongeaux@gmail.com>
     * @since 2012-09-11
     */
    private function insertWidget($plugin, $action, $message = "pi.session.flash.right.create")
    {
        try {
            $entity  = new \PiApp\AdminBundle\Entity\Widget();
            $block   = $this->_em->getRepository('PiAppAdminBundle:Block')->find($this->_id_block);

            if ($block instanceof \PiApp\AdminBundle\Entity\BLock){
                $entity->setPlugin($plugin);
                $entity->setAction($action);
                $entity->setBlock($block);
                $entity->setConfigXml($this->_xmlconfig);

                $this->_em->persist($entity);
                $this->_em->flush();
            }

            $this->_message = $message;
            return true;
        } catch (\Exception $e) {
            return false;
        }
    }

    /**
     * Update widget.
     *
     * @param string        $plugin
     * @param string        $action
     * @param string        $message
     * @access private
     * @return boolean        if the updated is correct.
     *
     * @author Etienne de Longeaux <etienne.delongeaux@gmail.com>
     * @since 2012-09-11
     */
    private function updateWidget($plugin, $action, $message = "pi.session.flash.right.update")
    {
        $widget   = $this->_em->getRepository('PiAppAdminBundle:Widget')->find($this->_id_widget);

        try {
            if ($widget instanceof \PiApp\AdminBundle\Entity\Widget){
                $widget->setPlugin($plugin);
                $widget->setAction($action);
                $widget->setConfigXml($this->_xmlconfig);

                $this->_em->persist($widget);
                $this->_em->flush();
            }
            $this->_message = $message;

            return true;
        } catch (\Exception $e) {
            return false;
        }
    }
}


text:
View Pipeline

## Installation
```
npm install tubing-view
```

## Usage
```javascript
var mime = require('mime')
  , http = require('http')
  , ViewPipeline = require('tubing-view').ViewPipeline;

var pipeline = ViewPipeline.configure({
  path: {
    content: process.cwd() + '/content'
  }
}).publish_to(function(err, cmd) {
  function write_res(code, content, content_type) {
    cmd.res.writeHead(code, {
      'Content-Type': content_type ? mime.lookup(content_type) : 'text/plain',
      'Content-Length': content.length
    });
    cmd.res.end(content);
  }

  if (err) return write_res(500, err.stack);
  if (!cmd.content) return write_res(404, 'Not Found');

  write_res(200, cmd.content, cmd.content_type);
});

http.createServer(function(req, res) {
  pipeline.push({
    req: req,
    res: res
  });
}).listen(3000);
```

## License
Copyright (c) 2013 Matt Insler
Licensed under the MIT license.


text:
require "fileutils"
require "open3"

##
# Keep trying a block of code until the code of block yield a true statement or
# raise error after timeout
def keep_trying_till_true timeout = 30
  t_begin = Time.now
  loop do
    if yield
      break
    elsif (Time.now - t_begin) > timeout
      fail "Timeout after trying for #{timeout} seconds"
    else
      sleep 1
    end
  end
end

##
# Get GCP project id from Gcloud SDK
def gcloud_project_id
  stdout = Open3.capture3("gcloud config list project").first
  stdout.scan(/project = (.*)/).first.first
end