text:
require 'rexml/namespace'
require 'rexml/xmltokens'
require 'rexml/attribute'
require 'rexml/syncenumerator'
require 'rexml/parsers/xpathparser'

class Object
  def dclone
    clone
  end
end
class Symbol
  def dclone ; self ; end
end
class Fixnum
  def dclone ; self ; end
end
class Float
  def dclone ; self ; end
end
class Array
  def dclone
    klone = self.clone
    klone.clear
    self.each{|v| klone << v.dclone}
    klone
  end
end

module REXML
  # You don't want to use this class.  Really.  Use XPath, which is a wrapper
  # for this class.  Believe me.  You don't want to poke around in here.
  # There is strange, dark magic at work in this code.  Beware.  Go back!  Go
  # back while you still can!
  class XPathParser
    include XMLTokens
    LITERAL    = /^'([^']*)'|^"([^"]*)"/u

    def initialize( )
      @parser = REXML::Parsers::XPathParser.new
      @namespaces = nil
      @variables = {}
    end

    def namespaces=( namespaces={} )
      Functions::namespace_context = namespaces
      @namespaces = namespaces
    end

    def variables=( vars={} )
      Functions::variables = vars
      @variables = vars
    end

    def parse path, nodeset
     #puts "#"*40
     path_stack = @parser.parse( path )
     #puts "PARSE: #{path} => #{path_stack.inspect}"
     #puts "PARSE: nodeset = #{nodeset.inspect}"
     match( path_stack, nodeset )
    end

    def get_first path, nodeset
     #puts "#"*40
     path_stack = @parser.parse( path )
     #puts "PARSE: #{path} => #{path_stack.inspect}"
     #puts "PARSE: nodeset = #{nodeset.inspect}"
     first( path_stack, nodeset )
    end

    def predicate path, nodeset
      path_stack = @parser.parse( path )
      expr( path_stack, nodeset )
    end

    def []=( variable_name, value )
      @variables[ variable_name ] = value
    end

    # Performs a depth-first (document order) XPath search, and returns the
    # first match.  This is the fastest, lightest way to return a single result.
    #
    # FIXME: This method is incomplete!
    def first( path_stack, node )
      #puts "#{depth}) Entering match( #{path.inspect}, #{tree.inspect} )"
      return nil if path.size == 0

      case path[0]
      when :document
        # do nothing
        return first( path[1..-1], node )
      when :child
        for c in node.children
          #puts "#{depth}) CHILD checking #{name(c)}"
          r = first( path[1..-1], c )
          #puts "#{depth}) RETURNING #{r.inspect}" if r
          return r if r
        end
      when :qname
        name = path[2]
        #puts "#{depth}) QNAME #{name(tree)} == #{name} (path => #{path.size})"
        if node.name == name
          #puts "#{depth}) RETURNING #{tree.inspect}" if path.size == 3
          return node if path.size == 3
          return first( path[3..-1], node )
        else
          return nil
        end
      when :descendant_or_self
        r = first( path[1..-1], node )
        return r if r
        for c in node.children
          r = first( path, c )
          return r if r
        end
      when :node
        return first( path[1..-1], node )
      when :any
        return first( path[1..-1], node )
      end
      return nil
    end

    def match( path_stack, nodeset )
      #puts "MATCH: path_stack = #{path_stack.inspect}"
      #puts "MATCH: nodeset = #{nodeset.inspect}"
      r = expr( path_stack, nodeset )
      #puts "MAIN EXPR => #{r.inspect}"
      r
    end

    private

    # Returns a String namespace for a node, given a prefix
    # The rules are:
    #
    #  1. Use the supplied namespace mapping first.
    #  2. If no mapping was supplied, use the context node to look up the namespace
    def get_namespace( node, prefix )
      if @namespaces
        return @namespaces[prefix] || ''
      else
        return node.namespace( prefix ) if node.node_type == :element
        return ''
      end
    end

    # Expr takes a stack of path elements and a set of nodes (either a Parent
    # or an Array and returns an Array of matching nodes
    ALL = [ :attribute, :element, :text, :processing_instruction, :comment ]
    ELEMENTS = [ :element ]
    def expr( path_stack, nodeset, context=nil )
      #puts "#"*15
      #puts "In expr with #{path_stack.inspect}"
      #puts "Returning" if path_stack.length == 0 || nodeset.length == 0
      node_types = ELEMENTS
      return nodeset if path_stack.length == 0 || nodeset.length == 0
      while path_stack.length > 0
        #puts "#"*5
        #puts "Path stack = #{path_stack.inspect}"
        #puts "Nodeset is #{nodeset.inspect}"
        if nodeset.length == 0
          path_stack.clear
          return []
        end
        case (op = path_stack.shift)
        when :document
          nodeset = [ nodeset[0].root_node ]
          #puts ":document, nodeset = #{nodeset.inspect}"

        when :qname
          #puts "IN QNAME"
          prefix = path_stack.shift
          name = path_stack.shift
          nodeset.delete_if do |node|
            # FIXME: This DOUBLES the time XPath searches take
            ns = get_namespace( node, prefix )
            #puts "NS = #{ns.inspect}"
            #puts "node.node_type == :element => #{node.node_type == :element}"
            if node.node_type == :element
              #puts "node.name == #{name} => #{node.name == name}"
              if node.name == name
                #puts "node.namespace == #{ns.inspect} => #{node.namespace == ns}"
              end
            end
            !(node.node_type == :element and
              node.name == name and
              node.namespace == ns )
          end
          node_types = ELEMENTS

        when :any
          #puts "ANY 1: nodeset = #{nodeset.inspect}"
          #puts "ANY 1: node_types = #{node_types.inspect}"
          nodeset.delete_if { |node| !node_types.include?(node.node_type) }
          #puts "ANY 2: nodeset = #{nodeset.inspect}"

        when :self
          # This space left intentionally blank

        when :processing_instruction
          target = path_stack.shift
          nodeset.delete_if do |node|
            (node.node_type != :processing_instruction) or
            ( target!='' and ( node.target != target ) )
          end

        when :text
          nodeset.delete_if { |node| node.node_type != :text }

        when :comment
          nodeset.delete_if { |node| node.node_type != :comment }

        when :node
          # This space left intentionally blank
          node_types = ALL

        when :child
          new_nodeset = []
          nt = nil
          nodeset.each do |node|
            nt = node.node_type
            new_nodeset += node.children if nt == :element or nt == :document
          end
          nodeset = new_nodeset
          node_types = ELEMENTS

        when :literal
          return path_stack.shift

        when :attribute
          new_nodeset = []
          case path_stack.shift
          when :qname
            prefix = path_stack.shift
            name = path_stack.shift
            for element in nodeset
              if element.node_type == :element
                #puts "Element name = #{element.name}"
                #puts "get_namespace( #{element.inspect}, #{prefix} ) = #{get_namespace(element, prefix)}"
                attrib = element.attribute( name, get_namespace(element, prefix) )
                #puts "attrib = #{attrib.inspect}"
                new_nodeset << attrib if attrib
              end
            end
          when :any
            #puts "ANY"
            for element in nodeset
              if element.node_type == :element
                new_nodeset += element.attributes.to_a
              end
            end
          end
          nodeset = new_nodeset

        when :parent
          #puts "PARENT 1: nodeset = #{nodeset}"
          nodeset = nodeset.collect{|n| n.parent}.compact
          #nodeset = expr(path_stack.dclone, nodeset.collect{|n| n.parent}.compact)
          #puts "PARENT 2: nodeset = #{nodeset.inspect}"
          node_types = ELEMENTS

        when :ancestor
          new_nodeset = []
          nodeset.each do |node|
            while node.parent
              node = node.parent
              new_nodeset << node unless new_nodeset.include? node
            end
          end
          nodeset = new_nodeset
          node_types = ELEMENTS

        when :ancestor_or_self
          new_nodeset = []
          nodeset.each do |node|
            if node.node_type == :element
              new_nodeset << node
              while ( node.parent )
                node = node.parent
                new_nodeset << node unless new_nodeset.include? node
              end
            end
          end
          nodeset = new_nodeset
          node_types = ELEMENTS

        when :predicate
          new_nodeset = []
          subcontext = { :size => nodeset.size }
          pred = path_stack.shift
          nodeset.each_with_index { |node, index|
            subcontext[ :node ] = node
            #puts "PREDICATE SETTING CONTEXT INDEX TO #{index+1}"
            subcontext[ :index ] = index+1
            pc = pred.dclone
            #puts "#{node.hash}) Recursing with #{pred.inspect} and [#{node.inspect}]"
            result = expr( pc, [node], subcontext )
            result = result[0] if result.kind_of? Array and result.length == 1
            #puts "#{node.hash}) Result = #{result.inspect} (#{result.class.name})"
            if result.kind_of? Numeric
              #puts "Adding node #{node.inspect}" if result == (index+1)
              new_nodeset << node if result == (index+1)
            elsif result.instance_of? Array
              if result.size > 0 and result.inject(false) {|k,s| s or k}
                #puts "Adding node #{node.inspect}" if result.size > 0
                new_nodeset << node if result.size > 0
              end
            else
              #puts "Adding node #{node.inspect}" if result
              new_nodeset << node if result
            end
          }
          #puts "New nodeset = #{new_nodeset.inspect}"
          #puts "Path_stack  = #{path_stack.inspect}"
          nodeset = new_nodeset
=begin
          predicate = path_stack.shift
          ns = nodeset.clone
          result = expr( predicate, ns )
          #puts "Result = #{result.inspect} (#{result.class.name})"
          #puts "nodeset = #{nodeset.inspect}"
          if result.kind_of? Array
            nodeset = result.zip(ns).collect{|m,n| n if m}.compact
          else
            nodeset = result ? nodeset : []
          end
          #puts "Outgoing NS = #{nodeset.inspect}"
=end

        when :descendant_or_self
          rv = descendant_or_self( path_stack, nodeset )
          path_stack.clear
          nodeset = rv
          node_types = ELEMENTS

        when :descendant
          results = []
          nt = nil
          nodeset.each do |node|
            nt = node.node_type
            results += expr( path_stack.dclone.unshift( :descendant_or_self ),
              node.children ) if nt == :element or nt == :document
          end
          nodeset = results
          node_types = ELEMENTS

        when :following_sibling
          #puts "FOLLOWING_SIBLING 1: nodeset = #{nodeset}"
          results = []
          nodeset.each do |node|
            next if node.parent.nil?
            all_siblings = node.parent.children
            current_index = all_siblings.index( node )
            following_siblings = all_siblings[ current_index+1 .. -1 ]
            results += expr( path_stack.dclone, following_siblings )
          end
          #puts "FOLLOWING_SIBLING 2: nodeset = #{nodeset}"
          nodeset = results

        when :preceding_sibling
          results = []
          nodeset.each do |node|
            next if node.parent.nil?
            all_siblings = node.parent.children
            current_index = all_siblings.index( node )
            preceding_siblings = all_siblings[ 0, current_index ].reverse
            results += preceding_siblings
          end
          nodeset = results
          node_types = ELEMENTS

        when :preceding
          new_nodeset = []
          nodeset.each do |node|
            new_nodeset += preceding( node )
          end
          #puts "NEW NODESET => #{new_nodeset.inspect}"
          nodeset = new_nodeset
          node_types = ELEMENTS

        when :following
          new_nodeset = []
          nodeset.each do |node|
            new_nodeset += following( node )
          end
          nodeset = new_nodeset
          node_types = ELEMENTS

        when :namespace
          #puts "In :namespace"
          new_nodeset = []
          prefix = path_stack.shift
          nodeset.each do |node|
            if (node.node_type == :element or node.node_type == :attribute)
              if @namespaces
                namespaces = @namespaces
              elsif (node.node_type == :element)
                namespaces = node.namespaces
              else
                namespaces = node.element.namesapces
              end
              #puts "Namespaces = #{namespaces.inspect}"
              #puts "Prefix = #{prefix.inspect}"
              #puts "Node.namespace = #{node.namespace}"
              if (node.namespace == namespaces[prefix])
                new_nodeset << node
              end
            end
          end
          nodeset = new_nodeset

        when :variable
          var_name = path_stack.shift
          return @variables[ var_name ]

        # :and, :or, :eq, :neq, :lt, :lteq, :gt, :gteq
        # TODO: Special case for :or and :and -- not evaluate the right
        # operand if the left alone determines result (i.e. is true for
        # :or and false for :and).
        when :eq, :neq, :lt, :lteq, :gt, :gteq, :or
          left = expr( path_stack.shift, nodeset.dup, context )
          #puts "LEFT => #{left.inspect} (#{left.class.name})"
          right = expr( path_stack.shift, nodeset.dup, context )
          #puts "RIGHT => #{right.inspect} (#{right.class.name})"
          res = equality_relational_compare( left, op, right )
          #puts "RES => #{res.inspect}"
          return res

        when :and
          left = expr( path_stack.shift, nodeset.dup, context )
          #puts "LEFT => #{left.inspect} (#{left.class.name})"
          if left == false || left.nil? || !left.inject(false) {|a,b| a | b}
            return []
          end
          right = expr( path_stack.shift, nodeset.dup, context )
          #puts "RIGHT => #{right.inspect} (#{right.class.name})"
          res = equality_relational_compare( left, op, right )
          #puts "RES => #{res.inspect}"
          return res

        when :div
          left = Functions::number(expr(path_stack.shift, nodeset, context)).to_f
          right = Functions::number(expr(path_stack.shift, nodeset, context)).to_f
          return (left / right)

        when :mod
          left = Functions::number(expr(path_stack.shift, nodeset, context )).to_f
          right = Functions::number(expr(path_stack.shift, nodeset, context )).to_f
          return (left % right)

        when :mult
          left = Functions::number(expr(path_stack.shift, nodeset, context )).to_f
          right = Functions::number(expr(path_stack.shift, nodeset, context )).to_f
          return (left * right)

        when :plus
          left = Functions::number(expr(path_stack.shift, nodeset, context )).to_f
          right = Functions::number(expr(path_stack.shift, nodeset, context )).to_f
          return (left + right)

        when :minus
          left = Functions::number(expr(path_stack.shift, nodeset, context )).to_f
          right = Functions::number(expr(path_stack.shift, nodeset, context )).to_f
          return (left - right)

        when :union
          left = expr( path_stack.shift, nodeset, context )
          right = expr( path_stack.shift, nodeset, context )
          return (left | right)

        when :neg
          res = expr( path_stack, nodeset, context )
          return -(res.to_f)

        when :not
        when :function
          func_name = path_stack.shift.tr('-','_')
          arguments = path_stack.shift
          #puts "FUNCTION 0: #{func_name}(#{arguments.collect{|a|a.inspect}.join(', ')})"
          subcontext = context ? nil : { :size => nodeset.size }

          res = []
          cont = context
          nodeset.each_with_index { |n, i|
            if subcontext
              subcontext[:node]  = n
              subcontext[:index] = i
              cont = subcontext
            end
            arg_clone = arguments.dclone
            args = arg_clone.collect { |arg|
              #puts "FUNCTION 1: Calling expr( #{arg.inspect}, [#{n.inspect}] )"
              expr( arg, [n], cont )
            }
            #puts "FUNCTION 2: #{func_name}(#{args.collect{|a|a.inspect}.join(', ')})"
            Functions.context = cont
            res << Functions.send( func_name, *args )
            #puts "FUNCTION 3: #{res[-1].inspect}"
          }
          return res

        end
      end # while
      #puts "EXPR returning #{nodeset.inspect}"
      return nodeset
    end

    ##########################################################
    # FIXME
    # The next two methods are BAD MOJO!
    # This is my achilles heel.  If anybody thinks of a better
    # way of doing this, be my guest.  This really sucks, but
    # it is a wonder it works at all.
    # ########################################################

    def descendant_or_self( path_stack, nodeset )
      rs = []
      #puts "#"*80
      #puts "PATH_STACK = #{path_stack.inspect}"
      #puts "NODESET = #{nodeset.collect{|n|n.inspect}.inspect}"
      d_o_s( path_stack, nodeset, rs )
      #puts "RS = #{rs.collect{|n|n.inspect}.inspect}"
      document_order(rs.flatten.compact)
      #rs.flatten.compact
    end

    def d_o_s( p, ns, r )
      #puts "IN DOS with #{ns.inspect}; ALREADY HAVE #{r.inspect}"
      nt = nil
      ns.each_index do |i|
        n = ns[i]
        #puts "P => #{p.inspect}"
        x = expr( p.dclone, [ n ] )
        nt = n.node_type
        d_o_s( p, n.children, x ) if nt == :element or nt == :document and n.children.size > 0
        r.concat(x) if x.size > 0
      end
    end

    # Reorders an array of nodes so that they are in document order
    # It tries to do this efficiently.
    #
    # FIXME: I need to get rid of this, but the issue is that most of the XPath
    # interpreter functions as a filter, which means that we lose context going
    # in and out of function calls.  If I knew what the index of the nodes was,
    # I wouldn't have to do this.  Maybe add a document IDX for each node?
    # Problems with mutable documents.  Or, rewrite everything.
    def document_order( array_of_nodes )
      new_arry = []
      array_of_nodes.each { |node|
        node_idx = []
        np = node.node_type == :attribute ? node.element : node
        while np.parent and np.parent.node_type == :element
          node_idx << np.parent.index( np )
          np = np.parent
        end
        new_arry << [ node_idx.reverse, node ]
      }
      #puts "new_arry = #{new_arry.inspect}"
      new_arry.sort{ |s1, s2| s1[0] <=> s2[0] }.collect{ |s| s[1] }
    end

    def recurse( nodeset, &block )
      for node in nodeset
        yield node
        recurse( node, &block ) if node.node_type == :element
      end
    end

    # Builds a nodeset of all of the preceding nodes of the supplied node,
    # in reverse document order
    # preceding:: includes every element in the document that precedes this node,
    # except for ancestors
    def preceding( node )
      #puts "IN PRECEDING"
      ancestors = []
      p = node.parent
      while p
        ancestors << p
        p = p.parent
      end

      acc = []
      p = preceding_node_of( node )
      #puts "P = #{p.inspect}"
      while p
        if ancestors.include? p
          ancestors.delete(p)
        else
          acc << p
        end
        p = preceding_node_of( p )
        #puts "P = #{p.inspect}"
      end
      acc
    end

    def preceding_node_of( node )
     #puts "NODE: #{node.inspect}"
     #puts "PREVIOUS NODE: #{node.previous_sibling_node.inspect}"
     #puts "PARENT NODE: #{node.parent}"
      psn = node.previous_sibling_node
      if psn.nil?
        if node.parent.nil? or node.parent.class == Document
          return nil
        end
        return node.parent
        #psn = preceding_node_of( node.parent )
      end
      while psn and psn.kind_of? Element and psn.children.size > 0
        psn = psn.children[-1]
      end
      psn
    end

    def following( node )
      #puts "IN PRECEDING"
      acc = []
      p = next_sibling_node( node )
      #puts "P = #{p.inspect}"
      while p
        acc << p
        p = following_node_of( p )
        #puts "P = #{p.inspect}"
      end
      acc
    end

    def following_node_of( node )
      #puts "NODE: #{node.inspect}"
      #puts "PREVIOUS NODE: #{node.previous_sibling_node.inspect}"
      #puts "PARENT NODE: #{node.parent}"
      if node.kind_of? Element and node.children.size > 0
        return node.children[0]
      end
      return next_sibling_node(node)
    end

    def next_sibling_node(node)
      psn = node.next_sibling_node
      while psn.nil?
        if node.parent.nil? or node.parent.class == Document
          return nil
        end
        node = node.parent
        psn = node.next_sibling_node
        #puts "psn = #{psn.inspect}"
      end
      return psn
    end

    def norm b
      case b
      when true, false
        return b
      when 'true', 'false'
        return Functions::boolean( b )
      when /^\d+(\.\d+)?$/
        return Functions::number( b )
      else
        return Functions::string( b )
      end
    end

    def equality_relational_compare( set1, op, set2 )
      #puts "EQ_REL_COMP(#{set1.inspect} #{op.inspect} #{set2.inspect})"
      if set1.kind_of? Array and set2.kind_of? Array
        #puts "#{set1.size} & #{set2.size}"
        if set1.size == 1 and set2.size == 1
          set1 = set1[0]
          set2 = set2[0]
        elsif set1.size == 0 or set2.size == 0
          nd = set1.size==0 ? set2 : set1
          rv = nd.collect { |il| compare( il, op, nil ) }
          #puts "RV = #{rv.inspect}"
          return rv
        else
          res = []
          enum = SyncEnumerator.new( set1, set2 ).each { |i1, i2|
            #puts "i1 = #{i1.inspect} (#{i1.class.name})"
            #puts "i2 = #{i2.inspect} (#{i2.class.name})"
            i1 = norm( i1 )
            i2 = norm( i2 )
            res << compare( i1, op, i2 )
          }
          return res
        end
      end
      #puts "EQ_REL_COMP: #{set1.inspect} (#{set1.class.name}), #{op}, #{set2.inspect} (#{set2.class.name})"
      #puts "COMPARING VALUES"
      # If one is nodeset and other is number, compare number to each item
      # in nodeset s.t. number op number(string(item))
      # If one is nodeset and other is string, compare string to each item
      # in nodeset s.t. string op string(item)
      # If one is nodeset and other is boolean, compare boolean to each item
      # in nodeset s.t. boolean op boolean(item)
      if set1.kind_of? Array or set2.kind_of? Array
        #puts "ISA ARRAY"
        if set1.kind_of? Array
          a = set1
          b = set2
        else
          a = set2
          b = set1
        end

        case b
        when true, false
          return a.collect {|v| compare( Functions::boolean(v), op, b ) }
        when Numeric
          return a.collect {|v| compare( Functions::number(v), op, b )}
        when /^\d+(\.\d+)?$/
          b = Functions::number( b )
          #puts "B = #{b.inspect}"
          return a.collect {|v| compare( Functions::number(v), op, b )}
        else
          #puts "Functions::string( #{b}(#{b.class.name}) ) = #{Functions::string(b)}"
          b = Functions::string( b )
          return a.collect { |v| compare( Functions::string(v), op, b ) }
        end
      else
        # If neither is nodeset,
        #   If op is = or !=
        #     If either boolean, convert to boolean
        #     If either number, convert to number
        #     Else, convert to string
        #   Else
        #     Convert both to numbers and compare
        s1 = set1.to_s
        s2 = set2.to_s
        #puts "EQ_REL_COMP: #{set1}=>#{s1}, #{set2}=>#{s2}"
        if s1 == 'true' or s1 == 'false' or s2 == 'true' or s2 == 'false'
          #puts "Functions::boolean(#{set1})=>#{Functions::boolean(set1)}"
          #puts "Functions::boolean(#{set2})=>#{Functions::boolean(set2)}"
          set1 = Functions::boolean( set1 )
          set2 = Functions::boolean( set2 )
        else
          if op == :eq or op == :neq
            if s1 =~ /^\d+(\.\d+)?$/ or s2 =~ /^\d+(\.\d+)?$/
              set1 = Functions::number( s1 )
              set2 = Functions::number( s2 )
            else
              set1 = Functions::string( set1 )
              set2 = Functions::string( set2 )
            end
          else
            set1 = Functions::number( set1 )
            set2 = Functions::number( set2 )
          end
        end
        #puts "EQ_REL_COMP: #{set1} #{op} #{set2}"
        #puts ">>> #{compare( set1, op, set2 )}"
        return compare( set1, op, set2 )
      end
      return false
    end

    def compare a, op, b
      #puts "COMPARE #{a.inspect}(#{a.class.name}) #{op} #{b.inspect}(#{b.class.name})"
      case op
      when :eq
        a == b
      when :neq
        a != b
      when :lt
        a < b
      when :lteq
        a <= b
      when :gt
        a > b
      when :gteq
        a >= b
      when :and
        a and b
      when :or
        a or b
      else
        false
      end
    end
  end
end


text:
<!DOCTYPE HTML>

    <title>Hyperspace by HTML5 UP</title>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />

    <link rel="stylesheet" href="assets/css/main.css" />

Welcome

Agenda

Downloads

Feedback Please

Dashboard

Pune Developers Community
#PDCNODE

We will explore Node Js basics.

Explore Agenda

What is Node js

NodeJS Basic concepts

Understanding ExpressJS

Building this with express

Downloads

You will need following stuff for the meetup. Please download it from below

Node JS

GIT

Source files

Download

Feedback Please

Feedbacks are indeed crucial for us. Please let us how we could have been better.

                        <form action="/" method="post" id="feedbacksubmit">

                                Name
                                <input  type="text" id="name" name="name" placeholder="Enter your full name" />

                                Email
                                <input type="email" id="email" name="email" placeholder="Enter your email address" />

                                Feedback
                                <textarea id="message" name="message" placeholder="What's on your mind?"></textarea>

<input type="submit" class="btn btn-submit" value="Send message" />

                        </form>

Meetup Address

                                Manekshaw Hall, Army Institute of Technology
Alandi Road, Dighi Hills, Pune, Maharashtra 411015, Pune

Email

                                cykulkarni@hotmail.com

Phone

                                8805189711

Follow PDC and get latest Updates:

Twitter

Facebook

© Untitled. All rights reserved.

Design: HTML5 UP

redpajama_set_name: RedPajamaGithub


text:
require "mellon"
require "econfig"

module Econfig
  class Keychain
    attr_reader :store

    def initialize(keychain, name)
      @store = ::Mellon::Store.new(name, keychain: keychain)
    end

    def has_key?(key)
      true if store.fetch(key)
    rescue KeyError
      false
    end

    def get(key)
      store[key]
    end

    def set(key, value)
      store[key] = value
    end
  end
end


text:
<?php

class Google_Service_Genomics_ContainerStoppedEvent extends Google_Model
{
  public $actionId;
  public $exitStatus;
  public $stderr;

  public function setActionId($actionId)
  {
    $this->actionId = $actionId;
  }
  public function getActionId()
  {
    return $this->actionId;
  }
  public function setExitStatus($exitStatus)
  {
    $this->exitStatus = $exitStatus;
  }
  public function getExitStatus()
  {
    return $this->exitStatus;
  }
  public function setStderr($stderr)
  {
    $this->stderr = $stderr;
  }
  public function getStderr()
  {
    return $this->stderr;
  }
}


text:
class HTTPRequest:

    def doCreateXmlHTTPRequest(self):
        # Check for IE6/ActiveX
        try:
            res = JS("""new ActiveXObject("Msxml2.XMLHTTP")""")
            return res
        except:
            pass

        # now try all others
        if JS("""typeof $wnd.XMLHttpRequest != 'undefined'"""):
            # IE7+, Mozilla, Safari, ...
           res = JS("""new XMLHttpRequest()""")
           return res
        return None

    def asyncImpl(self, method, user, pwd, url, postData, handler,
                      returnxml, content_type=None, headers=None):
        if headers is None:
            headers = {}
        if user and pwd and not "Authorization" in headers:
            import base64
            headers["Authorization"] = 'Basic %s' % (base64.b64encode('%s:%s' % (user, pwd)))

        if content_type is not None:
            headers["Content-Type"] = content_type
        if not "Content-Type" in headers:
            if returnxml:
                headers["Content-Type"] = "application/xml; charset=utf-8"
            else:
                headers["Content-Type"] = "text/plain; charset=utf-8"
        xmlHttp = self.doCreateXmlHTTPRequest()

        def onreadystatechange(evnt=None):
            global xmlHttp, handler
            if xmlHttp.readyState == 4:
                # For IE:
                JS("delete @{{xmlHttp}}.onreadystatechange;")
                localHandler = handler
                status = xmlHttp.status
                if returnxml:
                    response = xmlHttp.responseXML
                else:
                    response = xmlHttp.responseText;
                handler = None
                xmlHttp = None
                if status == 200 or status == 0:
                    localHandler.onCompletion(response);
                else:
                    localHandler.onError(response, status);
        xmlHttp.onreadystatechange = onreadystatechange

        try:
            xmlHttp.open(method, url, True);
            for h in headers:
                if isinstance(headers[h], basestring):
                    xmlHttp.setRequestHeader(h, str(headers[h]))
                else:
                    hval = ';'.join([str(i) for i in headers[h]])
                    xmlHttp.setRequestHeader(h, hval)
            if postData is None:
                postData = ''
            xmlHttp.send(postData)
        except:
            # For IE:
            JS("delete @{{xmlHttp}}.onreadystatechange;")
            localHandler = handler
            handler = None
            xmlHttp = None
            localHandler.onError(str(sys.exc_info()[1]), "");
            return False
        return True


text:
module CanTango::PermitStore::Execute::Statement
  class Factory
    attr_accessor :rules

    def initialize rules
      @rules = rules
    end

    def methods
      rules.keys
    end

    def actions_for key
      rules[key].keys
    end

    # Example: can([:edit, :manage], [Article, Comment])
    def statements_string
     targets ? create_statements.to_code : nil
    end

    def create_statements
      CanTango::Engine::Permission::Statement::Multi.new rules
    end
  end
end


text:
package com.opengamma.analytics.financial.provider.sensitivity;

import static org.testng.AssertJUnit.assertEquals;
import static org.testng.AssertJUnit.assertFalse;

import org.testng.annotations.Test;

import com.opengamma.analytics.financial.provider.sensitivity.multicurve.ForwardSensitivity;
import com.opengamma.analytics.financial.provider.sensitivity.multicurve.SimplyCompoundedForwardSensitivity;
import com.opengamma.util.test.TestGroup;

/**
 * Test.
 */
@Test(groups = TestGroup.UNIT)
public class ForwardSensitivityTest {
  private static final double VALUE = 12345.6;
  private static final double START = 1.25;
  private static final double END = 1.50;
  private static final double ACCRUAL_FACTOR = 0.251;
  private static final SimplyCompoundedForwardSensitivity SENSITIVITY = new SimplyCompoundedForwardSensitivity(START, END, ACCRUAL_FACTOR, VALUE);

  @Test(expectedExceptions = IllegalArgumentException.class)
  public void testEndBeforeStart() {
    new SimplyCompoundedForwardSensitivity(END, START, ACCRUAL_FACTOR, VALUE);
  }

  @Test
  public void testGetter() {
    assertEquals(START, SENSITIVITY.getStartTime());
    assertEquals(END, SENSITIVITY.getEndTime());
    assertEquals(ACCRUAL_FACTOR, SENSITIVITY.getAccrualFactor());
    assertEquals(VALUE, SENSITIVITY.getValue());
  }

  @Test
  public void testObject() {
    ForwardSensitivity other = new SimplyCompoundedForwardSensitivity(START, END, ACCRUAL_FACTOR, VALUE);
    assertEquals(SENSITIVITY, other);
    assertEquals(SENSITIVITY.hashCode(), other.hashCode());
    other = new SimplyCompoundedForwardSensitivity(START * 0.5, END, ACCRUAL_FACTOR, VALUE);
    assertFalse(SENSITIVITY.equals(other));
    other = new SimplyCompoundedForwardSensitivity(START, END * 1.5, ACCRUAL_FACTOR, VALUE);
    assertFalse(SENSITIVITY.equals(other));
    other = new SimplyCompoundedForwardSensitivity(START, END, ACCRUAL_FACTOR * 1.2, VALUE);
    assertFalse(SENSITIVITY.equals(other));
    other = new SimplyCompoundedForwardSensitivity(START, END, ACCRUAL_FACTOR, VALUE + 1);
    assertFalse(SENSITIVITY.equals(other));
  }

}


text:
<!-- SPDX-License-Identifier: CC-BY-4.0 -->
<!-- Copyright Contributors to the OpenColorIO Project. -->

June 16, 2020

Host: Michael Dolan

Rotating Secretary: Michael Dolan

Attendees:
  * [X] Mark Boorer (_TSC_) - Industrial Light & Magic
  * [X] Sean Cooper (_TSC ACES TAC Rep_) - DNEG
  * [X] Michael Dolan (_TSC Chair_) - Epic Games
  * [X] Carol Payne (_TSC_) - Netflix
  * [X] Doug Walker (_TSC Chief Architect_) - Autodesk
  * [X] Kevin Wheatley (_TSC_) - Framestore
  * [X] Matthias Scharfenberg - Industrial Light & Magic
  * [X] Dennis Adams - Sony
  * [X] Thomas Mansencal - Weta Digital
  * [X] Michael Parsons - MPC
  * [X] Chris Clark - Netflix
  * [X] Rémi Achard - DNEG
  * [X] Troy Sobotka

# **OCIO Configs Working Group Meeting Notes**

* Working group direction:
    - Michael: Goal of group could be to design and develop the next gen ACES
      config, but also to maintain it long-term. Do we want to make it a formal
      working group with dedicated leadership?
    - Thomas: Good to formalize the group. Current ACES config work is done
      when there is time. There's not a good commitment which can lead to
      delays. Group would be good for prioritizing work.
    - Sean: Should it be distinct from OCIO TSC, or a subgroup?
    - Mark: Division of power is better. There's some overlap, but the OCIO TSC
      is more dev centric. This is more user centric.
    - Michael: There could be a formal chair, or co-chairs, but without a
      formalized group.
    - Sean: The TSC has the benefit of governance structure.
    - ACES will likely be involved to support the work, but the goal from our
      previous meeting was for OCIO to own the ACES config.
    - Carol: We just need to make sure the OCIO TSC is represented in the
      group.
    - Michael: Studios will become highly dependent on this config, so it
      will be important work.
    - Mark: Software vendors (i.e. Foundry) will also be dependent on it.
    - Thomas: Vendors are already asking about it.
    - Michael: Anyone interested in leading the group?
    - Sean and Matthias will co-chair.

* Config structure:
    - ACES reference config, studio in a box, or both:
        - Michael: As discussed, could potentially have one code base which can
          create an ACES reference config (minimal), and the big "studio in a
          box" config.
        - Mark: If nobody is using the reference config, there's no point in
          duplicating efforts.
        - Thomas: The smaller config is a subset of the bigger one. May not
          need everything depending on what you are using. A base.
        - Kevin: We will often take a stock config and strip out stuff not
          needed. Depends on distribution. How we generate it could lead to
          module configuration.
        - Doug: Does seem like build settings to select options would be good.
          Pure ACES model is good for OCIO as an ACES product partner, to
          submit the implementation to the ACES logo program.
        - Carol: Something to be said for ACES transforms being builtin to OCIO
          v2. Not needing external files is nice.
        - Mark: If you have multiple things to release, people have to make a
          choice of what they use. People who want the studio in the box will
          be upset depending on what DCCs choose as default. Lose benefit of
          consistency. If we up front have minimal ACES only, that has some
          value. We should be clear about what we're giving out.
        - Matthias: Will the config be OCIO v2 only? Is it backwards
          compatible.
        - Sean: Needs to be backwards compatible. We're probably the wrong
          people to answer this question. Should ask community what they want,
          rather than deciding on something.
        - Thomas: Breaking backwards compatibility makes migration hard.
        - Carol: We might get polarizing opinions.
        - Mark: Almost feel whole idea of giant config is atypical of how OCIO
          works. People are supposed to have their own configs. May as well
          build everything into the library at that point.
        - Carol: Some just use whatever config ships with an application.
        - Michael: Think it is useful to support ACES-only reference for
          checking against ACES, etc.
        - Thomas: ACES would like this config to be "the" config, to make
          exchange between studios easier. Something ready to use out of the
          box seems to be desired.
        - Doug: Some projects, Like MaterialX, want to make this config their
          default.
        - Thomas: That could be done for USD as well.
- Utilizing OCIO v2 BuiltinTransform, and CLF where needed:
    - Michael: The implementation could focus on utilizing BuiltinTransform,
      and CLF where external files are needed, since CLF is the ACES format.
    - Doug: If Academy publishes transforms in CLF as well as CTL, would be
      interesting.
    - Mark: Doesn't hurt to use it.
    - Doug: CLF also supports metadata.
    - Thomas: We currently ship ICC profiles, for things like Adobe tools. Need
      those for wider support. We could provide scripts to help people generate
      ICC profiles. Would result in simpler package.
    - Mark: ICC profiles generated with ociobakelut often need to have
      additional stuff injected into them from an external script. Cant just
      use ociobakelut directly necessarily.
    - Kevin: Repo should mostly be Python code, and generated artifacts.

* Repository:
    - Python code base
    - Store generated config in repo? Or only as build artifact?
        - Mark: Nothing in repo but code.
        - Michael: We discussed previously if we should include the generated
          config in the repo for reference.
        - Thomas: Need everything to go with config. Would be missing LUTs,
          etc. We need to get past that old issue.
        - Matthias: Might be some vendor LUTs that are needed, where it is just
          a curve. Would potentially need to be in version control then.
        - Mark: if the only source is only a LUT.
        - Michael: Thoughts on pulling dependent data from upstream?
        - Mark: Prefer to store it in repo if it's ASCII.
        - Kevin: Need to be careful relying on vendor storage. May not always
          be available.
        - Config repo will only contain config generation code, and text data
          resources where absolutely necessary (i.e. LUT data where no
          BuiltinTransform is available)
    - Compound versioning (OCIO, ACES, semver):
        - Michael: People need to know what they are getting. Sean proposed a
          compound versioning structure previously, to include OCIO version,
          ACES version, and a config release version.
        - Carol: Yes, users need to know what is being used.
        - Mark: Version structure like:
          `<OCIO version>_<ACES version>_<Build/Patch version>`
        - Kevin: Recommend incremental build #.
        - Michael: Could also use metadata to associate with ACES version.
        - Mark: Can reset build number counter at new ACES version or OCIO
          version, etc.
        - Doug: Could be comment in config file that shows what you have.
          Printed out nicely with different components.
        - Mark: There could also just be a text file with the config.
        - **TODO**: Determine how and where to differentiate the config release
          versions.

* CI/CD:
    - Build configs/LUTs for download
        - Use CI to build complete config packages for release and easy
          download.
        - Mark: In releases tab should be multiple entries at a time. Can
          generate: ACES reference config, ACES full config etc. Any variations
          are present for download independently.
    - Validate config results against ground truth (ACES images, CTL)
        - Michael: Proposing (and volunteering) to setup CI system, via GH
          Actions, to validate config transforms against ground truth CLF
          and/or ACES images.
        - Thomas: There is facilities like that now, in the current ACES
          config. Optional utility. Generator is slow.
        - Michael: GH Actions supports 20 concurrent jobs, so can be sped up a
          bit there.

* Config contents:
    - Color space, alias naming
        - Michael: Do we keep names consistent with existing config? A question
          was raised in ocio-dev regarding underscores in alias names. Without
          underscores, many color space names become problematic.
        - Thomas: Make configurable delimiter for future version.
        - Stick with existing names?
        - Thomas: Can change names, but need easy way to migrate. People are
          building pipelines around this to do conversion. If we break
          everything, people will be sad.
        - Kevin: Is there anything wrong with existing names? Or just opinions?
        - Thomas: The later.
        - Kevin: For OCIO v2 we had discussed being able to deprecate color
          space names but maintain backwards compatibility.
        - Doug: The new inactive color space feature supports this, yes.
          Deprecated spaces would work in color space transforms, but not
          discoverable in menus.
        - Kevin: Need survey monkey to get feedback on general opinions of
          naming, etc.
    - Displays, views, reference spaces, looks.
        - Michael: Should displays and views be restructured to use OCIO v2
          features like display reference space and view transform. Might be
          good to organize views by actual display instead of grouping under
          one ACES display.
        - Doug: Current config was setup to avoid display use. Needs to be
          revisited. To what extent do we want to use v2 features. They are
          optional, but would help with working.
        - Mark: Make it v2 as much as possible, and if someone complains,
          make a backwards compatible config off the tail-end of the project.
          Good opportunity to force DCCs to do the right thing. Incentive.
        - Carol: v2 makes things easier to implement. Will want config that
          works and takes advantage of new features.
        - Doug: Good opportunity to ask vendors to improve things. Could put
          together list of minimum expectations: support displays, views,
          looks, etc.
        - Sean: Agree on using displays properly.
        - Matthias: Maintain family names (which group color spaces in some
          DCCs, like Nuke)? Want to keep name similar to aid migration, but
          might want to fix family names.
        - Doug: v2 has option to build hierarchical menus from family.
        - Sean: I think the ACES config families were a reaction to the size
          of the config.
        - Thomas: Worth pinging vendors, to have more people on the table
          discussing that.
        - Sean: Can't blame vendors in previous version. We didn't tell them
          what we were looking for.
        - Kevin: Think the idea of roles appearing in menus was an annoyance.
          Roles should be a Pipeline detail.
        - Michael: The new categories don't work with roles right?
        - Doug: Categories are for reducing color spaces in menus based on use.

* New code base:
    - Doug: Where did we land on whether old code could brought over?
    - Michael: I don't think it can with the current license.
    - Thomas: Would be better to start fresh.
    - Sean: Also thinking to start from scratch. To make it work well for CI
      too.
    - Doug: Agree.
    - Michael: When should we target completion for this project?
    - Doug: OCIO v2 stabilization period over second half of year. Vendors will
      work on incorporating, and find bugs, etc. Want people to start using it
      before that.
    - Thomas: Are builtin transforms being shipped at that point?
    - Doug: ACES transforms are there now. Over stabilization period we could
      increase number of builtin transforms. Not changing API. Just adding stuff.
    - Michael: Can we have something functional by end of year?
    - Sean: Good to have unit test config at feature complete time. Need
      something to get right impression at start.
    - Mark: There will be a long period of requiring v1 configs, until every
      DCC at studios is updated. Might be period where this config can't be
      used.
    - Carol: Some people might not use OCIO v2 until there's a config.
    - Goal is to target reference config at feature complete time, and
      end of year for "studio in a box". This working group will meet at the
      same day and time every other week, for now.


text:
<?xml version="1.0" encoding="UTF-8" ?>
<testsuite tests="0" failures="0" name="Tester" time="0" errors="0" skipped="0">
  <properties>
    <property name="idea.version" value="14.0.2"/>
    <property name="java.runtime.name" value="Java(TM) SE Runtime Environment"/>
    <property name="sun.boot.library.path" value="/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/jre/lib"/>
    <property name="java.vm.version" value="25.25-b02"/>
    <property name="gopherProxySet" value="false"/>
    <property name="java.vm.vendor" value="Oracle Corporation"/>
    <property name="java.vendor.url" value="http://java.oracle.com/"/>
    <property name="path.separator" value=":"/>
    <property name="guice.disable.misplaced.annotation.check" value="true"/>
    <property name="java.vm.name" value="Java HotSpot(TM) 64-Bit Server VM"/>
    <property name="file.encoding.pkg" value="sun.io"/>
    <property name="idea.launcher.port" value="7534"/>
    <property name="user.country" value="US"/>
    <property name="sun.java.launcher" value="SUN_STANDARD"/>
    <property name="sun.os.patch.level" value="unknown"/>
    <property name="java.vm.specification.name" value="Java Virtual Machine Specification"/>
    <property name="user.dir" value="/Users/robert/Documents/devel/sc2geeks/source-code/web-api/app"/>
    <property name="java.runtime.version" value="1.8.0_25-b17"/>
    <property name="java.awt.graphicsenv" value="sun.awt.CGraphicsEnvironment"/>
    <property name="java.endorsed.dirs" value="/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/jre/lib/endorsed"/>
    <property name="os.arch" value="x86_64"/>
    <property name="java.io.tmpdir" value="/var/folders/zd/pw33mg8s53j989m3thyfv7m40000gn/T/"/>
    <property name="line.separator" value="
"/>
    <property name="java.vm.specification.vendor" value="Oracle Corporation"/>
    <property name="os.name" value="Mac OS X"/>
    <property name="classworlds.conf" value="/Users/robert/srv/java/mvn/versions/apache-maven-3.2.2/bin/m2.conf"/>
    <property name="sun.jnu.encoding" value="UTF-8"/>
    <property name="java.library.path" value="/Users/robert/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:."/>
    <property name="java.specification.name" value="Java Platform API Specification"/>
    <property name="java.class.version" value="52.0"/>
    <property name="sun.management.compiler" value="HotSpot 64-Bit Tiered Compilers"/>
    <property name="os.version" value="10.10.3"/>
    <property name="http.nonProxyHosts" value="local|*.local|169.254/16|*.169.254/16"/>
    <property name="user.home" value="/Users/robert"/>
    <property name="user.timezone" value="America/Los_Angeles"/>
    <property name="java.awt.printerjob" value="sun.lwawt.macosx.CPrinterJob"/>
    <property name="java.specification.version" value="1.8"/>
    <property name="idea.launcher.bin.path" value="/Applications/IntelliJ IDEA 14.app/Contents/bin"/>
    <property name="file.encoding" value="UTF-8"/>
    <property name="user.name" value="robert"/>
    <property name="java.class.path" value="/Users/robert/srv/java/mvn/versions/apache-maven-3.2.2/boot/plexus-classworlds-2.5.1.jar:/Applications/IntelliJ IDEA 14.app/Contents/lib/idea_rt.jar"/>
    <property name="org.slf4j.simpleLogger.defaultLogLevel" value="info"/>
    <property name="java.vm.specification.version" value="1.8"/>
    <property name="sun.arch.data.model" value="64"/>
    <property name="java.home" value="/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/jre"/>
    <property name="sun.java.command" value="com.intellij.rt.execution.application.AppMain org.codehaus.classworlds.Launcher -Didea.version=14.0.2 install"/>
    <property name="java.specification.vendor" value="Oracle Corporation"/>
    <property name="user.language" value="en"/>
    <property name="awt.toolkit" value="sun.lwawt.macosx.LWCToolkit"/>
    <property name="java.vm.info" value="mixed mode"/>
    <property name="java.version" value="1.8.0_25"/>
    <property name="java.ext.dirs" value="/Users/robert/Library/Java/Extensions:/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/jre/lib/ext:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java"/>
    <property name="sun.boot.class.path" value="/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/jre/lib/resources.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/jre/lib/rt.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/jre/lib/sunrsasign.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/jre/lib/jsse.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/jre/lib/jce.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/jre/lib/charsets.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/jre/lib/jfr.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/jre/classes"/>
    <property name="java.vendor" value="Oracle Corporation"/>
    <property name="maven.home" value="/Users/robert/srv/java/mvn/versions/apache-maven-3.2.2"/>
    <property name="file.separator" value="/"/>
    <property name="java.vendor.url.bug" value="http://bugreport.sun.com/bugreport/"/>
    <property name="sun.cpu.endian" value="little"/>
    <property name="sun.io.unicode.encoding" value="UnicodeBig"/>
    <property name="socksNonProxyHosts" value="local|*.local|169.254/16|*.169.254/16"/>
    <property name="ftp.nonProxyHosts" value="local|*.local|169.254/16|*.169.254/16"/>
    <property name="sun.cpu.isalist" value=""/>
  </properties>
</testsuite>


text:
var BaseAssistant = Class.create({
  initialize: function() {
    this.appMenuItems = []
    this.appMenuItems.push(Mojo.Menu.editItem)
    if(!this.hidePreferences) this.appMenuItems.push({label: "Preferences", command: "preferences"})
    this.appMenuItems.push({label: "Logout", command: "logout"})
    this.appMenuItems.push({label: "Help", command: Mojo.Menu.helpCmd})
  },

  setup: function() {
    this.controller.setupWidget("spinner", {spinnerSize: Mojo.Widget.spinnerLarge}, {})

    this.controller.setupWidget(
      Mojo.Menu.appMenu,
      {omitDefaultItems: true},
      {visible: true, items: this.appMenuItems}
    )
  },

  ready: function() {
  },

  activate: function() {
    this.controller.stageController.setWindowOrientation(Preferences.allowLandscape() ? "free" : "up")
  },

  deactivate: function() {
  },

  cleanup: function() {
  },

  spinnerOn: function(message) {
    var spinner = this.controller.sceneElement.querySelector(".spinner")
    spinner.mojo.start()
    this.controller.get("spinner-scrim").show()

    var spinnerMessage = this.controller.get("spinner-message")

    if(!spinnerMessage) {
      spinner.insert({after: '

'})
      spinnerMessage = this.controller.get("spinner-message")
    }

    spinnerMessage.update(message || "")
  },

  spinnerOff: function() {
    var message = this.controller.get("spinner-message")

    if(message) {
      message.remove()
      this.controller.sceneElement.querySelector(".spinner").mojo.stop()
      this.controller.get("spinner-scrim").hide()
    }
  },

  handleCommand: function(event) {
    if(Mojo.Event.command === event.type) {
      if(Mojo.Menu.helpCmd == event.command) {
        this.controller.stageController.pushScene("help")
        event.stop()
      }
      else if("preferences" == event.command) {
        this.controller.stageController.pushScene("preferences")
        event.stop()
      }
      else if("logout" == event.command) {
        var creds = new Credentials()
        creds.username = null
        creds.password = null
        creds.save()
        this.controller.stageController.swapScene("login")
      }
      else if("add" == event.command) {
        this.controller.stageController.pushScene("add")
      }
    }
  }
})


text:
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

/*
 *
 * Date:    31 August 2002
 * SUMMARY: RegExp conformance test
 * See http://bugzilla.mozilla.org/show_bug.cgi?id=165353
 *
 */
//-----------------------------------------------------------------------------
var i = 0;
var BUGNUMBER = 165353;
var summary = 'RegExp conformance test';
var status = '';
var statusmessages = new Array();
var pattern = '';
var patterns = new Array();
var string = '';
var strings = new Array();
var actualmatch = '';
var actualmatches = new Array();
var expectedmatch = '';
var expectedmatches = new Array();

pattern = /^([a-z]+)*[a-z]$/;
status = inSection(1);
string = 'a';
actualmatch = string.match(pattern);
expectedmatch = Array('a', undefined);
addThis();

status = inSection(2);
string = 'ab';
actualmatch = string.match(pattern);
expectedmatch = Array('ab', 'a');
addThis();

status = inSection(3);
string = 'abc';
actualmatch = string.match(pattern);
expectedmatch = Array('abc', 'ab');
addThis();

string = 'www.netscape.com';
status = inSection(4);
pattern = /^(([a-z]+)*[a-z]\.)+[a-z]{2,}$/;
actualmatch = string.match(pattern);
expectedmatch = Array('www.netscape.com', 'netscape.', 'netscap');
addThis();

// add one more capturing parens to the previous regexp -
status = inSection(5);
pattern = /^(([a-z]+)*([a-z])\.)+[a-z]{2,}$/;
actualmatch = string.match(pattern);
expectedmatch = Array('www.netscape.com', 'netscape.', 'netscap', 'e');
addThis();

//-------------------------------------------------------------------------------------------------
test();
//-------------------------------------------------------------------------------------------------

function addThis()
{
  statusmessages[i] = status;
  patterns[i] = pattern;
  strings[i] = string;
  actualmatches[i] = actualmatch;
  expectedmatches[i] = expectedmatch;
  i++;
}

function test()
{
  enterFunc ('test');
  printBugNumber(BUGNUMBER);
  printStatus (summary);
  testRegExp(statusmessages, patterns, strings, actualmatches, expectedmatches);
  exitFunc ('test');
}


text:
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include "LoadImageModule.hpp"
#include "../framework/types/Matrix.hpp"

using namespace std;
using namespace uipf;

/*

*/
void LoadImageModule::run( DataManager& data) const
{
	 using namespace cv;

	  Mat image;
	  std::string strFilename = data.getParam<std::string>("filename","");
	  // check whether to load the image in grayscale mode, defaults to color
	  if (data.getParam<std::string>("mode","color").compare("grayscale") == 0)
	  {
	    image = imread (strFilename.c_str (), CV_LOAD_IMAGE_GRAYSCALE);	// Read the file
	  }
	  else
	  {
	    image = imread (strFilename.c_str (), CV_LOAD_IMAGE_COLOR);	// Read the file
	  }

	  if (!image.data)// Check for invalid input
	  {
	    throw ErrorException(string("Could not open or find the image: ") + strFilename);
	  }

	  data.setOutputData("image",new Matrix(image));

}

MetaData LoadImageModule::getMetaData() const
{
	map<string, DataDescription> output = {
		{"image", DataDescription(MATRIX, "the loaded image.") }
	};
	map<string, ParamDescription> params = {
		{"filename", ParamDescription("file name of the file to load from.") },
		{"mode", ParamDescription("can be either 'color' or 'grayscale' for whether to load the image in color or grayscale mode. Defaults to 'color'.",true) },
	};

	return MetaData(
		"Load an image from a file.",
		"I/O",
		map<string, DataDescription>(), // no inputs
		output,
		params
	);
}


text:
#include <math.h>
#include <string.h>

#define PY_SSIZE_T_CLEAN
#include <Python.h>
#include <grpc/grpc.h>
#include <grpc/byte_buffer_reader.h>
#include <grpc/support/alloc.h>
#include <grpc/support/slice.h>
#include <grpc/support/time.h>
#include <grpc/support/string_util.h>

#include "grpc/_adapter/_c/types.h"

pygrpc_tag *pygrpc_produce_batch_tag(
    PyObject *user_tag, Call *call, grpc_op *ops, size_t nops) {
  pygrpc_tag *tag = gpr_malloc(sizeof(pygrpc_tag));
  tag->user_tag = user_tag;
  Py_XINCREF(tag->user_tag);
  tag->call = call;
  Py_XINCREF(tag->call);
  tag->ops = gpr_malloc(sizeof(grpc_op)*nops);
  memcpy(tag->ops, ops, sizeof(grpc_op)*nops);
  tag->nops = nops;
  grpc_call_details_init(&tag->request_call_details);
  grpc_metadata_array_init(&tag->request_metadata);
  tag->is_new_call = 0;
  return tag;
}

pygrpc_tag *pygrpc_produce_request_tag(PyObject *user_tag, Call *empty_call) {
  pygrpc_tag *tag = gpr_malloc(sizeof(pygrpc_tag));
  tag->user_tag = user_tag;
  Py_XINCREF(tag->user_tag);
  tag->call = empty_call;
  Py_XINCREF(tag->call);
  tag->ops = NULL;
  tag->nops = 0;
  grpc_call_details_init(&tag->request_call_details);
  grpc_metadata_array_init(&tag->request_metadata);
  tag->is_new_call = 1;
  return tag;
}

pygrpc_tag *pygrpc_produce_server_shutdown_tag(PyObject *user_tag) {
  pygrpc_tag *tag = gpr_malloc(sizeof(pygrpc_tag));
  tag->user_tag = user_tag;
  Py_XINCREF(tag->user_tag);
  tag->call = NULL;
  tag->ops = NULL;
  tag->nops = 0;
  grpc_call_details_init(&tag->request_call_details);
  grpc_metadata_array_init(&tag->request_metadata);
  tag->is_new_call = 0;
  return tag;
}

void pygrpc_discard_tag(pygrpc_tag *tag) {
  if (!tag) {
    return;
  }
  Py_XDECREF(tag->user_tag);
  Py_XDECREF(tag->call);
  gpr_free(tag->ops);
  grpc_call_details_destroy(&tag->request_call_details);
  grpc_metadata_array_destroy(&tag->request_metadata);
  gpr_free(tag);
}

PyObject *pygrpc_consume_event(grpc_event event) {
  pygrpc_tag *tag;
  PyObject *result;
  if (event.type == GRPC_QUEUE_TIMEOUT) {
    Py_RETURN_NONE;
  }
  tag = event.tag;
  switch (event.type) {
  case GRPC_QUEUE_SHUTDOWN:
    result = Py_BuildValue("iOOOOO", GRPC_QUEUE_SHUTDOWN,
                           Py_None, Py_None, Py_None, Py_None, Py_True);
    break;
  case GRPC_OP_COMPLETE:
    if (tag->is_new_call) {
      result = Py_BuildValue(
          "iOO(ssd)[(iNOOOO)]O", GRPC_OP_COMPLETE, tag->user_tag, tag->call,
          tag->request_call_details.method, tag->request_call_details.host,
          pygrpc_cast_gpr_timespec_to_double(tag->request_call_details.deadline),
          GRPC_OP_RECV_INITIAL_METADATA,
          pygrpc_cast_metadata_array_to_pyseq(tag->request_metadata), Py_None,
          Py_None, Py_None, Py_None,
          event.success ? Py_True : Py_False);
    } else {
      result = Py_BuildValue("iOOONO", GRPC_OP_COMPLETE, tag->user_tag,
          tag->call ? (PyObject*)tag->call : Py_None, Py_None,
          pygrpc_consume_ops(tag->ops, tag->nops),
          event.success ? Py_True : Py_False);
    }
    break;
  default:
    PyErr_SetString(PyExc_ValueError,
                    "unknown completion type; could not translate event");
    return NULL;
  }
  pygrpc_discard_tag(tag);
  return result;
}

int pygrpc_produce_op(PyObject *op, grpc_op *result) {
  static const int OP_TUPLE_SIZE = 5;
  static const int STATUS_TUPLE_SIZE = 2;
  static const int TYPE_INDEX = 0;
  static const int INITIAL_METADATA_INDEX = 1;
  static const int TRAILING_METADATA_INDEX = 2;
  static const int MESSAGE_INDEX = 3;
  static const int STATUS_INDEX = 4;
  static const int STATUS_CODE_INDEX = 0;
  static const int STATUS_DETAILS_INDEX = 1;
  int type;
  Py_ssize_t message_size;
  char *message;
  char *status_details;
  gpr_slice message_slice;
  grpc_op c_op;
  if (!PyTuple_Check(op)) {
    PyErr_SetString(PyExc_TypeError, "expected tuple op");
    return 0;
  }
  if (PyTuple_Size(op) != OP_TUPLE_SIZE) {
    char *buf;
    gpr_asprintf(&buf, "expected tuple op of length %d", OP_TUPLE_SIZE);
    PyErr_SetString(PyExc_ValueError, buf);
    gpr_free(buf);
    return 0;
  }
  type = PyInt_AsLong(PyTuple_GET_ITEM(op, TYPE_INDEX));
  if (PyErr_Occurred()) {
    return 0;
  }
  c_op.op = type;
  c_op.flags = 0;
  switch (type) {
  case GRPC_OP_SEND_INITIAL_METADATA:
    if (!pygrpc_cast_pyseq_to_send_metadata(
            PyTuple_GetItem(op, INITIAL_METADATA_INDEX),
            &c_op.data.send_initial_metadata.metadata,
            &c_op.data.send_initial_metadata.count)) {
      return 0;
    }
    break;
  case GRPC_OP_SEND_MESSAGE:
    PyString_AsStringAndSize(
        PyTuple_GET_ITEM(op, MESSAGE_INDEX), &message, &message_size);
    message_slice = gpr_slice_from_copied_buffer(message, message_size);
    c_op.data.send_message = grpc_raw_byte_buffer_create(&message_slice, 1);
    gpr_slice_unref(message_slice);
    break;
  case GRPC_OP_SEND_CLOSE_FROM_CLIENT:
    /* Don't need to fill in any other fields. */
    break;
  case GRPC_OP_SEND_STATUS_FROM_SERVER:
    if (!pygrpc_cast_pyseq_to_send_metadata(
            PyTuple_GetItem(op, TRAILING_METADATA_INDEX),
            &c_op.data.send_status_from_server.trailing_metadata,
            &c_op.data.send_status_from_server.trailing_metadata_count)) {
      return 0;
    }
    if (!PyTuple_Check(PyTuple_GET_ITEM(op, STATUS_INDEX))) {
      char *buf;
      gpr_asprintf(&buf, "expected tuple status in op of length %d",
                   STATUS_TUPLE_SIZE);
      PyErr_SetString(PyExc_ValueError, buf);
      gpr_free(buf);
      return 0;
    }
    c_op.data.send_status_from_server.status = PyInt_AsLong(
        PyTuple_GET_ITEM(PyTuple_GET_ITEM(op, STATUS_INDEX), STATUS_CODE_INDEX));
    status_details = PyString_AsString(
        PyTuple_GET_ITEM(PyTuple_GET_ITEM(op, STATUS_INDEX), STATUS_DETAILS_INDEX));
    if (PyErr_Occurred()) {
      return 0;
    }
    c_op.data.send_status_from_server.status_details =
        gpr_malloc(strlen(status_details) + 1);
    strcpy((char *)c_op.data.send_status_from_server.status_details,
           status_details);
    break;
  case GRPC_OP_RECV_INITIAL_METADATA:
    c_op.data.recv_initial_metadata = gpr_malloc(sizeof(grpc_metadata_array));
    grpc_metadata_array_init(c_op.data.recv_initial_metadata);
    break;
  case GRPC_OP_RECV_MESSAGE:
    c_op.data.recv_message = gpr_malloc(sizeof(grpc_byte_buffer *));
    break;
  case GRPC_OP_RECV_STATUS_ON_CLIENT:
    c_op.data.recv_status_on_client.trailing_metadata =
        gpr_malloc(sizeof(grpc_metadata_array));
    grpc_metadata_array_init(c_op.data.recv_status_on_client.trailing_metadata);
    c_op.data.recv_status_on_client.status =
        gpr_malloc(sizeof(grpc_status_code *));
    c_op.data.recv_status_on_client.status_details =
        gpr_malloc(sizeof(char *));
    *c_op.data.recv_status_on_client.status_details = NULL;
    c_op.data.recv_status_on_client.status_details_capacity =
        gpr_malloc(sizeof(size_t));
    *c_op.data.recv_status_on_client.status_details_capacity = 0;
    break;
  case GRPC_OP_RECV_CLOSE_ON_SERVER:
    c_op.data.recv_close_on_server.cancelled = gpr_malloc(sizeof(int));
    break;
  default:
    return 0;
  }
  *result = c_op;
  return 1;
}

void pygrpc_discard_op(grpc_op op) {
  size_t i;
  switch(op.op) {
  case GRPC_OP_SEND_INITIAL_METADATA:
    /* Whenever we produce send-metadata, we allocate new strings (to handle
       arbitrary sequence input as opposed to just lists or just tuples). We
       thus must free those elements. */
    for (i = 0; i < op.data.send_initial_metadata.count; ++i) {
      gpr_free((void *)op.data.send_initial_metadata.metadata[i].key);
      gpr_free((void *)op.data.send_initial_metadata.metadata[i].value);
    }
    gpr_free(op.data.send_initial_metadata.metadata);
    break;
  case GRPC_OP_SEND_MESSAGE:
    grpc_byte_buffer_destroy(op.data.send_message);
    break;
  case GRPC_OP_SEND_CLOSE_FROM_CLIENT:
    /* Don't need to free any fields. */
    break;
  case GRPC_OP_SEND_STATUS_FROM_SERVER:
    /* Whenever we produce send-metadata, we allocate new strings (to handle
       arbitrary sequence input as opposed to just lists or just tuples). We
       thus must free those elements. */
    for (i = 0; i < op.data.send_status_from_server.trailing_metadata_count;
         ++i) {
      gpr_free(
          (void *)op.data.send_status_from_server.trailing_metadata[i].key);
      gpr_free(
          (void *)op.data.send_status_from_server.trailing_metadata[i].value);
    }
    gpr_free(op.data.send_status_from_server.trailing_metadata);
    gpr_free((char *)op.data.send_status_from_server.status_details);
    break;
  case GRPC_OP_RECV_INITIAL_METADATA:
    grpc_metadata_array_destroy(op.data.recv_initial_metadata);
    gpr_free(op.data.recv_initial_metadata);
    break;
  case GRPC_OP_RECV_MESSAGE:
    grpc_byte_buffer_destroy(*op.data.recv_message);
    gpr_free(op.data.recv_message);
    break;
  case GRPC_OP_RECV_STATUS_ON_CLIENT:
    grpc_metadata_array_destroy(op.data.recv_status_on_client.trailing_metadata);
    gpr_free(op.data.recv_status_on_client.trailing_metadata);
    gpr_free(op.data.recv_status_on_client.status);
    gpr_free(*op.data.recv_status_on_client.status_details);
    gpr_free(op.data.recv_status_on_client.status_details);
    gpr_free(op.data.recv_status_on_client.status_details_capacity);
    break;
  case GRPC_OP_RECV_CLOSE_ON_SERVER:
    gpr_free(op.data.recv_close_on_server.cancelled);
    break;
  }
}

PyObject *pygrpc_consume_ops(grpc_op *op, size_t nops) {
  static const int TYPE_INDEX = 0;
  static const int INITIAL_METADATA_INDEX = 1;
  static const int TRAILING_METADATA_INDEX = 2;
  static const int MESSAGE_INDEX = 3;
  static const int STATUS_INDEX = 4;
  static const int CANCELLED_INDEX = 5;
  static const int OPRESULT_LENGTH = 6;
  PyObject *list;
  size_t i;
  size_t j;
  char *bytes;
  size_t bytes_size;
  PyObject *results = PyList_New(nops);
  if (!results) {
    return NULL;
  }
  for (i = 0; i < nops; ++i) {
    PyObject *result = PyTuple_Pack(OPRESULT_LENGTH, Py_None, Py_None, Py_None,
                                    Py_None, Py_None, Py_None);
    PyTuple_SetItem(result, TYPE_INDEX, PyInt_FromLong(op[i].op));
    switch(op[i].op) {
    case GRPC_OP_RECV_INITIAL_METADATA:
      PyTuple_SetItem(result, INITIAL_METADATA_INDEX,
                      list=PyList_New(op[i].data.recv_initial_metadata->count));
      for (j = 0; j < op[i].data.recv_initial_metadata->count; ++j) {
        grpc_metadata md = op[i].data.recv_initial_metadata->metadata[j];
        PyList_SetItem(list, j, Py_BuildValue("ss#", md.key, md.value,
                                              (Py_ssize_t)md.value_length));
      }
      break;
    case GRPC_OP_RECV_MESSAGE:
      if (*op[i].data.recv_message) {
        pygrpc_byte_buffer_to_bytes(
            *op[i].data.recv_message, &bytes, &bytes_size);
        PyTuple_SetItem(result, MESSAGE_INDEX,
                        PyString_FromStringAndSize(bytes, bytes_size));
        gpr_free(bytes);
      } else {
        PyTuple_SetItem(result, MESSAGE_INDEX, Py_BuildValue(""));
      }
      break;
    case GRPC_OP_RECV_STATUS_ON_CLIENT:
      PyTuple_SetItem(
          result, TRAILING_METADATA_INDEX,
          list = PyList_New(op[i].data.recv_status_on_client.trailing_metadata->count));
      for (j = 0; j < op[i].data.recv_status_on_client.trailing_metadata->count; ++j) {
        grpc_metadata md =
            op[i].data.recv_status_on_client.trailing_metadata->metadata[j];
        PyList_SetItem(list, j, Py_BuildValue("ss#", md.key, md.value,
                                              (Py_ssize_t)md.value_length));
      }
      PyTuple_SetItem(
          result, STATUS_INDEX, Py_BuildValue(
              "is", *op[i].data.recv_status_on_client.status,
              *op[i].data.recv_status_on_client.status_details));
      break;
    case GRPC_OP_RECV_CLOSE_ON_SERVER:
      PyTuple_SetItem(
          result, CANCELLED_INDEX,
          PyBool_FromLong(*op[i].data.recv_close_on_server.cancelled));
      break;
    default:
      break;
    }
    pygrpc_discard_op(op[i]);
    PyList_SetItem(results, i, result);
  }
  return results;
}

double pygrpc_cast_gpr_timespec_to_double(gpr_timespec timespec) {
  return timespec.tv_sec + 1e-9*timespec.tv_nsec;
}

/* Because C89 doesn't have a way to check for infinity... */
static int pygrpc_isinf(double x) {
  return x * 0 != 0;
}

gpr_timespec pygrpc_cast_double_to_gpr_timespec(double seconds) {
  gpr_timespec result;
  if (pygrpc_isinf(seconds)) {
    result = seconds > 0.0 ? gpr_inf_future : gpr_inf_past;
  } else {
    result.tv_sec = (time_t)seconds;
    result.tv_nsec = ((seconds - result.tv_sec) * 1e9);
  }
  return result;
}

int pygrpc_produce_channel_args(PyObject *py_args, grpc_channel_args *c_args) {
  size_t num_args = PyList_Size(py_args);
  size_t i;
  grpc_channel_args args;
  args.num_args = num_args;
  args.args = gpr_malloc(sizeof(grpc_arg) * num_args);
  for (i = 0; i < args.num_args; ++i) {
    char *key;
    PyObject *value;
    if (!PyArg_ParseTuple(PyList_GetItem(py_args, i), "zO", &key, &value)) {
      gpr_free(args.args);
      args.num_args = 0;
      args.args = NULL;
      PyErr_SetString(PyExc_TypeError,
                      "expected a list of 2-tuple of str and str|int|None");
      return 0;
    }
    args.args[i].key = key;
    if (PyInt_Check(value)) {
      args.args[i].type = GRPC_ARG_INTEGER;
      args.args[i].value.integer = PyInt_AsLong(value);
    } else if (PyString_Check(value)) {
      args.args[i].type = GRPC_ARG_STRING;
      args.args[i].value.string = PyString_AsString(value);
    } else if (value == Py_None) {
      --args.num_args;
      --i;
      continue;
    } else {
      gpr_free(args.args);
      args.num_args = 0;
      args.args = NULL;
      PyErr_SetString(PyExc_TypeError,
                      "expected a list of 2-tuple of str and str|int|None");
      return 0;
    }
  }
  *c_args = args;
  return 1;
}

void pygrpc_discard_channel_args(grpc_channel_args args) {
  gpr_free(args.args);
}

int pygrpc_cast_pyseq_to_send_metadata(
    PyObject *pyseq, grpc_metadata **metadata, size_t *count) {
  size_t i;
  Py_ssize_t value_length;
  char *key;
  char *value;
  if (!PySequence_Check(pyseq)) {
    return 0;
  }
  *count = PySequence_Size(pyseq);
  *metadata = gpr_malloc(sizeof(grpc_metadata) * *count);
  for (i = 0; i < *count; ++i) {
    PyObject *item = PySequence_GetItem(pyseq, i);
    if (!PyArg_ParseTuple(item, "ss#", &key, &value, &value_length)) {
      Py_DECREF(item);
      gpr_free(*metadata);
      *count = 0;
      *metadata = NULL;
      return 0;
    } else {
      (*metadata)[i].key = gpr_strdup(key);
      (*metadata)[i].value = gpr_malloc(value_length);
      memcpy((void *)(*metadata)[i].value, value, value_length);
      Py_DECREF(item);
    }
    (*metadata)[i].value_length = value_length;
  }
  return 1;
}

PyObject *pygrpc_cast_metadata_array_to_pyseq(grpc_metadata_array metadata) {
  PyObject *result = PyTuple_New(metadata.count);
  size_t i;
  for (i = 0; i < metadata.count; ++i) {
    PyTuple_SetItem(
        result, i, Py_BuildValue(
            "ss#", metadata.metadata[i].key, metadata.metadata[i].value,
            (Py_ssize_t)metadata.metadata[i].value_length));
    if (PyErr_Occurred()) {
      Py_DECREF(result);
      return NULL;
    }
  }
  return result;
}

void pygrpc_byte_buffer_to_bytes(
    grpc_byte_buffer *buffer, char **result, size_t *result_size) {
  grpc_byte_buffer_reader reader;
  grpc_byte_buffer_reader_init(&reader, buffer);
  gpr_slice slice;
  char *read_result = NULL;
  size_t size = 0;
  while (grpc_byte_buffer_reader_next(&reader, &slice)) {
    read_result = gpr_realloc(read_result, size + GPR_SLICE_LENGTH(slice));
    memcpy(read_result + size, GPR_SLICE_START_PTR(slice),
           GPR_SLICE_LENGTH(slice));
    size = size + GPR_SLICE_LENGTH(slice);
    gpr_slice_unref(slice);
  }
  *result_size = size;
  *result = read_result;
}


text:
package org.earthtime.dialogs;

import org.earthtime.dialogs.DialogEditor;
import java.awt.Dimension;
import java.awt.Toolkit;
import org.earthtime.UPb_Redux.ReduxConstants;
import org.earthtime.UPb_Redux.user.ReduxPreferences;

/**
 *
 * @author  James F. Bowring
 */
public class PreferencesEditorDialog extends DialogEditor {

    private ReduxPreferences reduxPreferences = null;

    /** Creates new form SampleEditorDialog
     * @param parent
     * @param myPrefs
     * @param modal
     */
    public PreferencesEditorDialog(
            java.awt.Frame parent,
            boolean modal,
            ReduxPreferences myPrefs) {
        super(parent, modal);

        setReduxPreferences(myPrefs);

        initComponents();

        this.preferencesPanel.setBackground(ReduxConstants.myFractionGreenColor);

        // set radio buttons
        if (reduxPreferences.isFractionDataOverriddenOnImport())
            radioYesOverride.setSelected(true);
        else
            radioNoOverride.setSelected(true);

   //     importLabel.setText
   //             ("
"
   //             + "When importing a fraction with the same name as an existing fraction, "
   //             + "choose whether to override non-zero values:"
   //             + "
");

            setSize(375, 540);
    }

    /**
     *
     * @param width
     * @param height
     */
    @Override
    public void setSize(int width, int height) {
        super.setSize(width, height);

        //Get the screen size
        Toolkit toolkit = Toolkit.getDefaultToolkit();
        Dimension screenSize = toolkit.getScreenSize();

        //Calculate the frame location
        int x = (screenSize.width - getWidth()) / 2;
        int y = (screenSize.height - getHeight()) / 2;

        //Set the new frame location
        setLocation(x, y);
    }

    /**
     *
     * @param size
     */
    @Override
    public void setSize(Dimension size) {
        setSize(size.width, size.height);
    }

    /**
     *
     * @return
     */
    public ReduxPreferences getReduxPreferences() {
        return reduxPreferences;
    }

    /**
     *
     * @param reduxPreferences
     */
    public void setReduxPreferences(ReduxPreferences reduxPreferences) {
        this.reduxPreferences = reduxPreferences;
    }

    /**
     *
     */
    public void close(){
        getReduxPreferences().setFractionDataOverriddenOnImport(radioYesOverride.isSelected());
        super.close();
    }

   /* private void InitSampleFields(){
        // init input fields
        sampleName_text.setDocument(
                new UnDoAbleDocument(sampleName_text, (mySample.getFractions().size() == 0)));
        sampleName_text.setText(getMySample().getSampleName());

        // init display fields
        sampleReduxFileName_label.setText(
                ""
                + getMySample().getReduxSampleFilePath()
                + "");
    }

    private void SaveSampleData(){
        // validate fields - make this more sophisticated
        if (sampleName_text.getText().length() == 0) return;
        getMySample().setSampleName(sampleName_text.getText());

        setInitialized(true);
    }

    */

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        buttonGroupFractionImport = new javax.swing.ButtonGroup();
        preferencesPanel = new javax.swing.JPanel();
        chooseLabel = new javax.swing.JLabel();
        importLabel = new javax.swing.JLabel();
        radioNoOverride = new javax.swing.JRadioButton();
        radioYesOverride = new javax.swing.JRadioButton();
        toolBar = new javax.swing.JPanel();
        done_button = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setAlwaysOnTop(true);

        preferencesPanel.setBackground(new java.awt.Color(204, 255, 255));
        preferencesPanel.setBorder(javax.swing.BorderFactory.createEtchedBorder(javax.swing.border.EtchedBorder.RAISED));

        chooseLabel.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        chooseLabel.setText("Choose preferred behaviors:");

        importLabel.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        importLabel.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        importLabel.setText("
(1) When importing a fraction with the same name as an existing fraction, select yes to automatically override all values:
");
        importLabel.setHorizontalTextPosition(javax.swing.SwingConstants.LEFT);
        importLabel.setVerticalTextPosition(javax.swing.SwingConstants.TOP);

        radioNoOverride.setBackground(new java.awt.Color(255, 255, 255));
        buttonGroupFractionImport.add(radioNoOverride);
        radioNoOverride.setSelected(true);
        radioNoOverride.setText("no");
        radioNoOverride.setBorderPainted(true);
        radioNoOverride.setContentAreaFilled(false);
        radioNoOverride.setMargin(new java.awt.Insets(0, 0, 0, 5));

        radioYesOverride.setBackground(new java.awt.Color(255, 255, 255));
        buttonGroupFractionImport.add(radioYesOverride);
        radioYesOverride.setText("yes");
        radioYesOverride.setContentAreaFilled(false);
        radioYesOverride.setMargin(new java.awt.Insets(0, 0, 0, 5));

        org.jdesktop.layout.GroupLayout preferencesPanelLayout = new org.jdesktop.layout.GroupLayout(preferencesPanel);
        preferencesPanel.setLayout(preferencesPanelLayout);
        preferencesPanelLayout.setHorizontalGroup(
            preferencesPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(preferencesPanelLayout.createSequentialGroup()
                .addContainerGap()
                .add(chooseLabel)
                .addContainerGap(198, Short.MAX_VALUE))
            .add(org.jdesktop.layout.GroupLayout.TRAILING, preferencesPanelLayout.createSequentialGroup()
                .addContainerGap(64, Short.MAX_VALUE)
                .add(preferencesPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, preferencesPanelLayout.createSequentialGroup()
                        .add(radioNoOverride)
                        .add(72, 72, 72)
                        .add(radioYesOverride)
                        .add(93, 93, 93))
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, preferencesPanelLayout.createSequentialGroup()
                        .add(importLabel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 309, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addContainerGap())))
        );
        preferencesPanelLayout.setVerticalGroup(
            preferencesPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(preferencesPanelLayout.createSequentialGroup()
                .add(20, 20, 20)
                .add(chooseLabel)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(importLabel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 77, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(preferencesPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(radioNoOverride)
                    .add(radioYesOverride))
                .addContainerGap(356, Short.MAX_VALUE))
        );

        toolBar.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));

        done_button.setForeground(new java.awt.Color(255, 51, 0));
        done_button.setText("Done");
        done_button.setMargin(new java.awt.Insets(2, 1, 2, 1));
        done_button.setPreferredSize(new java.awt.Dimension(110, 23));
        done_button.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                done_buttonActionPerformed(evt);
            }
        });

        org.jdesktop.layout.GroupLayout toolBarLayout = new org.jdesktop.layout.GroupLayout(toolBar);
        toolBar.setLayout(toolBarLayout);
        toolBarLayout.setHorizontalGroup(
            toolBarLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(toolBarLayout.createSequentialGroup()
                .addContainerGap()
                .add(done_button, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 345, Short.MAX_VALUE)
                .addContainerGap())
        );
        toolBarLayout.setVerticalGroup(
            toolBarLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(done_button, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
        );

        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(toolBar, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .add(preferencesPanel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
                .add(preferencesPanel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(toolBar, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void done_buttonActionPerformed (java.awt.event.ActionEvent evt) {//GEN-FIRST:event_done_buttonActionPerformed
        //SaveSampleData();
        close();
    }//GEN-LAST:event_done_buttonActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.ButtonGroup buttonGroupFractionImport;
    private javax.swing.JLabel chooseLabel;
    private javax.swing.JButton done_button;
    private javax.swing.JLabel importLabel;
    private javax.swing.JPanel preferencesPanel;
    private javax.swing.JRadioButton radioNoOverride;
    private javax.swing.JRadioButton radioYesOverride;
    private javax.swing.JPanel toolBar;
    // End of variables declaration//GEN-END:variables

}


text:
require 'webrick'

include WEBrick    # let's import the namespace so
                   # I don't have to keep typing
                   # WEBrick:: in this documentation.

def start_webrick(config = {})
  # always listen on port 8080
  config.update(:Port => 8080)
  server = HTTPServer.new(config)
  yield server if block_given?
  ['INT', 'TERM'].each {|signal|
    trap(signal) {server.shutdown}
  }
  server.start

end

puts "Site now running on http://localhost:8080"
start_webrick(:DocumentRoot => 'built')


text:
import sys
import math
import logging
from dataclasses import astuple
from collections import defaultdict
from argparse import ArgumentParser, ArgumentDefaultsHelpFormatter

import numpy as np

from pyrsss.kalman.kalman_filter import kalman_filter, sqrt_kalman_filter

def randn_pd(N):
    """
    Generate a random NxN positive definite matrix with norm 1. Return
    the tuple containing this matrix and its square root.
    """
    A_sqrt = np.random.randn(N, N)
    A = np.dot(A_sqrt, A_sqrt.T)
    norm = np.linalg.norm(A)
    return A / norm, A_sqrt / math.sqrt(norm)

def setup_random_sim(N, M, I):
    """
    Generate a random, standard state-space form simulation for the
    purpose of testing. The state dimension is *N*, number of
    measurements is *M*, and *I* is the number of time
    steps. State-space model parameters are generated randomly.
    """
    sim = defaultdict(list)
    sim['N'], sim['M'], sim['I'] = N, M, I
    sim['mu'] = np.random.randn(N)
    sim['PI'], sim['PI_sqrt'] = randn_pd(N)
    for _ in range(I):
        # measurement
        sim['H'].append(np.random.randn(M, N))
        R_i, R_i_sqrt = randn_pd(M)
        sim['R'].append(R_i)
        sim['R_sqrt'].append(R_i_sqrt)
        # time update
        sim['F'].append(np.random.randn(N, N))
        Q_i, Q_i_sqrt = randn_pd(N)
        sim['Q'].append(Q_i)
        sim['Q_sqrt'].append(Q_i_sqrt)
    return sim

def run_random_sim(sim, L):
    """
    Run *L* simulations of the state space model specified by *sim*
    (see :func:`setup_random_sim`). Each simulation is added to *sim*
    index by an integer identifier.
    """
    sim['L'] = L
    for l in range(L):
        sim[l] = defaultdict(list)
        x_i = sim['mu'] + np.matmul(sim['PI_sqrt'], np.random.randn(sim['N']))
        for i in range(sim['I']):
            sim[l]['x'].append(x_i)
            # measurement
            v_i = np.matmul(sim['R_sqrt'][i], np.random.randn(sim['M']))
            sim[l]['y'].append(np.matmul(sim['H'][i], sim[l]['x'][i]) + v_i)
            # time update
            u_i = np.matmul(sim['Q_sqrt'][i], np.random.randn(sim['N']))
            x_i = np.matmul(sim['F'][i], x_i) + u_i
    return sim

def setup_random_test(N, M, I, L):
    """
    Generate a random, standard state-space form simulation for the
    purpose of testing. The state dimension is *N*, number of
    measurements is *M*, number of time steps is *I*, and *L* is the
    number of simulations. State-space model parameters are generated
    randomly. The random simulations are returned as a mapping between
    parameter names and integer simulation indices to lists of vectors
    or matrices.
    """
    sim = setup_random_sim(N, M, I)
    return run_random_sim(sim, L)

def kf_sim(sim):
    """
    Process each simulation trial generated with
    :func:`setup_random_test` with a Kalman filter and return the
    posterior state estimates and error covariances.
    """
    post = defaultdict(dict)
    for l in range(sim['L']):
        x_hat_l, P_l = astuple(kalman_filter(sim[l]['y'],
                                             sim['H'],
                                             sim['R'],
                                             sim['F'],
                                             sim['Q'],
                                             sim['mu'],
                                             sim['PI']))
        post[l]['x_hat'] = x_hat_l
        if l == 0:
            post['P'] = P_l
        post[l]['error'] = []
        for x_i, x_hat_i in zip(sim[l]['x'], post[l]['x_hat']):
            post[l]['error'].append(x_hat_i - x_i)
    return post

def sqrt_kf_sim(sim):
    """
    Process each simulation trial generated with
    :func:`setup_random_test` with a Kalman filter and return the
    posterior state estimates and error covariances.
    """
    post = defaultdict(dict)
    for l in range(sim['L']):
        x_hat_l, P_sqrt_l = astuple(sqrt_kalman_filter(sim[l]['y'],
                                                       sim['H'],
                                                       sim['R_sqrt'],
                                                       sim['F'],
                                                       sim['Q_sqrt'],
                                                       sim['mu'],
                                                       sim['PI_sqrt']))
        post[l]['x_hat'] = x_hat_l
        if l == 0:
            post['P'] = [np.matmul(x, x.T) for x in P_sqrt_l]
        post[l]['error'] = []
        for x_i, x_hat_i in zip(sim[l]['x'], post[l]['x_hat']):
            post[l]['error'].append(x_hat_i - x_i)
    return post

def analysis(N, M, I, L, sqrt=False):
    """
    Conduct a Kalman filter validation experiment. Output results
    (concerning the error, i.e., x_hat - x) for the last time step
    only. If *sqrt* use the square root form Kalman filter.
    """
    sim = setup_random_test(N, M, I, L)
    if sqrt:
        post = sqrt_kf_sim(sim)
    else:
        post = kf_sim(sim)
    # output statistics of \hat{x}_{I|I}
    error_I = []
    for l in range(sim['L']):
        error_I.append(post[l]['error'][-1])
    E_I = np.stack(error_I, 1)
    E_I_mean = np.mean(E_I, 1)
    P_I = np.cov(E_I)
    print('Mean of error at time step I={}'.format(I))
    for E_I_mean_n in E_I_mean:
        print('{:9.2e}'.format(E_I_mean_n))
    print('')
    print(f'Norm of mean of error = {np.linalg.norm(E_I_mean):.3e}')
    print('')
    print('True posterior covariance at time step I')
    print(np.array_str(post['P'][-1], precision=2))
    print('')
    print('Empirical posterior covariance at time step I')
    print(np.array_str(P_I, precision=2))
    print('')
    print(f"||P_{{I|I}}(true) - P_{{I|I}}(empirical)||_F = {np.linalg.norm(post['P'][-1] - P_I):.3e}")
    return sim, post

def main(argv=None):
    if argv is None:
        argv = sys.argv

    parser = ArgumentParser('Validate Kalman filter implementation with a randomly generated simulation.',
                            formatter_class=ArgumentDefaultsHelpFormatter)
    parser.add_argument('N',
                        type=int,
                        help='state dimension')
    parser.add_argument('M',
                        type=int,
                        help='number of measurements')
    parser.add_argument('I',
                        type=int,
                        help='number of time steps')
    parser.add_argument('L',
                        type=int,
                        help='number of simulation trials')
    parser.add_argument('--sqrt',
                        '-s',
                        action='store_true',
                        help='use square root form Kalman filter')
    parser.add_argument('--seed',
                        type=int,
                        default=None,
                        help='random number generator seed')
    args = parser.parse_args(argv[1:])

    np.random.seed(args.seed)

    analysis(args.N,
             args.M,
             args.I,
             args.L,
             sqrt=args.sqrt)

if __name__ == '__main__':
    logging.basicConfig(level=logging.INFO)
    sys.exit(main())