text:
Imports Microsoft.VisualBasic
Imports System
Imports System.Text
Imports System.Collections
Imports System.Web.UI.WebControls
Imports System.Web
Imports System.Collections.Generic
Imports System.Globalization

Namespace InfosoftGlobal

    '''
    ''' @version: v3.2.2.2
    ''' @date: 15 August 2012
    '''
    ''' <remarks></remarks>
    Public Class FusionCharts
        Private Shared __CONFIG__ As Hashtable = New Hashtable(New CaseInsensitiveHashCodeProvider(), New CaseInsensitiveComparer())
        Private Shared __CONFIG__Initialized As Boolean = False

#Region "RenderALL methods"
        '''
        ''' Generate html code for rendering chart
        ''' This function assumes that you've already included the FusionCharts JavaScript class in your page
        '''
        ''' <param name="chartSWF">SWF File Name (and Path) of the chart which you intend to plot</param>
        ''' <param name="dataUrl">If you intend to use dataURL method for this chart, pass the URL as this parameter. Else, set it to "" (in case of dataXML method)</param>
        ''' <param name="dataStr">If you intend to use dataXML method for this chart, pass the XML data as this parameter. Else, set it to "" (in case of dataURL method)</param>
        ''' <param name="chartId">Id for the chart, using which it will be recognized in the HTML page. Each chart on the page needs to have a unique Id.</param>
        ''' <param name="chartWidth">Intended width for the chart (in pixels)</param>
        ''' <param name="chartHeight">Intended height for the chart (in pixels)</param>
        ''' <param name="debugMode">Whether to start the chart in debug mode</param>
        ''' <param name="registerWithJS">Whether to ask chart to register itself with JavaScript</param>
        ''' <param name="allowTransparent">Whether allowTransparent chart (true / false)</param>
        ''' <param name="bgColor">Back Ground Color</param>
        ''' <param name="scaleMode">Set Scale Mode</param>
        ''' <param name="language">Set SWF file Language</param>
        ''' <returns>JavaScript + HTML code required to embed a chart</returns>
        Private Shared Function RenderChartALL(ByVal chartSWF As String, ByVal dataUrl As String, ByVal dataStr As String, ByVal chartId As String, ByVal chartWidth As String, ByVal chartHeight As String, ByVal debugMode As Boolean, ByVal registerWithJS As Boolean, ByVal allowTransparent As Boolean, ByVal bgColor As String, ByVal scaleMode As String, ByVal language As String) As String

            __INIT()

            ' Creating a local copy of global Configuration.
            Dim __CONFIGCLONE__ As Hashtable = __CONFIG__.Clone()

            ' String dataprovider_js_code
            SetConfiguration(__CONFIGCLONE__, "debugMode", boolToNum(debugMode))
            SetConfiguration(__CONFIGCLONE__, "registerWithJS", boolToNum(True))
            ' Setup debug mode js parameter
            Dim debugMode_js_param As Integer = boolToNum(debugMode)
            ' Setup register with js js parameter
            Dim registerWithJS_js_param As Integer = boolToNum(True)
            Dim dataFormat As String = GetConfiguration(__CONFIGCLONE__, "dataFormat")
            dataFormat = IIf(dataFormat = "", "xml" & IIf(dataStr = "", "url", ""), dataFormat & IIf(dataStr = "", "url", ""))

            If (GetConfiguration(__CONFIGCLONE__, "renderAt") = "") Then SetConfiguration(__CONFIGCLONE__, "renderAt", chartId + "Div")

            Dim wmode As String = GetConfiguration(__CONFIGCLONE__, "wMode")
            'If (wmode.Trim() = "") Or (wmode = DBNull.Value) Then
            If (wmode.Trim() = "") Then
                wmode = IIf(allowTransparent = True, "transparent", "opaque")
            End If

            SetConfiguration(__CONFIGCLONE__, "swfUrl", chartSWF)
            SetConfiguration(__CONFIGCLONE__, "dataFormat", dataFormat)
            SetConfiguration(__CONFIGCLONE__, "id", chartId)
            SetConfiguration(__CONFIGCLONE__, "width", chartWidth)
            SetConfiguration(__CONFIGCLONE__, "height", chartHeight)
            SetConfiguration(__CONFIGCLONE__, "wMode", wmode)
            SetConfiguration(__CONFIGCLONE__, "bgColor", bgColor)
            SetConfiguration(__CONFIGCLONE__, "scaleMode", scaleMode)
            SetConfiguration(__CONFIGCLONE__, "lang", language)

            Dim dataSource As String = IIf(dataStr = "", dataUrl, dataStr.Replace(vbCrLf, ""))
            Dim dataSourceJSON As String = """dataSource"" : " & IIf(dataFormat = "json", dataSource, """" + dataSource + """")
            Dim chartConfigJSON As String = "{" + FC_EncodeJSON(GetConfigurationGroup(__CONFIGCLONE__, "params"), False) + "," + dataSourceJSON + "}"

            Dim builder As StringBuilder = New StringBuilder()
            builder.Append("" & Environment.NewLine)
            builder.Append("
" & Environment.NewLine)
            builder.Append("Chart." + Environment.NewLine)
            builder.Append("
" + Environment.NewLine)
            builder.Append("" + Environment.NewLine)
            builder.Append("" + Environment.NewLine)

            ' Re-Initializing...
            __fc__initialize__()

            __CONFIGCLONE__ = Nothing

            Return builder.ToString()
        End Function
        '''
        ''' Renders the HTML code for the chart. This
        ''' method does NOT embed the chart using JavaScript class. Instead, it uses
        ''' direct HTML embedding. So, if you see the charts on IE 6 (or above), you'll
        ''' see the "Click to activate..." message on the chart.
        '''
        ''' <param name="chartSWF">SWF File Name (and Path) of the chart which you intend to plot</param>
        ''' <param name="dataUrl">If you intend to use dataURL method for this chart, pass the URL as this parameter. Else, set it to "" (in case of dataXML method)</param>
        ''' <param name="dataStr">If you intend to use dataXML method for this chart, pass the XML data as this parameter. Else, set it to "" (in case of dataURL method)</param>
        ''' <param name="chartId">Id for the chart, using which it will be recognized in the HTML page. Each chart on the page needs to have a unique Id.</param>
        ''' <param name="chartWidth">Intended width for the chart (in pixels)</param>
        ''' <param name="chartHeight">Intended height for the chart (in pixels)</param>
        ''' <param name="debugMode">Whether to start the chart in debug mode</param>
        ''' <param name="registerWithJS">Whether to ask chart to register itself with JavaScript</param>
        ''' <param name="allowTransparent">Whether allowTransparent chart (true / false)</param>
        ''' <param name="bgColor">Back Ground Color</param>
        ''' <param name="scaleMode">Set Scale Mode</param>
        ''' <param name="language">Set SWF file Language</param>
        ''' <returns></returns>
        Private Shared Function RenderChartHTMLALL(ByVal chartSWF As String, ByVal dataUrl As String, ByVal dataStr As String, ByVal chartId As String, ByVal chartWidth As String, ByVal chartHeight As String, ByVal debugMode As Boolean, ByVal registerWithJS As Boolean, ByVal allowTransparent As Boolean, ByVal bgColor As String, ByVal scaleMode As String, ByVal language As String) As String
            __INIT()
            ' Creating a local copy of global Configuration.
            Dim __CONFIGCLONE__ As Hashtable = __CONFIG__.Clone()

            Dim wmode As String = GetConfiguration(__CONFIGCLONE__, "wMode")
            'If (wmode.Trim() = "") Or (wmode = null) Then
            If (wmode.Trim() = "") Then
                wmode = IIf(allowTransparent = True, "transparent", "opaque")
            End If

            SetConfiguration(__CONFIGCLONE__, "data", chartSWF)
            SetConfiguration(__CONFIGCLONE__, "movie", chartSWF)
            SetConfiguration(__CONFIGCLONE__, "dataXML", dataStr)
            SetConfiguration(__CONFIGCLONE__, "dataURL", dataUrl)
            SetConfiguration(__CONFIGCLONE__, "width", chartWidth)
            SetConfiguration(__CONFIGCLONE__, "height", chartHeight)
            SetConfiguration(__CONFIGCLONE__, "chartWidth", chartWidth)
            SetConfiguration(__CONFIGCLONE__, "chartHeight", chartHeight)
            SetConfiguration(__CONFIGCLONE__, "DOMId", chartId)
            SetConfiguration(__CONFIGCLONE__, "id", chartId)
            SetConfiguration(__CONFIGCLONE__, "debugMode", boolToNum(debugMode))
            SetConfiguration(__CONFIGCLONE__, "wMode", wmode)
            SetConfiguration(__CONFIGCLONE__, "bgColor", bgColor)
            SetConfiguration(__CONFIGCLONE__, "scaleMode", scaleMode)
            SetConfiguration(__CONFIGCLONE__, "lang", language)

            Dim strFlashVars As String = FC_Transform(GetConfigurationGroup(__CONFIGCLONE__, "fvars"), "&{key}={value}", True)
            SetConfiguration(__CONFIGCLONE__, "flashvars", strFlashVars)

            Dim strObjectNode As String = FC_Transform(GetConfigurationGroup(__CONFIGCLONE__, "object"), " {key}=""{value}""", True)
            Dim strObjectParamsNode As String = FC_Transform(GetConfigurationGroup(__CONFIGCLONE__, "objparams"), vbTab + "<param name=""{key}"" value=""{value}"">" + Environment.NewLine, True)

            Dim htmlcodes As StringBuilder = New StringBuilder()
            htmlcodes.Append("" + Environment.NewLine)
            htmlcodes.Append("<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' " + strObjectNode + ">" + Environment.NewLine)
            htmlcodes.Append(strObjectParamsNode + Environment.NewLine)
            htmlcodes.Append("" + Environment.NewLine + "<object type='application/x-shockwave-flash' " + strObjectNode + ">" + Environment.NewLine)
            htmlcodes.Append(strObjectParamsNode + Environment.NewLine + "</object>" + Environment.NewLine + "" + Environment.NewLine)
            htmlcodes.Append("</object>" + Environment.NewLine + "" + Environment.NewLine)

            ' Re-Initializing...
            __fc__initialize__()

            __CONFIGCLONE__ = Nothing

            Return htmlcodes.ToString()
        End Function
#End Region

        '''
        ''' Generate html code for rendering chart
        ''' This function assumes that you've already included the FusionCharts JavaScript class in your page
        '''
        ''' <param name="chartSWF">SWF File Name (and Path) of the chart which you intend to plot</param>
        ''' <param name="dataUrl">If you intend to use dataURL method for this chart, pass the URL as this parameter. Else, set it to "" (in case of dataXML method)</param>
        ''' <param name="dataStr">If you intend to use dataXML method for this chart, pass the XML data as this parameter. Else, set it to "" (in case of dataURL method)</param>
        ''' <param name="chartId">Id for the chart, using which it will be recognized in the HTML page. Each chart on the page needs to have a unique Id.</param>
        ''' <param name="chartWidth">Intended width for the chart (in pixels)</param>
        ''' <param name="chartHeight">Intended height for the chart (in pixels)</param>
        ''' <param name="debugMode">Whether to start the chart in debug mode</param>
        ''' <param name="registerWithJS">Whether to ask chart to register itself with JavaScript</param>
        ''' <returns>JavaScript + HTML code required to embed a chart</returns>
        Public Shared Function RenderChart(ByVal chartSWF As String, ByVal dataUrl As String, ByVal dataStr As String, ByVal chartId As String, ByVal chartWidth As String, ByVal chartHeight As String, ByVal debugMode As Boolean, ByVal registerWithJS As Boolean) As String
            Return RenderChartALL(chartSWF, dataUrl, dataStr, chartId, chartWidth, chartHeight, debugMode, registerWithJS, False, "", "noScale", "EN")
        End Function

        '''
        ''' Generate html code for rendering chart
        ''' This function assumes that you've already included the FusionCharts JavaScript class in your page
        '''
        ''' <param name="chartSWF">SWF File Name (and Path) of the chart which you intend to plot</param>
        ''' <param name="dataUrl">If you intend to use dataURL method for this chart, pass the URL as this parameter. Else, set it to "" (in case of dataXML method)</param>
        ''' <param name="dataStr">If you intend to use dataXML method for this chart, pass the XML data as this parameter. Else, set it to "" (in case of dataURL method)</param>
        ''' <param name="chartId">Id for the chart, using which it will be recognized in the HTML page. Each chart on the page needs to have a unique Id.</param>
        ''' <param name="chartWidth">Intended width for the chart (in pixels)</param>
        ''' <param name="chartHeight">Intended height for the chart (in pixels)</param>
        ''' <param name="debugMode">Whether to start the chart in debug mode</param>
        ''' <param name="registerWithJS">Whether to ask chart to register itself with JavaScript</param>
        ''' <param name="allowTransparent">Whether allowTransparent chart (true / false)</param>
        ''' <returns>JavaScript + HTML code required to embed a chart</returns>
        Public Shared Function RenderChart(ByVal chartSWF As String, ByVal dataUrl As String, ByVal dataStr As String, ByVal chartId As String, ByVal chartWidth As String, ByVal chartHeight As String, ByVal debugMode As Boolean, ByVal registerWithJS As Boolean, ByVal allowTransparent As Boolean) As String
            Return RenderChartALL(chartSWF, dataUrl, dataStr, chartId, chartWidth, chartHeight, debugMode, registerWithJS, allowTransparent, "", "noScale", "EN")
        End Function
        '''
        ''' Generate html code for rendering chart
        ''' This function assumes that you've already included the FusionCharts JavaScript class in your page
        '''
        ''' <param name="chartSWF">SWF File Name (and Path) of the chart which you intend to plot</param>
        ''' <param name="dataUrl">If you intend to use dataURL method for this chart, pass the URL as this parameter. Else, set it to "" (in case of dataXML method)</param>
        ''' <param name="dataStr">If you intend to use dataXML method for this chart, pass the XML data as this parameter. Else, set it to "" (in case of dataURL method)</param>
        ''' <param name="chartId">Id for the chart, using which it will be recognized in the HTML page. Each chart on the page needs to have a unique Id.</param>
        ''' <param name="chartWidth">Intended width for the chart (in pixels)</param>
        ''' <param name="chartHeight">Intended height for the chart (in pixels)</param>
        ''' <param name="debugMode">Whether to start the chart in debug mode</param>
        ''' <param name="registerWithJS">Whether to ask chart to register itself with JavaScript</param>
        ''' <param name="allowTransparent">Whether allowTransparent chart (true / false)</param>
        ''' <param name="bgColor">Back Ground Color</param>
        ''' <param name="scaleMode">Set Scale Mode</param>
        ''' <param name="language">Set SWF file Language</param>
        ''' <returns>JavaScript + HTML code required to embed a chart</returns>
        Public Shared Function RenderChart(ByVal chartSWF As String, ByVal dataUrl As String, ByVal dataStr As String, ByVal chartId As String, ByVal chartWidth As String, ByVal chartHeight As String, ByVal debugMode As Boolean, ByVal registerWithJS As Boolean, ByVal allowTransparent As Boolean, ByVal bgColor As String, ByVal scaleMode As String, ByVal language As String) As String
            Return RenderChartALL(chartSWF, dataUrl, dataStr, chartId, chartWidth, chartHeight, debugMode, registerWithJS, allowTransparent, bgColor, scaleMode, language)
        End Function
        '''
        ''' Renders the HTML code for the chart. This
        ''' method does NOT embed the chart using JavaScript class. Instead, it uses
        ''' direct HTML embedding. So, if you see the charts on IE 6 (or above), you'll
        ''' see the "Click to activate..." message on the chart.
        '''
        ''' <param name="chartSWF">SWF File Name (and Path) of the chart which you intend to plot</param>
        ''' <param name="dataUrl">If you intend to use dataURL method for this chart, pass the URL as this parameter. Else, set it to "" (in case of dataXML method)</param>
        ''' <param name="dataStr">If you intend to use dataXML method for this chart, pass the XML data as this parameter. Else, set it to "" (in case of dataURL method)</param>
        ''' <param name="chartId">Id for the chart, using which it will be recognized in the HTML page. Each chart on the page needs to have a unique Id.</param>
        ''' <param name="chartWidth">Intended width for the chart (in pixels)</param>
        ''' <param name="chartHeight">Intended height for the chart (in pixels)</param>
        ''' <param name="debugMode">Whether to start the chart in debug mode</param>
        ''' <returns></returns>
        Public Shared Function RenderChartHTML(ByVal chartSWF As String, ByVal dataUrl As String, ByVal dataStr As String, ByVal chartId As String, ByVal chartWidth As String, ByVal chartHeight As String, ByVal debugMode As Boolean) As String
            Return RenderChartHTMLALL(chartSWF, dataUrl, dataStr, chartId, chartWidth, chartHeight, debugMode, True, False, "", "noScale", "EN")
        End Function
        '''
        ''' Renders the HTML code for the chart. This
        ''' method does NOT embed the chart using JavaScript class. Instead, it uses
        ''' direct HTML embedding. So, if you see the charts on IE 6 (or above), you'll
        ''' see the "Click to activate..." message on the chart.
        '''
        ''' <param name="chartSWF">SWF File Name (and Path) of the chart which you intend to plot</param>
        ''' <param name="dataUrl">If you intend to use dataURL method for this chart, pass the URL as this parameter. Else, set it to "" (in case of dataXML method)</param>
        ''' <param name="dataStr">If you intend to use dataXML method for this chart, pass the XML data as this parameter. Else, set it to "" (in case of dataURL method)</param>
        ''' <param name="chartId">Id for the chart, using which it will be recognized in the HTML page. Each chart on the page needs to have a unique Id.</param>
        ''' <param name="chartWidth">Intended width for the chart (in pixels)</param>
        ''' <param name="chartHeight">Intended height for the chart (in pixels)</param>
        ''' <param name="debugMode">Whether to start the chart in debug mode</param>
        ''' <param name="registerWithJS">Whether to ask chart to register itself with JavaScript</param>
        ''' <returns></returns>
        Public Shared Function RenderChartHTML(ByVal chartSWF As String, ByVal dataUrl As String, ByVal dataStr As String, ByVal chartId As String, ByVal chartWidth As String, ByVal chartHeight As String, ByVal debugMode As Boolean, ByVal registerWithJS As Boolean) As String
            Return RenderChartHTMLALL(chartSWF, dataUrl, dataStr, chartId, chartWidth, chartHeight, debugMode, registerWithJS, False, "", "noScale", "EN")
        End Function
        '''
        ''' Renders the HTML code for the chart. This
        ''' method does NOT embed the chart using JavaScript class. Instead, it uses
        ''' direct HTML embedding. So, if you see the charts on IE 6 (or above), you'll
        ''' see the "Click to activate..." message on the chart.
        '''
        ''' <param name="chartSWF">SWF File Name (and Path) of the chart which you intend to plot</param>
        ''' <param name="dataUrl">If you intend to use dataURL method for this chart, pass the URL as this parameter. Else, set it to "" (in case of dataXML method)</param>
        ''' <param name="dataStr">If you intend to use dataXML method for this chart, pass the XML data as this parameter. Else, set it to "" (in case of dataURL method)</param>
        ''' <param name="chartId">Id for the chart, using which it will be recognized in the HTML page. Each chart on the page needs to have a unique Id.</param>
        ''' <param name="chartWidth">Intended width for the chart (in pixels)</param>
        ''' <param name="chartHeight">Intended height for the chart (in pixels)</param>
        ''' <param name="debugMode">Whether to start the chart in debug mode</param>
        ''' <param name="registerWithJS">Whether to ask chart to register itself with JavaScript</param>
        ''' <param name="allowTransparent">Whether allowTransparent chart (true / false)</param>
        ''' <returns></returns>
        Public Shared Function RenderChartHTML(ByVal chartSWF As String, ByVal dataUrl As String, ByVal dataStr As String, ByVal chartId As String, ByVal chartWidth As String, ByVal chartHeight As String, ByVal debugMode As Boolean, ByVal registerWithJS As Boolean, ByVal allowTransparent As Boolean) As String
            Return RenderChartHTMLALL(chartSWF, dataUrl, dataStr, chartId, chartWidth, chartHeight, debugMode, registerWithJS, allowTransparent, "", "noScale", "EN")
        End Function
        '''
        ''' Renders the HTML code for the chart. This
        ''' method does NOT embed the chart using JavaScript class. Instead, it uses
        ''' direct HTML embedding. So, if you see the charts on IE 6 (or above), you'll
        ''' see the "Click to activate..." message on the chart.
        '''
        ''' <param name="chartSWF">SWF File Name (and Path) of the chart which you intend to plot</param>
        ''' <param name="dataUrl">If you intend to use dataURL method for this chart, pass the URL as this parameter. Else, set it to "" (in case of dataXML method)</param>
        ''' <param name="dataStr">If you intend to use dataXML method for this chart, pass the XML data as this parameter. Else, set it to "" (in case of dataURL method)</param>
        ''' <param name="chartId">Id for the chart, using which it will be recognized in the HTML page. Each chart on the page needs to have a unique Id.</param>
        ''' <param name="chartWidth">Intended width for the chart (in pixels)</param>
        ''' <param name="chartHeight">Intended height for the chart (in pixels)</param>
        ''' <param name="debugMode">Whether to start the chart in debug mode</param>
        ''' <param name="registerWithJS">Whether to ask chart to register itself with JavaScript</param>
        ''' <param name="allowTransparent">Whether allowTransparent chart (true / false)</param>
        ''' <param name="bgColor">Back Ground Color</param>
        ''' <param name="scaleMode">Set Scale Mode</param>
        ''' <param name="language">Set SWF file Language</param>
        ''' <returns></returns>
        Public Shared Function RenderChartHTML(ByVal chartSWF As String, ByVal dataUrl As String, ByVal dataStr As String, ByVal chartId As String, ByVal chartWidth As String, ByVal chartHeight As String, ByVal debugMode As Boolean, ByVal registerWithJS As Boolean, ByVal allowTransparent As Boolean, ByVal bgColor As String, ByVal scaleMode As String, ByVal language As String) As String
            Return RenderChartHTMLALL(chartSWF, dataUrl, dataStr, chartId, chartWidth, chartHeight, debugMode, registerWithJS, allowTransparent, bgColor, scaleMode, language)
        End Function

        '''
        ''' Encodes the dataURL before it's served to FusionCharts
        ''' If you have parameters in your dataURL, you'll necessarily need to encode it
        '''
        ''' <param name="dataURL">dataURL to be fed to chart</param>
        ''' <param name="noCacheStr">Whether to add aditional string to URL to disable caching of data</param>
        ''' <returns>Encoded dataURL, ready to be consumed by FusionCharts</returns>
        Public Shared Function EncodeDataURL(ByVal dataUrl As String, ByVal noCacheStr As Boolean) As String
            Dim result As String = dataUrl
            If (noCacheStr) Then
                result += IIf((dataUrl.IndexOf("?") <> -1), "&", "?")
                ' Replace : in time with _, as FusionCharts cannot handle : in URLs
                result += "FCCurrTime=" + DateTime.Now.ToString().Replace(":", "_")
            End If
            Return System.Web.HttpUtility.UrlEncode(result)
        End Function

        '''
        ''' Enables Print Manager for Mozilla browsers
        ''' This function returns a small JavaScript snippet which can be added to ClientScript's RegisterClientScriptBlock method
        '''
        ''' <example>ClientScript.RegisterClientScriptBlock(Page.GetType(), "", FusionCharts.enableFCPrintManager());</example>
        ''' <returns>String with the JavaScript code</returns>
        Public Shared Function EnablePrintManager() As String
            Dim strHTML As String = ""
            Return strHTML
        End Function

        '''
        ''' Enables Print Manager for Mozilla browsers
        '''
        ''' <param name="CurrentPage">Current page reference</param>
        Public Shared Sub EnablePrintManager(ByVal CurrentPage As Object)
            Dim HostPage As System.Web.UI.Page
            HostPage = DirectCast(CurrentPage, System.Web.UI.Page)
            Dim strHTML As String = ""
            HostPage.ClientScript.RegisterClientScriptBlock(HostPage.GetType(), "", strHTML)
        End Sub

        Private Shared Sub __INIT()
            If (__CONFIG__Initialized = False) Then

                __fc__initialize__()
                __fc__initstatic__()
                __CONFIG__Initialized = True
            End If
        End Sub
        '''
        ''' Sets the dataformat to be provided to charts (json/xml)
        '''
        ''' <param name="format">Data format. Default is 'xml'. Other format is 'json'</param>
        Public Shared Sub SetDataFormat(ByVal format As String)
            __INIT()

            If (format.Trim().Length = 0) Then

                format = "xml"
            End If
            ' Stores the dataformat in global configuration store
            SetConfiguration("dataFormat", format)
        End Sub

        '''
        ''' Sets renderer type (flash/javascript)
        '''
        ''' <param name="renderer"> Name of the renderer. Default is 'flash'. Other possibility is 'javascript'</param>
        Public Shared Sub SetRenderer(ByVal renderer As String)
            __INIT()

            If (renderer.Trim().Length = 0) Then
                renderer = "flash"
            End If
            ' stores the renderer name in global configuration store
            SetConfiguration("renderer", renderer)
        End Sub

        '''
        ''' Explicitely sets window mode (window[detault]/transpatent/opaque)
        '''
        ''' <param name="mode">Name of the mode. Default is 'window'. Other possibilities are 'transparent'/'opaque'</param>
        Public Shared Sub SetWindowMode(ByVal mode As String)
            __INIT()
            SetConfiguration("wMode", mode)
        End Sub

        '''
        ''' SetConfiguration sets various configurations of FusionCharts
        ''' It takes configuration names as first parameter and its value a second parameter
        ''' There are config groups which can contain common configuration names. All config names in all groups gets set with this value
        ''' unless group is specified explicitly
        '''
        ''' <param name="setting">Name of configuration</param>
        ''' <param name="value">Value of configuration</param>
        Public Shared Sub SetConfiguration(ByVal setting As String, ByVal value As Object)
            Dim de As DictionaryEntry
            For Each de In __CONFIG__
                If (DirectCast(__CONFIG__(de.Key), Hashtable).ContainsKey(setting)) Then
                    DirectCast(__CONFIG__(de.Key), Hashtable)(setting) = value
                End If
            Next
        End Sub

        Private Shared Sub SetConfiguration(ByRef __CONFIGCLONE__ As Hashtable, ByVal setting As String, ByVal value As Object)
            Dim de As DictionaryEntry
            For Each de In __CONFIGCLONE__
                If (DirectCast(__CONFIGCLONE__(de.Key), Hashtable).ContainsKey(setting)) Then
                    DirectCast(__CONFIGCLONE__(de.Key), Hashtable)(setting) = value
                End If
            Next
        End Sub

        Private Shared Function GetHTTP() As String

            'Checks for protocol type.
            Dim isHTTPS As String = HttpContext.Current.Request.ServerVariables("HTTPS")
            'Checks browser type.
            Dim isMSIE As Boolean = HttpContext.Current.Request.ServerVariables("HTTP_USER_AGENT").Contains("MSIE")
            'Protocol initially sets to http.
            Dim sHTTP As String = "http"
            If (isHTTPS.ToLower() = "on") Then
                sHTTP = "https"
            End If
            Return sHTTP

        End Function

        '''
        ''' Transform the meaning of boolean value in integer value
        '''
        ''' <param name="value">true/false value to be transformed</param>
        ''' <returns>1 if the value is true, 0 if the value is false</returns>
        Private Shared Function boolToNum(ByVal value As Boolean) As Integer
            Return IIf(value = True, 1, 0)
        End Function

        Private Shared Sub SetCONSTANTConfiguration(ByVal setting As String, ByVal value As Object)
            DirectCast(__CONFIG__("constants"), Hashtable)(setting) = value
        End Sub

        Private Shared Function GetConfiguration(ByVal setting As String) As String
            Dim de As System.Collections.DictionaryEntry
            For Each de In __CONFIG__
                If DirectCast(__CONFIG__(de.Key), Hashtable).ContainsKey(setting) Then
                    Return (DirectCast(__CONFIG__(de.Key), Hashtable)(setting).ToString())
                End If
            Next
            Return Nothing
        End Function

        Private Shared Function GetConfiguration(ByRef __CONFIGCLONE__ As Hashtable, ByVal setting As String) As String
            Dim de As System.Collections.DictionaryEntry
            For Each de In __CONFIGCLONE__
                If DirectCast(__CONFIGCLONE__(de.Key), Hashtable).ContainsKey(setting) Then
                    Return (DirectCast(__CONFIGCLONE__(de.Key), Hashtable)(setting).ToString())
                End If
            Next
            Return Nothing
        End Function

        Private Shared Function GetConfigurationGroup(ByVal setting As String) As Hashtable
            If (__CONFIG__.ContainsKey(setting)) Then
                Return DirectCast(__CONFIG__(setting), Hashtable)
            End If
            Return Nothing
        End Function

        Private Shared Function GetConfigurationGroup(ByRef __CONFIGCLONE__ As Hashtable, ByVal setting As String) As Hashtable
            If (__CONFIGCLONE__.ContainsKey(setting)) Then
                Return DirectCast(__CONFIGCLONE__(setting), Hashtable)
            End If
            Return Nothing
        End Function

        Private Shared Function FC_Transform(ByVal arr As System.Collections.Hashtable, ByVal tFormat As String, ByVal ignoreBlankValues As Boolean) As String
            Dim converted As String = ""
            Dim Key As String = ""
            Dim Value As String = ""
            Dim ds As System.Collections.DictionaryEntry

            For Each ds In arr
                If (ignoreBlankValues = True And ds.Value.ToString().Trim() = "") Then Continue For
                Key = ds.Key.ToString()
                Value = ds.Value.ToString()
                If (Key.ToLower().Equals("codebase")) Then
                    Value = Value.Replace("http", GetHTTP())
                End If
                Dim TFApplied As String = tFormat.Replace("{key}", Key)
                TFApplied = TFApplied.Replace("{value}", Value)
                converted = converted & TFApplied
            Next

            Return converted

        End Function

        Private Shared Function FC_EncodeJSON(ByVal json As Hashtable, ByVal enclosed As Boolean) As String
            Dim strjson As String = ""
            If (enclosed = True) Then strjson = "{"
            strjson = strjson & FC_Transform(json, """{key}"" : ""{value}"", ", True)
            strjson = strjson.Trim()

            If (strjson.EndsWith(",")) Then strjson = strjson.Remove(strjson.Length - 1)

            Return strjson
        End Function

        Private Shared Sub __fc__initstatic__()
            Dim constant As Hashtable = New Hashtable(New CaseInsensitiveHashCodeProvider(), New CaseInsensitiveComparer())
            constant("scriptbaseUri") = ""
            __CONFIG__("constants") = constant
            constant = Nothing
        End Sub

        Private Shared Sub __fc__initialize__()

            __CONFIG__ = Nothing
            __CONFIG__ = New Hashtable(New CaseInsensitiveHashCodeProvider(), New CaseInsensitiveComparer())

            Dim param As Hashtable = New Hashtable(New CaseInsensitiveHashCodeProvider(), New CaseInsensitiveComparer())

            param("swfUrl") = ""
            param("width") = ""
            param("height") = ""
            param("renderAt") = ""
            param("renderer") = ""
            param("dataSource") = ""
            param("dataFormat") = ""
            param("id") = ""
            param("lang") = ""
            param("debugMode") = ""
            param("registerWithJS") = ""
            param("detectFlashVersion") = ""
            param("autoInstallRedirect") = ""
            param("wMode") = ""
            param("scaleMode") = ""
            param("menu") = ""
            param("bgColor") = ""
            param("quality") = ""

            __CONFIG__("params") = param

            Dim fvar As Hashtable = New Hashtable(New CaseInsensitiveHashCodeProvider(), New CaseInsensitiveComparer())
            fvar("dataURL") = ""
            fvar("dataXML") = ""
            fvar("chartWidth") = ""
            fvar("chartHeight") = ""
            fvar("DOMId") = ""
            fvar("registerWithJS") = "1"
            fvar("debugMode") = "0"
            fvar("scaleMode") = "noScale"
            fvar("lang") = "EN"
            fvar("animation") = "undefined"
            __CONFIG__("fvars") = fvar

            Dim obj As Hashtable = New Hashtable(New CaseInsensitiveHashCodeProvider(), New CaseInsensitiveComparer())
            obj("height") = ""
            obj("width") = ""
            obj("id") = ""
            obj("lang") = "EN"
            obj("class") = "FusionCharts"
            obj("data") = ""
            __CONFIG__("object") = obj

            Dim objparam As Hashtable = New Hashtable(New CaseInsensitiveHashCodeProvider(), New CaseInsensitiveComparer())
            objparam("movie") = ""
            objparam("scaleMode") = "noScale"
            objparam("scale") = ""
            objparam("wMode") = ""
            objparam("allowScriptAccess") = "always"
            objparam("quality") = "best"
            objparam("FlashVars") = ""
            objparam("bgColor") = ""
            objparam("swLiveConnect") = ""
            objparam("base") = ""
            objparam("align") = ""
            objparam("salign") = ""
            objparam("menu") = ""
            __CONFIG__("objparams") = objparam

            Dim embeds As Hashtable = New Hashtable(New CaseInsensitiveHashCodeProvider(), New CaseInsensitiveComparer())
            embeds("height") = ""
            embeds("width") = ""
            embeds("id") = ""
            embeds("src") = ""
            embeds("flashvars") = ""
            embeds("name") = ""
            embeds("scaleMode") = "noScale"
            embeds("wMode") = ""
            embeds("bgColor") = ""
            embeds("quality") = "best"
            embeds("allowScriptAccess") = "always"
            embeds("type") = "application/x-shockwave-flash"
            embeds("pluginspage") = "http://www.macromedia.com/go/getflashplayer"
            embeds("swLiveConnect") = ""
            embeds("base") = ""
            embeds("align") = ""
            embeds("salign") = ""
            embeds("scale") = ""
            embeds("menu") = ""
            __CONFIG__("embed") = embeds

            param = Nothing
            fvar = Nothing
            obj = Nothing
            objparam = Nothing
            embeds = Nothing

        End Sub
    End Class
End Namespace


text:
{% load i18n %}
{% load sentry_helpers %}

    {% for frame in frames %}

                {% if frame.filename %}
                    {% if frame.is_url %}

                    {% endif %}
                    {{ frame.filename }}
                    {% if frame.sourcemap %}
                        <a class="annotation trigger-popover"
                            data-placement="right"
                            data-title="{% trans "Original Location" %}"
                            data-content="

{% trans "Filename" %}

{{ frame.orig_filename }}

{% trans "Line Number" %}

{{ frame.orig_lineno|default_if_none:"n/a" }}

{% trans "Column Number" %}

{{ frame.orig_colno|default_if_none:"n/a" }}

{% trans "Function" %}

{{ frame.orig_function|default_if_none:"n/a" }}

{% trans "Sourcemap" %}

{{ frame.sourcemap }}

">?
                    {% elif frame.abs_path and frame.abs_path != filename %}
                        <a class="annotation trigger-popover"
                            data-placement="right"
                            data-title="{% trans "Original Location" %}"
                            data-content="

{% trans "Filename" %}

{{ frame.abs_path }}

                                {% if not frame.lineno|is_none %}

{% trans "Line Number" %}

{{ frame.lineno }}

                                {% endif %}
                                {% if not frame.colno|is_none %}

{% trans "Column Number" %}

{{ frame.colno }}

                                {% endif %}
                                {% if frame.function %}

{% trans "Function" %}

{{ frame.function }}

                                {% endif %}

">?
                    {% endif %}
                    {% if frame.is_url %}

                    {% endif %}
                {% elif frame.module %}
                    {{ frame.module }}
                {% endif %}
                {% if frame.function %}
                     {% if frame.filename or frame.module %}in {% endif %}{{ frame.function }}
                {% endif %}
                {% if not frame.context and not frame.lineno|is_none %}
                     at line {{ frame.lineno }}{% if not frame.colno|is_none %}:{{ frame.colno }}{% endif %}
                {% endif %}
                {% if system_frames and frame.in_app %}
                    (application)
                {% endif %}

            {% if frame.context or frame.vars %}

                    {% if frame.vars %} {% endif %}{% if frame.context %} {% endif %}

            {% endif %}

            {% if frame.context %}

                {% for num, line in frame.context %}

{{ line }}

                {% endfor %}

            {% elif not frame.context_line|is_none %}

{{ frame.context_line }}

            {% endif %}

            {% if frame.vars %}

                    {% render_values frame.vars %}

            {% endif %}

    {% endfor %}

redpajama_set_name: RedPajamaGithub


text:
package org.apache.commons.geometry.examples.jmh.euclidean;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;

import org.apache.commons.geometry.euclidean.threed.Bounds3D;
import org.apache.commons.geometry.euclidean.threed.Vector3D;
import org.apache.commons.geometry.euclidean.threed.line.Line3D;
import org.apache.commons.geometry.euclidean.threed.line.Lines3D;
import org.apache.commons.geometry.euclidean.threed.line.Segment3D;
import org.apache.commons.numbers.core.Precision;
import org.apache.commons.rng.UniformRandomProvider;
import org.apache.commons.rng.sampling.shape.UnitBallSampler;
import org.apache.commons.rng.simple.RandomSource;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.Fork;
import org.openjdk.jmh.annotations.Level;
import org.openjdk.jmh.annotations.Measurement;
import org.openjdk.jmh.annotations.Mode;
import org.openjdk.jmh.annotations.OutputTimeUnit;
import org.openjdk.jmh.annotations.Param;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.Setup;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.annotations.Warmup;
import org.openjdk.jmh.infra.Blackhole;

/** Benchmarks for the {@link Bounds3D} class.
 */
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.NANOSECONDS)
@Warmup(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS)
@Measurement(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS)
@Fork(value = 1, jvmArgs = {"-server", "-Xms512M", "-Xmx512M"})
public class Bounds3DPerformance {

    /** Precision context. */
    private static final Precision.DoubleEquivalence PRECISION =
            Precision.doubleEquivalenceOfEpsilon(1e-6);

    /** Benchmark input class providing random line segments. */
    @State(Scope.Thread)
    public static class SegmentInput {

        /** Minimum value used to construct random point coordinates. */
        private static final double COORDINATE_MIN = -10;

        /** Maximum value used to construct random point coordinates. */
        private static final double COORDINATE_MAX = +10;

        /** Number of line segments to generate. */
        @Param({"1000"})
        private int count;

        /** Seed value for randomization. */
        @Param({"1"})
        private int randomSeed;

        /** List of segments for the run. */
        private List<Segment3D> segments;

        /** Random instance. */
        private UniformRandomProvider random;

        /** Get the segments for the run.
         * @return segments for the run
         */
        public List<Segment3D> getSegments() {
            return segments;
        }

        /** Set up the instance for the benchmark. */
        @Setup(Level.Iteration)
        public void setup() {
            random = RandomSource.XO_SHI_RO_256_PP.create(randomSeed);

            final UnitBallSampler ballSampler = UnitBallSampler.of(random, 3);

            segments = new ArrayList<>(count);
            for (int i = 0; i < count; ++i) {
                final Vector3D pt = randomPoint();
                final Vector3D dir = Vector3D.of(ballSampler.sample());

                final Line3D line = Lines3D.fromPointAndDirection(pt, dir, PRECISION);

                segments.add(line.segment(randomCoordinate(), randomCoordinate()));
            }
        }

        /** Return a random point with coordinates within the configured min and max range.
         * @return a random point with coordinates within the configured min and max range
         */
        private Vector3D randomPoint() {
            return Vector3D.of(
                    randomCoordinate(),
                    randomCoordinate(),
                    randomCoordinate());
        }

        /** Return a random double coordinate value within the configured min and max range.
         * @return a random double coordinate value within the configured min and max range
         */
        private double randomCoordinate() {
            return ((COORDINATE_MAX - COORDINATE_MIN) * random.nextDouble()) + COORDINATE_MIN;

        }
    }

    /** Construct a default {@link Bounds3D} instance for performance testing.
     * @return a default {@link Bounds3D} instance
     */
    private static Bounds3D createDefaultTestBounds() {
        return Bounds3D.from(Vector3D.of(-1, -1, -1), Vector3D.of(1, 1, 1));
    }

    /** Baseline benchmark that construct a bounds instance and iterates through all
     * input values.
     * @param input input for the run
     * @param bh blackhole instance
     * @return bounds instance
     */
    @Benchmark
    public Bounds3D segmentBaseline(final SegmentInput input, final Blackhole bh) {
        final Bounds3D bounds = createDefaultTestBounds();
        for (final Segment3D segment : input.getSegments()) {
            bh.consume(segment);
        }
        return bounds;
    }

    /** Benchmark that tests the performance of the
     * {@link Bounds3D#intersects(org.apache.commons.geometry.euclidean.threed.line.LineConvexSubset3D)} method.
     * @param input input for the run
     * @param bh blackhole instance
     * @return bounds instance
     */
    @Benchmark
    public Bounds3D segmentIntersects(final SegmentInput input, final Blackhole bh) {
        final Bounds3D bounds = createDefaultTestBounds();
        for (final Segment3D segment : input.getSegments()) {
            bh.consume(bounds.intersects(segment));
        }
        return bounds;
    }

    /** Benchmark that tests the performance of the
     * {@link Bounds3D#intersection(org.apache.commons.geometry.euclidean.threed.line.LineConvexSubset3D)} method.
     * @param input input for the run
     * @param bh blackhole instance
     * @return bounds instance
     */
    @Benchmark
    public Bounds3D segmentIntersection(final SegmentInput input, final Blackhole bh) {
        final Bounds3D bounds = createDefaultTestBounds();
        for (final Segment3D segment : input.getSegments()) {
            bh.consume(bounds.intersection(segment));
        }
        return bounds;
    }

    /** Benchmark that tests the performance of the
     * {@link Bounds3D#linecast(org.apache.commons.geometry.euclidean.threed.line.LineConvexSubset3D)} method.
     * @param input input for the run
     * @param bh blackhole instance
     * @return bounds instance
     */
    @Benchmark
    public Bounds3D segmentLinecast(final SegmentInput input, final Blackhole bh) {
        final Bounds3D bounds = createDefaultTestBounds();
        for (final Segment3D segment : input.getSegments()) {
            bh.consume(bounds.linecast(segment));
        }
        return bounds;
    }

    /** Benchmark that tests the performance of the
     * {@link Bounds3D#linecastFirst(org.apache.commons.geometry.euclidean.threed.line.LineConvexSubset3D)} method.
     * @param input input for the run
     * @param bh blackhole instance
     * @return bounds instance
     */
    @Benchmark
    public Bounds3D segmentLinecastFirst(final SegmentInput input, final Blackhole bh) {
        final Bounds3D bounds = createDefaultTestBounds();
        for (final Segment3D segment : input.getSegments()) {
            bh.consume(bounds.linecastFirst(segment));
        }
        return bounds;
    }
}


text:
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Xml;

using AlchemyAPI;

using Clifton.MycroParser;

namespace NlpComparison
{
    public class Program
    {
		protected Form form;
		protected TextBox tbUrl;
		protected StatusBarPanel sbStatus;
		protected Button btnProcess;

		// AlchemyAPI views and grids:
		protected DataView dvEntities;
		protected DataView dvKeywords;
		protected DataView dvConcepts;

		protected DataGridView dgvEntities;
		protected DataGridView dgvKeywords;
		protected DataGridView dgvConcepts;

		// OpenCalais views and grids:
		protected DataView dvCalaisEntities;
		protected DataView dvCalaisTopics;
		protected DataView dvCalaisEvents;

		protected DataGridView dgvCalaisEntities;
		protected DataGridView dgvCalaisTopics;
		protected DataGridView dgvCalaisEvents;

		// Semantria views and grids:
		protected DataView dvSemantriaEntities;
		protected DataView dvSemantriaThemes;
		protected DataView dvSemantriaTopics;

		protected DataGridView dgvSemantriaEntities;
		protected DataGridView dgvSemantriaThemes;
		protected DataGridView dgvSemantriaTopics;

		// Labels:
		protected Label lblAlchemyEntities;
		protected Label lblAlchemyKeywords;
		protected Label lblAlchemyConcepts;
		protected Label lblCalaisEntities;
		protected Label lblCalaisTopics;
		protected Label lblCalaisEvents;
		protected Label lblSemantriaEntities;
		protected Label lblSemantriaThemes;
		protected Label lblSemantriaTopics;

		// NLP's:
		protected AlchemyWrapper alchemy;
		protected CalaisWrapper calais;
		protected SemantriaWrapper semantria;

		public Program()
		{
		}

		public void Initialize()
		{
			MycroParser mp = new MycroParser();
			XmlDocument doc = new XmlDocument();
			doc.Load("MainForm.xml");
			mp.Load(doc, "Form", this);
			form = (Form)mp.Process();

			// Controls we need to use:
			tbUrl = mp.ObjectCollection["tbUrl"] as TextBox;
			sbStatus = mp.ObjectCollection["sbStatus"] as StatusBarPanel;
			btnProcess = mp.ObjectCollection["btnProcess"] as Button;

			// AlchemyAPI grids:
			dgvEntities = (DataGridView)mp.ObjectCollection["dgvEntities"];
			dgvKeywords = (DataGridView)mp.ObjectCollection["dgvKeywords"];
			dgvConcepts = (DataGridView)mp.ObjectCollection["dgvConcepts"];

			// Calais grids:
			dgvCalaisEntities = (DataGridView)mp.ObjectCollection["dgvCalaisEntities"];
			dgvCalaisTopics = (DataGridView)mp.ObjectCollection["dgvCalaisTopics"];
			dgvCalaisEvents = (DataGridView)mp.ObjectCollection["dgvCalaisEvents"];

			// Semantria grids:
			dgvSemantriaEntities = (DataGridView)mp.ObjectCollection["dgvSemantriaEntities"];
			dgvSemantriaThemes = (DataGridView)mp.ObjectCollection["dgvSemantriaThemes"];
			dgvSemantriaTopics = (DataGridView)mp.ObjectCollection["dgvSemantriaTopics"];

			lblAlchemyEntities = (Label)mp.ObjectCollection["lblAlchemyEntities"]; ;
			lblAlchemyKeywords = (Label)mp.ObjectCollection["lblAlchemyKeywords"];
			lblAlchemyConcepts = (Label)mp.ObjectCollection["lblAlchemyConcepts"];
			lblCalaisEntities = (Label)mp.ObjectCollection["lblCalaisEntities"];
			lblCalaisTopics = (Label)mp.ObjectCollection["lblCalaisTopics"];
			lblCalaisEvents = (Label)mp.ObjectCollection["lblCalaisEvents"];
			lblSemantriaEntities = (Label)mp.ObjectCollection["lblSemantriaEntities"];
			lblSemantriaThemes = (Label)mp.ObjectCollection["lblSemantriaThemes"];
			lblSemantriaTopics = (Label)mp.ObjectCollection["lblSemantriaTopics"];

			btnProcess.Enabled = false;
			InitializeNLPs();

			Application.Run(form);
		}

		[STAThread]
		public static void Main()
		{
			Application.EnableVisualStyles();
			Application.SetCompatibleTextRenderingDefault(false);
			Program program = new Program();
			program.Initialize();
		}

		protected async void InitializeNLPs()
		{
			sbStatus.Text = "Initializing NLP's...";

			alchemy = await Task.Run(() =>
				{
					AlchemyWrapper api = new AlchemyWrapper();
					api.Initialize();
					return api;
				});

			calais = await Task.Run(() =>
			{
				CalaisWrapper api = new CalaisWrapper();
				api.Initialize();

				return api;
			});

			semantria = await Task.Run(() =>
				{
					SemantriaWrapper api = new SemantriaWrapper();
					api.Initialize();

					return api;
				});

			btnProcess.Enabled = true;
			sbStatus.Text = "Ready";
		}

		/// <summary>
		/// Process the URL with AlchemyAPI, OpenCalais, and Semantra NLP's.
		/// </summary>
		protected async void Process(object sender, EventArgs args)
		{
			btnProcess.Enabled = false;
			ClearAllGrids();
			string url = tbUrl.Text;
			sbStatus.Text = "Acquiring page content...";

			// Eases debugging when we comment out one or more of the NLP's to test the other.
			double alchemyTime = 0;
			double calaisTime = 0;
			double semantriaTime = 0;

			string pageText = await Task.Run(() => GetUrlText(url));

			sbStatus.Text = "Processing results with Alchemy...";

			alchemyTime = await Task.Run(() =>
				{
					LoadAlchemyResults(pageText);
					return ElapsedTime();
				});

			sbStatus.Text = "Processing results with OpenCalais...";

			calaisTime = await Task.Run(() =>
				{
					LoadCalaisResults(pageText);
					return ElapsedTime();
				});

			sbStatus.Text = "Processing results with Semantria...";

			semantriaTime = await Task.Run(() =>
				{
					LoadSemantriaResults(pageText);
					return ElapsedTime();
				});

			sbStatus.Text = "Done processing.";

			ReportTimes(alchemyTime, calaisTime, semantriaTime);
			btnProcess.Enabled = true;
		}

		/// <summary>
		/// Uses AlchemyAPI to scrape the URL.  Also caches the URL, so
		/// we don't hit AlchemyAPI's servers for repeat queries.
		/// </summary>
		protected string GetUrlText(string url)
		{
			string urlHash = url.GetHashCode().ToString();
			string textFilename = urlHash + ".txt";
			string pageText;

			if (File.Exists(textFilename))
			{
				pageText = File.ReadAllText(textFilename);
			}
			else
			{
				pageText = GetPageText(url);
			}

			File.WriteAllText(textFilename, pageText);

			return pageText;
		}

		protected void ClearAllGrids()
		{
			dgvEntities.DataSource = null;
			dgvKeywords.DataSource = null;
			dgvConcepts.DataSource = null;

			dgvCalaisEntities.DataSource = null;
			dgvCalaisTopics.DataSource = null;
			dgvCalaisEvents.DataSource = null;

			dgvSemantriaEntities.DataSource = null;
			dgvSemantriaThemes.DataSource = null;
			dgvSemantriaTopics.DataSource = null;
		}

		protected DateTime start;
		protected DateTime end;

		protected void StartTimer()
		{
			start = DateTime.Now;
			end = DateTime.Now;
		}

		/// <summary>
		/// Returns elapsed time in milliseconds.
		/// </summary>
		protected double StopTimer()
		{
			end = DateTime.Now;

			return ElapsedTime();
		}

		protected double ElapsedTime()
		{
			return (end - start).TotalSeconds;
		}

		protected void ReportTimes(double alchemyTime, double calaisTime, double semantriaTime)
		{
			string results = String.Format("AlchemyAPI: {0}\r\nOpenCalais: {1}\r\nSemantria: {2}", alchemyTime, calaisTime, semantriaTime);
			MessageBox.Show(results, "Processing Time (in seconds)", MessageBoxButtons.OK, MessageBoxIcon.Information);
		}

		/// <summary>
		/// We use AlchemyAPI to get the page text for OpenCalais and Semantria.
		/// </summary>
		protected string GetPageText(string url)
		{
			AlchemyWrapper alchemy = new AlchemyWrapper();
			alchemy.Initialize();

			string xml = alchemy.GetUrlText(url);
			XmlDocument xdoc = new XmlDocument();
			xdoc.LoadXml(xml);

			return xdoc.SelectSingleNode("//text").InnerText;
		}

		/// <summary>
		/// Have Alchemy process the URL and then we populate the DataGridView controls with views of the desired tables.
		/// </summary>
		protected void LoadAlchemyResults(string text)
		{
			try
			{
				StartTimer();
				DataSet dsEntities = alchemy.LoadEntities(text);
				DataSet dsKeywords = alchemy.LoadKeywords(text);
				DataSet dsConcepts = alchemy.LoadConcepts(text);
				StopTimer();

				form.BeginInvoke((Action)(() =>
					{
						dvEntities = new DataView(dsEntities.Tables["entity"]);
						dgvEntities.DataSource = dvEntities;

						dvKeywords = new DataView(dsKeywords.Tables["keyword"]);
						dgvKeywords.DataSource = dvKeywords;

						dvConcepts = new DataView(dsConcepts.Tables["concept"]);
						dgvConcepts.DataSource = dvConcepts;

						lblAlchemyEntities.Text = String.Format("Entities: {0}", dvEntities.Count);
						lblAlchemyKeywords.Text = String.Format("Keywords: {0}", dvKeywords.Count);
						lblAlchemyConcepts.Text = String.Format("Concepts: {0}", dvConcepts.Count);
					}));
			}
			catch (Exception ex)
			{
				ReportException(ex, "Alchemy: ");
			}
		}

		/// <summary>
		/// Have OpenCalais process the URL.
		/// </summary>
		protected void LoadCalaisResults(string text)
		{
			try
			{
				StartTimer();
				calais.ParseUrl(text);
				StopTimer();

				form.BeginInvoke((Action)(() =>
					{
						dgvCalaisEntities.DataSource = calais.GetEntities();
						dgvCalaisTopics.DataSource = calais.GetTopics();
						dgvCalaisEvents.DataSource = calais.GetEvents();

						lblCalaisEntities.Text = String.Format("Entities: {0}", ((IList)dgvCalaisEntities.DataSource).Count);
						lblCalaisTopics.Text = String.Format("Topics: {0}", ((IList)dgvCalaisTopics.DataSource).Count);
						lblCalaisEvents.Text = String.Format("Events: {0}", ((IList)dgvCalaisEvents.DataSource).Count);
					}));
			}
			catch (Exception ex)
			{
				ReportException(ex, "OpenCalais: ");
			}
		}

		/// <summary>
		/// Have Semantria process the URL.
		/// </summary>
		protected void LoadSemantriaResults(string text)
		{
			try
			{
				StartTimer();
				semantria.ParseUrl(text);
				StopTimer();

				form.BeginInvoke((Action)(() =>
					{
						dgvSemantriaEntities.DataSource = semantria.GetEntities();
						dgvSemantriaThemes.DataSource = semantria.GetThemes();
						dgvSemantriaTopics.DataSource = semantria.GetTopics();

						lblSemantriaEntities.Text = String.Format("Entities: {0}", ((IList)dgvSemantriaEntities.DataSource).Count);
						lblSemantriaThemes.Text = String.Format("Themes: {0}", ((IList)dgvSemantriaThemes.DataSource).Count);
						lblSemantriaTopics.Text = String.Format("Topics: {0}", ((IList)dgvSemantriaTopics.DataSource).Count);
					}));
			}
			catch (Exception ex)
			{
				ReportException(ex, "Semantria: ");
			}
		}

		protected void ReportException(Exception ex, string source)
		{
			MessageBox.Show(source + "\r\n" + ex.Message, "Error in processing", MessageBoxButtons.OK, MessageBoxIcon.Error);
		}
    }
}


text:
import { api } from '../config/api'
import { AREAS } from './actionTypes'

export const getArea = () => (dispatch, getState) => {
  const { lang } = getState()
  if (!getState().areas.length) {
    dispatch({ type: AREAS.REQUEST })
    return (
      fetch(api.areas)
      .then(res => res.json())
      .then((res) => {
        dispatch({ type: AREAS.SUCCESS, data: res })
      })
      .catch((err) => {
        dispatch({ type: AREAS.FAILURE, error: err })
      })
    )
  }
}


text:
using Markdown
using Mustache
using Dates
using SQLite
using Morsel
using DataFrames

include("setup.jl")
include("models.jl")

app = Morsel.app()
include("views.jl")
include("routes.jl")

global_context = { "staticroot" => staticroot }

function render(tpl, context)
	Mustache.render(tpl, merge(global_context, context))
end


text:
#include <aws/ec2/model/CreateLocalGatewayRouteTableVirtualInterfaceGroupAssociationResponse.h>
#include <aws/core/utils/xml/XmlSerializer.h>
#include <aws/core/AmazonWebServiceResult.h>
#include <aws/core/utils/StringUtils.h>
#include <aws/core/utils/logging/LogMacros.h>

#include <utility>

using namespace Aws::EC2::Model;
using namespace Aws::Utils::Xml;
using namespace Aws::Utils::Logging;
using namespace Aws::Utils;
using namespace Aws;

CreateLocalGatewayRouteTableVirtualInterfaceGroupAssociationResponse::CreateLocalGatewayRouteTableVirtualInterfaceGroupAssociationResponse()
{
}

CreateLocalGatewayRouteTableVirtualInterfaceGroupAssociationResponse::CreateLocalGatewayRouteTableVirtualInterfaceGroupAssociationResponse(const Aws::AmazonWebServiceResult<XmlDocument>& result)
{
  *this = result;
}

CreateLocalGatewayRouteTableVirtualInterfaceGroupAssociationResponse& CreateLocalGatewayRouteTableVirtualInterfaceGroupAssociationResponse::operator =(const Aws::AmazonWebServiceResult<XmlDocument>& result)
{
  const XmlDocument& xmlDocument = result.GetPayload();
  XmlNode rootNode = xmlDocument.GetRootElement();
  XmlNode resultNode = rootNode;
  if (!rootNode.IsNull() && (rootNode.GetName() != "CreateLocalGatewayRouteTableVirtualInterfaceGroupAssociationResponse"))
  {
    resultNode = rootNode.FirstChild("CreateLocalGatewayRouteTableVirtualInterfaceGroupAssociationResponse");
  }

  if(!resultNode.IsNull())
  {
    XmlNode localGatewayRouteTableVirtualInterfaceGroupAssociationNode = resultNode.FirstChild("localGatewayRouteTableVirtualInterfaceGroupAssociation");
    if(!localGatewayRouteTableVirtualInterfaceGroupAssociationNode.IsNull())
    {
      m_localGatewayRouteTableVirtualInterfaceGroupAssociation = localGatewayRouteTableVirtualInterfaceGroupAssociationNode;
    }
  }

  if (!rootNode.IsNull()) {
    XmlNode requestIdNode = rootNode.FirstChild("requestId");
    if (!requestIdNode.IsNull())
    {
      m_responseMetadata.SetRequestId(StringUtils::Trim(requestIdNode.GetText().c_str()));
    }
    AWS_LOGSTREAM_DEBUG("Aws::EC2::Model::CreateLocalGatewayRouteTableVirtualInterfaceGroupAssociationResponse", "x-amzn-request-id: " << m_responseMetadata.GetRequestId() );
  }
  return *this;
}


text:
    <input type='checkbox' name='attr_lock_playbook' class='sheet-lock'>
    <input type='checkbox' name='attr_lock_playbook' class='sheet-lock' style="display: none;">
    Playbook:

            <input type='checkbox' name='attr_lock_playbook' class='sheet-lock' style="display: none;">
    	        <input type="checkbox" name="attr_playbook" class="sheet-playbook" value='Beacon'/>The Beacon
    		    <input type="checkbox" name="attr_playbook" class="sheet-playbook" value='Bull'/>The Bull
		        <input type="checkbox" name="attr_playbook" class="sheet-playbook" value='Delinquent'/>The Delinquent
		        <input type="checkbox" name="attr_playbook" class="sheet-playbook" value='Doomed'/>The Doomed
		        <input type="checkbox" name="attr_playbook" class="sheet-playbook" value='Janus'/>The Janus
    		    <input type="checkbox" name="attr_playbook" class="sheet-playbook" value='Legacy'/>The Legacy
		        <input type="checkbox" name="attr_playbook" class="sheet-playbook" value='Nova'/>The Nova
		        <input type="checkbox" name="attr_playbook" class="sheet-playbook" value='Outsider'/>The Outsider
		        <input type="checkbox" name="attr_playbook" class="sheet-playbook" value='Protege'/>The Protégé
		        <input type="checkbox" name="attr_playbook" class="sheet-playbook" value='Transformed'/>The Transformed
		        <input type="checkbox" name="attr_playbook" class="sheet-playbook" value='Innocent'/>The Innocent
                <input type="checkbox" name="attr_playbook" class="sheet-playbook" value='Joined'/>The Joined
                <input type="checkbox" name="attr_playbook" class="sheet-playbook" value='Newborn'/>The Newborn
                <input type="checkbox" name="attr_playbook" class="sheet-playbook" value='Reformed'/>The Reformed
                <input type="checkbox" name="attr_playbook" class="sheet-playbook" value='Star'/>The Star
                <input type="checkbox" name="attr_playbook" class="sheet-playbook" value='Something'/>Something Else

                <input type="checkbox" name="attr_playbook" class="sheet-playbook" value='Beacon'/>The Beacon
    		    <input type="checkbox" name="attr_playbook" class="sheet-playbook" value='Bull'/>The Bull
		        <input type="checkbox" name="attr_playbook" class="sheet-playbook" value='Delinquent'/>The Delinquent
		        <input type="checkbox" name="attr_playbook" class="sheet-playbook" value='Doomed'/>The Doomed
		        <input type="checkbox" name="attr_playbook" class="sheet-playbook" value='Janus'/>The Janus

    		    <input type="checkbox" name="attr_playbook" class="sheet-playbook" value='Legacy'/>The Legacy
		        <input type="checkbox" name="attr_playbook" class="sheet-playbook" value='Nova'/>The Nova
		        <input type="checkbox" name="attr_playbook" class="sheet-playbook" value='Outsider'/>The Outsider
		        <input type="checkbox" name="attr_playbook" class="sheet-playbook" value='Protege'/>The Protégé
		        <input type="checkbox" name="attr_playbook" class="sheet-playbook" value='Transformed'/>The Transformed

		        <input type="checkbox" name="attr_playbook" class="sheet-playbook" value='Innocent'/>The Innocent
                <input type="checkbox" name="attr_playbook" class="sheet-playbook" value='Joined'/>The Joined
                <input type="checkbox" name="attr_playbook" class="sheet-playbook" value='Newborn'/>The Newborn
                <input type="checkbox" name="attr_playbook" class="sheet-playbook" value='Reformed'/>The Reformed
                <input type="checkbox" name="attr_playbook" class="sheet-playbook" value='Star'/>The Star

                <input type="checkbox" name="attr_playbook" class="sheet-playbook" value='Something'/>Something Else
            <input type='checkbox' name='attr_lock_playbook' class='sheet-lock' style="display: none;">

                <button type='roll' value='&{template:aw} {{name=@{character_name}}} {{roll_name=Freak}} {{roll_mod=@{freak}}} {{result=[[2d6 + [[{[[{[[@{freak} - @{hopeless} * 2 + ?{Situational bonus/penalty?|0}]],-3}dl1]],4}kl1]][Modifier]]]}}' name='roll_freak' ></button>
                Freak:
                <input type="checkbox" name="attr_freaklock" class="labellock">

				    <input type="number" name="attr_freak" min="-2" max="3" class="stat">

                    <input type="number" name="attr_freaklocked" value="@{freak}" class="lockedbox" disabled>

				    (unleash your powers)

        		<button type='roll' value='&{template:aw} {{name=@{character_name}}} {{roll_name=Danger}} {{roll_mod=@{danger}}} {{result=[[2d6 + [[{[[{[[@{danger} - @{afraid} * 2 + ?{Situational bonus/penalty?|0}]],-3}dl1]],4}kl1]][Modifier]]]}}' name='roll_danger' ></button>
				Danger:
                <input type="checkbox" name="attr_dangerlock" class="labellock">

    			    <input type="number" name="attr_danger" min="-2" max="3" class="stat">

                    <input type="number" name="attr_dangerlocked" value="@{danger}" class="lockedbox" disabled>

				    (directly engage)

        		<button type='roll' value='&{template:aw} {{name=@{character_name}}} {{roll_name=Savior}} {{roll_mod=@{savior}}} {{result=[[2d6 + [[{[[{[[@{savior} - @{insecure} * 2 + ?{Situational bonus/penalty?|0}]],-3}dl1]],4}kl1]][Modifier]]]}}' name='roll_savior' ></button>
				Savior:
                <input type="checkbox" name="attr_saviorlock" class="labellock">

        		    <input type="number" name="attr_savior" min="-2" max="3" class="stat">

                    <input type="number" name="attr_saviorlocked" value="@{savior}" class="lockedbox" disabled>

				    (defend)

            	<button type='roll' value='&{template:aw} {{name=@{character_name}}} {{roll_name=Superior}} {{roll_mod=@{superior}}} {{result=[[2d6 + [[{[[{[[@{superior} - @{guilty} * 2 + ?{Situational bonus/penalty?|0}]],-3}dl1]],4}kl1]][Modifier]]]}}' name='roll_superior' ></button>
				Superior:
                <input type="checkbox" name="attr_superiorlock" class="labellock">

        		    <input type="number" name="attr_superior" min="-2" max="3" class="stat">

                    <input type="number" name="attr_superiorlocked" value="@{superior}" class="lockedbox" disabled>

				    (assess the situation)

    			    (provoke someone)

            	<button type='roll' align="center" value='&{template:aw} {{name=@{character_name}}} {{roll_name=Mundane}} {{roll_mod=@{mundane}}} {{result=[[2d6 + [[{[[{[[@{mundane} - @{angry} * 2 + ?{Situational bonus/penalty?|0}]],-3}dl1]],4}kl1]][Modifier]]]}}' name='roll_mundane' ></button>
                Mundane:
                <input type="checkbox" name="attr_mundanelock" class="labellock">

        		    <input type="number" name="attr_mundane" min="-2" max="3" class="stat">

                    <input type="number" name="attr_mundanelocked" value="@{mundane}" class="lockedbox" disabled>

				    (pierce the mask)

                    (comfort or support)

                <button type='roll' value='&{template:aw} {{name=@{character_name}}} {{roll_name=something}} {{roll_mod=0}} {{result=[[2d6 + [[{[[{[[?{Situational bonus/penalty?|0}]],-3}dl1]],4}kl1]][Modifier]]]}}' name='roll_basic' ></button>
                Flat 2d6

                    (reject someone's influence)
                    (custom rolls)

                Sum of Labels:
    			<input type="number" name="attr_labeltotal" value='{{result=[[@{freak} + @{danger} + @{savior} + @{superior} + @{mundane}]]}}' disabled/>

				    (by default this should be a 3)

                    (advancement may increase this)

                    <input type="checkbox" name="attr_1exp">
                    <input type="checkbox" name="attr_2exp">
                    <input type="checkbox" name="attr_3exp">
                    <input type="checkbox" name="attr_4exp">
                    <input type="checkbox" name="attr_5exp">

                <fieldset class="repeating_advancements">
				<input type="text" name="attr_advancements" placeholder="(what did you take?)" data-i18n-placeholder="whatdidyoutake" autocomplete="off">
                </fieldset>

    			<fieldset class="repeating_activemoves">
                    <button type='roll' value='&{template:aw} {{name=@{character_name}}} {{roll_name=@{activemovename}}} {{roll_mod=[[@{activelabel}]]}} {{result=[[2d6 + [[{[[{[[@{activelabel} + ?{Situational bonus/penalty?|0}]],-3}dl1]],4}kl1]][Modifier]]]}}' name='roll_move'></button>
                    Move:
                    <input type="text" name="attr_activemovename" placeholder="(move name)" data-i18n-placeholder="movename" class="activemovename" autocomplete="off">
                    <input type="checkbox" name="attr_activemoveshowhide" class="activemoveshowhide">

                        Label:
                            <select name="attr_activelabel" class="moves">
                              <option type="radio" name="attr_label" value="@{freak}" data-i18n="freak">Freak</option>
        			          <option type="radio" name="attr_label" value="@{danger}" data-i18n="danger">Danger</option>
        			          <option type="radio" name="attr_label" value="@{savior}" data-i18n="savior">Savior</option>
        			          <option type="radio" name="attr_label" value="@{superior}" data-i18n="superior">Superior</option>
        			          <option type="radio" name="attr_label" value="@{mundane}" data-i18n="mundane">Mundane</option>
        			        </select>

                         <textarea name="attr_activemovedesc" placeholder="(move description)" data-i18n-placeholder="movedescription" autocomplete="off"></textarea>

    			</fieldset>

    			<fieldset class="repeating_passivemoves">
                    Move:
                    <input type="text" name="attr_passivemovename" placeholder="(move name)" data-i18n-placeholder="movename" class="passivemovename" autocomplete="off">
                    <input type="checkbox" name="attr_passivemoveshowhide" class="passivemoveshowhide">

                        <textarea name="attr_passivemovedesc" placeholder="(move description)" data-i18n-placeholder="movedescription" autocomplete="off"></textarea>

    			</fieldset>

                <button type='roll' align="center" value='&{template:aw} {{name=@{character_name}}} {{roll_name=Conditions}} {{roll_mod=[[@{afraid} + @{angry} + @{guilty} + @{insecure} + @{hopeless}]]}} {{result=[[2d6 + [[{[[{[[[[@{afraid} + @{angry} + @{guilty} + @{insecure} + @{hopeless}]] + ?{Situational bonus/penalty?|0}]],-3}dl1]],4}kl1]][Modifier]]]}}' name='roll_conditions' ></button>
                Conditions:
                <input type="number" name="attr_conditiontotal" value='{{result=[[@{afraid} + @{angry} + @{guilty} + @{insecure} + @{hopeless}]]}}' disabled/>

				    (take a powerful blow)

                    <input type="checkbox" value="1" name="attr_afraid"/>Afraid

                    (-2 to directly engage)

                    <input type="checkbox" value="1" name="attr_angry"/>Angry

                    (-2 to comfort or support)

                    (-2 to pierce the mask)

                    <input type="checkbox" value="1" name="attr_guilty"/>Guilty

                    (-2 to provoke someone)

                    (-2 to assess the situation)

                    <input type="checkbox" value="1" name="attr_insecure"/>Insecure

                    (-2 to defend)

                    (-2 to reject what others say)

                    <input type="checkbox" value="1" name="attr_hopeless"/>Hopeless

                    (-2 to unleash your powers)

                    <input type="checkbox" name="attr_playbook" class="sheet-isbeacon" value='Beacon' style="display: none;" />
        			<input type="checkbox" name="attr_playbook" class="sheet-isbull" value='Bull' style="display: none;" />
        			<input type="checkbox" name="attr_playbook" class="sheet-isdelinquent" value='Delinquent' style="display: none;" />
        			<input type="checkbox" name="attr_playbook" class="sheet-isdoomed" value='Doomed' style="display: none;" />
        			<input type="checkbox" name="attr_playbook" class="sheet-isjanus" value='Janus' style="display: none;" />
        			<input type="checkbox" name="attr_playbook" class="sheet-islegacy" value='Legacy' style="display: none;" />
        			<input type="checkbox" name="attr_playbook" class="sheet-isnova" value='Nova' style="display: none;" />
        			<input type="checkbox" name="attr_playbook" class="sheet-isoutsider" value='Outsider' style="display: none;" />
        			<input type="checkbox" name="attr_playbook" class="sheet-isprotege" value='Protege' style="display: none;" />
        			<input type="checkbox" name="attr_playbook" class="sheet-istransformed" value='Transformed' style="display: none;" />
        			<input type="checkbox" name="attr_playbook" class="sheet-isinnocent" value='Innocent' style="display: none;" />
                    <input type="checkbox" name="attr_playbook" class="sheet-isjoined" value='Joined' style="display: none;" />
                    <input type="checkbox" name="attr_playbook" class="sheet-isnewborn" value='Newborn' style="display: none;" />
                    <input type="checkbox" name="attr_playbook" class="sheet-isreformed" value='Reformed' style="display: none;" />
                    <input type="checkbox" name="attr_playbook" class="sheet-isstar" value='Star' style="display: none;" />
                    <input type="checkbox" name="attr_playbook" class="sheet-issomething" value='Something' style="display: none;" />

                                <fieldset class="repeating_drives">
                                    <input type="checkbox" name="attr_beacondrivehide" class="beacondrivehide">
                                    completed this set

                                        <input type="checkbox" name="attr_beacondrive1completed" class="beacondrivecompleted">
                                        <input type="text" name="attr_beacondrive1" class="beacondrive" placeholder="(drive)" data-i18n-placeholder="drive" autocomplete="off">

                                        <input type="checkbox" name="attr_beacondrive2completed" class="beacondrivecompleted">
                                        <input type="text" name="attr_beacondrive2" class="beacondrive" placeholder="(drive)" data-i18n-placeholder="drive" autocomplete="off">

                                        <input type="checkbox" name="attr_beacondrive3completed" class="beacondrivecompleted">
                                        <input type="text" name="attr_beacondrive3" class="beacondrive" placeholder="(drive)" data-i18n-placeholder="drive" autocomplete="off">

                                        <input type="checkbox" name="attr_beacondrive4completed" class="beacondrivecompleted">
                                        <input type="text" name="attr_beacondrive4" class="beacondrive" placeholder="(drive)" data-i18n-placeholder="drive" autocomplete="off">

                                </fieldset>

                                    Love:
                                    <input type="text" name="attr_bulllove" placeholder="(your love)" data-i18n-placeholder="yourlove" autocomplete="off"/>

                                    Rival:
                                    <input type="text" name="attr_bullrival" placeholder="(your rival)" data-i18n-placeholder="yourrival" autocomplete="off"/>

                                (add 1 to all rolls that target these two)

                                    <input type="checkbox" name="attr_1doom">
                                    <input type="checkbox" name="attr_2doom">
                                    <input type="checkbox" name="attr_3doom">
                                    <input type="checkbox" name="attr_4doom">
                                    <input type="checkbox" name="attr_5doom">

                                        <input type="checkbox" name="attr_doomsign1" class="doomsignmarked">
                                        Dark Visions

                                        <input type="checkbox" name="attr_doomsign5" class="doomsignmarked">
                                        Burning Bright

                                        <input type="checkbox" name="attr_doomsign3" class="doomsignmarked">
                                        Infinite Powers

                                        <input type="checkbox" name="attr_doomsign4" class="doomsignmarked">
                                        Bolstered

                                        <input type="checkbox" name="attr_doomsign2" class="doomsignmarked">
                                        Portal

                                        <input type="checkbox" name="attr_doomfinal" class="doomsignmarked">
                                        Your doom comes

                                    <button type='roll' align="center" value='&{template:aw} {{name=@{character_name}}} {{roll_name=Burn}} {{roll_mod=[[@{afraid} + @{angry} + @{guilty} + @{insecure} + @{hopeless}]]}} {{result=[[2d6 + [[{[[{[[[[@{afraid} + @{angry} + @{guilty} + @{insecure} + @{hopeless}]] + ?{Situational bonus/penalty?|0}]],-3}dl1]],4}kl1]][Modifier]]]}}' name='roll_conditions' ></button>
                                    Hold:
                                    <input type="number" name="attr_burnhold" min="0">

                                (reset to 0 at the end of the scene)

                                    <button type='roll' value='&{template:aw} {{name=@{character_name}}} {{roll_name=Embodied Mentor Label}} {{roll_mod=[[@{mentorembody}]]}} {{result=[[2d6 + [[{[[{[[@{mentorembody} + ?{Situational bonus/penalty?|0}]],-3}dl1]],4}kl1]][Modifier]]]}}' name='roll_embody'></button>
                                    Embodies:
                                    <select name="attr_mentorembody" class="mentormoves">
                                        <option type="radio" name="attr_embodylabel" value="@{freak}" data-i18n="freak">Freak</option>
                                        <option type="radio" name="attr_embodylabel" value="@{danger}" data-i18n="danger">Danger</option>
                                        <option type="radio" name="attr_embodylabel" value="@{savior}" data-i18n="savior">Savior</option>
                                        <option type="radio" name="attr_embodylabel" value="@{superior}" data-i18n="superior">Superior</option>
                                        <option type="radio" name="attr_embodylabel" value="@{mundane}" data-i18n="mundane">Mundane</option>
                                    </select>

                                    <button type='roll' value='&{template:aw} {{name=@{character_name}}} {{roll_name=Denied Mentor Label}} {{roll_mod=[[@{mentordeny}]]}} {{result=[[2d6 + [[{[[{[[@{mentordeny} + ?{Situational bonus/penalty?|0}]],-3}dl1]],4}kl1]][Modifier]]]}}' name='roll_deny'></button>
                                    Denies:
                                    <select name="attr_mentordeny" class="mentormoves">
                                        <option type="radio" name="attr_denylabel" value="@{freak}" data-i18n="freak">Freak</option>
                                        <option type="radio" name="attr_denylabel" value="@{danger}" data-i18n="danger">Danger</option>
                                        <option type="radio" name="attr_denylabel" value="@{savior}" data-i18n="savior">Savior</option>
                                        <option type="radio" name="attr_denylabel" value="@{superior}" data-i18n="superior">Superior</option>
                                        <option type="radio" name="attr_denylabel" value="@{mundane}" data-i18n="mundane">Mundane</option>
                                    </select>

                                <input type="text" name="attr_newbornlesson1" placeholder="(I am...)" data-i18n-placeholder="iam" autocomplete="off"/>

                                <input type="text" name="attr_newbornlesson2" placeholder="(A superhero should...)" data-i18n-placeholder="asuperheroshould" autocomplete="off"/>

                                <input type="text" name="attr_newbornlesson3" placeholder="(Always...)" data-i18n-placeholder="always" autocomplete="off"/>

                                <input type="text" name="attr_newbornlesson4" placeholder="(Never...)" data-i18n-placeholder="never" autocomplete="off"/>

                            <fieldset class="repeating_contacts">
                                <input type="text" name="attr_reformedcontact" placeholder="(villainous contact)" data-i18n-placeholder="villainouscontact" autocomplete="off">

                                <input type="checkbox" name="attr_1obligation">
                                <input type="checkbox" name="attr_2obligation">
                                <input type="checkbox" name="attr_3obligation">
                                <input type="checkbox" name="attr_4obligation">

                            </fieldset>

                (add 1 to all rolls that target these people)

                <fieldset class="repeating_influence">
				<input type="text" name="attr_influence" style="font-size: 1em; font-weight: bold" placeholder="(their name)" autocomplete="off">
                </fieldset>

<rolltemplate class="sheet-rolltemplate-aw">

{{name}} rolls
{{#roll_name}}{{roll_name}}{{/roll_name}}{{#roll_mod}}{{/roll_mod}}

            {{#rollTotal() result 16}}
                {{result}}
                KAPOW!
            {{/rollTotal() result 16}}
            {{#rollTotal() result 15}}
                {{result}}
            	KAPOW!
            {{/rollTotal() result 15}}
            {{#rollTotal() result 14}}
                {{result}}
            	KAPOW!
            {{/rollTotal() result 14}}
            {{#rollTotal() result 13}}
                {{result}}
            	Full hit!
            {{/rollTotal() result 13}}
            {{#rollTotal() result 12}}
                {{result}}
            	Full hit!
            {{/rollTotal() result 12}}
            {{#rollTotal() result 11}}
                {{result}}
            	Full hit!
            {{/rollTotal() result 11}}
            {{#rollTotal() result 10}}
            	{{result}}
            	Full hit!
            {{/rollTotal() result 10}}
            {{#rollTotal() result 9}}
            	{{result}}
            	Hit!
            {{/rollTotal() result 9}}
            {{#rollTotal() result 8}}
            	{{result}}
            	Hit!
            {{/rollTotal() result 8}}
            {{#rollTotal() result 7}}
            	{{result}}
            	Hit!
            {{/rollTotal() result 7}}
            {{#rollTotal() result 6}}
            	{{result}}
            	Miss
            {{/rollTotal() result 6}}
            {{#rollTotal() result 5}}
            	{{result}}
            	Miss
            {{/rollTotal() result 5}}
            {{#rollTotal() result 4}}
                {{result}}
            	Miss
            {{/rollTotal() result 4}}
            {{#rollTotal() result 3}}
                {{result}}
            	Miss
            {{/rollTotal() result 3}}
            {{#rollTotal() result 2}}
                {{result}}
            	oh dear
            {{/rollTotal() result 2}}
            {{#rollTotal() result 1}}
                {{result}}
            	oh dear
            {{/rollTotal() result 1}}
            {{#rollTotal() result 0}}
                {{result}}
            	oh dear
            {{/rollTotal() result 0}}
            {{#rollTotal() result -1}}
                {{result}}
                oh dear
            {{/rollTotal() result -1}}

</rolltemplate>


text:
package org.jboss.netty.handler.ipfilter;

import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.StringTokenizer;
import java.util.Vector;

/**
 * This class allows to check if an IP-V4-Address is contained in a subnet.

 * Supported Formats for the Subnets are: 1.1.1.1/255.255.255.255 or 1.1.1.1/32 (CIDR-Notation)
 * and (InetAddress,Mask) where Mask is a integer for CIDR-notation or a String for Standard Mask notation.

 *

Example1:

 * <tt>IpV4Subnet ips = new IpV4Subnet("192.168.1.0/24");</tt>

 * <tt>System.out.println("Result: "+ ips.contains("192.168.1.123"));</tt>

 * <tt>System.out.println("Result: "+ ips.contains(inetAddress2));</tt>

 *
Example1 bis:

 * <tt>IpV4Subnet ips = new IpV4Subnet(inetAddress, 24);</tt>

 * where inetAddress is 192.168.1.0 and inetAddress2 is 192.168.1.123

 *

Example2:

 * <tt>IpV4Subnet ips = new IpV4Subnet("192.168.1.0/255.255.255.0");</tt>

 * <tt>System.out.println("Result: "+ ips.contains("192.168.1.123"));</tt>

 * <tt>System.out.println("Result: "+ ips.contains(inetAddress2));</tt>

 *
Example2 bis:

 * <tt>IpV4Subnet ips = new IpV4Subnet(inetAddress, "255.255.255.0");</tt>

 * where inetAddress is 192.168.1.0 and inetAddress2 is 192.168.1.123

 * @author frederic bregier
 *
 */
public class IpV4Subnet implements IpSet, Comparable<IpV4Subnet>
{
   private static final int SUBNET_MASK = 0x80000000;

   private static final int BYTE_ADDRESS_MASK = 0xFF;

   private InetAddress inetAddress;

   private int subnet;

   private int mask;

   private int cidrMask;

   /**
    * Create IpV4Subnet for ALL (used for ALLOW or DENY ALL)
    */
   public IpV4Subnet()
   {
      // ALLOW or DENY ALL
      mask = -1;
      // other will be ignored
      inetAddress = null;
      subnet = 0;
      cidrMask = 0;
   }

   /**
    * Create IpV4Subnet using the CIDR or normal Notation

    * i.e.:
    * IpV4Subnet subnet = new IpV4Subnet("10.10.10.0/24"); or
    * IpV4Subnet subnet = new IpV4Subnet("10.10.10.0/255.255.255.0");
    * @param netAddress a network address as string.
    * @throws UnknownHostException
    * */
   public IpV4Subnet(String netAddress) throws UnknownHostException
   {
      setNetAddress(netAddress);
   }

   /**
    * Create IpV4Subnet using the CIDR Notation
    * @param inetAddress
    * @param cidrNetMask
    */
   public IpV4Subnet(InetAddress inetAddress, int cidrNetMask)
   {
      setNetAddress(inetAddress, cidrNetMask);
   }

   /**
    * Create IpV4Subnet using the normal Notation
    * @param inetAddress
    * @param netMask
    */
   public IpV4Subnet(InetAddress inetAddress, String netMask)
   {
      setNetAddress(inetAddress, netMask);
   }

   /**
    * Sets the Network Address in either CIDR or Decimal Notation.

    * i.e.: setNetAddress("1.1.1.1/24"); or

    * setNetAddress("1.1.1.1/255.255.255.0");

    * @param netAddress a network address as string.
    * @throws UnknownHostException
    * */
   private void setNetAddress(String netAddress) throws UnknownHostException
   {
      Vector<Object> vec = new Vector<Object>();
      StringTokenizer st = new StringTokenizer(netAddress, "/");
      while (st.hasMoreTokens())
      {
         vec.add(st.nextElement());
      }

      if (vec.get(1).toString().length() < 3)
      {
         setNetId(vec.get(0).toString());
         setCidrNetMask(Integer.parseInt(vec.get(1).toString()));
      }
      else
      {
         setNetId(vec.get(0).toString());
         setNetMask(vec.get(1).toString());
      }
   }

   /**
    * Sets the Network Address in CIDR Notation.
    * @param inetAddress
    * @param cidrNetMask
    * */
   private void setNetAddress(InetAddress inetAddress, int cidrNetMask)
   {
      setNetId(inetAddress);
      setCidrNetMask(cidrNetMask);
   }

   /**
    * Sets the Network Address in Decimal Notation.
    * @param inetAddress
    * @param netMask
    * */
   private void setNetAddress(InetAddress inetAddress, String netMask)
   {
      setNetId(inetAddress);
      setNetMask(netMask);
   }

   /**
    * Sets the BaseAdress of the Subnet.

    * i.e.: setNetId("192.168.1.0");
    * @param netId a network ID
    * @throws UnknownHostException
    * */
   private void setNetId(String netId) throws UnknownHostException
   {
      InetAddress inetAddress1 = InetAddress.getByName(netId);
      this.setNetId(inetAddress1);
   }

   /**
    * Compute integer representation of InetAddress
    * @param inetAddress1
    * @return the integer representation
    */
   private int toInt(InetAddress inetAddress1)
   {
      byte[] address = inetAddress1.getAddress();
      int net = 0;
      for (byte addres : address)
      {
         net <<= 8;
         net |= addres & BYTE_ADDRESS_MASK;
      }
      return net;
   }

   /**
    * Sets the BaseAdress of the Subnet.
    * @param inetAddress
    * */
   private void setNetId(InetAddress inetAddress)
   {
      this.inetAddress = inetAddress;
      subnet = toInt(inetAddress);
   }

   /**
    * Sets the Subnet's Netmask in Decimal format.

    * i.e.: setNetMask("255.255.255.0");
    * @param netMask a network mask
    * */
   private void setNetMask(String netMask)
   {
      StringTokenizer nm = new StringTokenizer(netMask, ".");
      int i = 0;
      int[] netmask = new int[4];
      while (nm.hasMoreTokens())
      {
         netmask[i] = Integer.parseInt(nm.nextToken());
         i++;
      }
      int mask1 = 0;
      for (i = 0; i < 4; i++)
      {
         mask1 += Integer.bitCount(netmask[i]);
      }
      setCidrNetMask(mask1);
   }

   /**
    * Sets the CIDR Netmask

    * i.e.: setCidrNetMask(24);
    * @param cidrNetMask a netmask in CIDR notation
    * */
   private void setCidrNetMask(int cidrNetMask)
   {
      cidrMask = cidrNetMask;
      mask = SUBNET_MASK >> cidrMask - 1;
   }

   /**
    * Compares the given IP-Address against the Subnet and returns true if
    * the ip is in the subnet-ip-range and false if not.
    * @param ipAddr an ipaddress
    * @return returns true if the given IP address is inside the currently
    * set network.
    * @throws UnknownHostException
    * */
   public boolean contains(String ipAddr) throws UnknownHostException
   {
      InetAddress inetAddress1 = InetAddress.getByName(ipAddr);
      return this.contains(inetAddress1);
   }

   /**
    * Compares the given InetAddress against the Subnet and returns true if
    * the ip is in the subnet-ip-range and false if not.
    * @param inetAddress1
    * @return returns true if the given IP address is inside the currently
    * set network.
    * */
   public boolean contains(InetAddress inetAddress1)
   {
      if (mask == -1)
      {
         // ANY
         return true;
      }
      return (toInt(inetAddress1) & mask) == subnet;
   }

   @Override
   public String toString()
   {
      return inetAddress.getHostAddress() + "/" + cidrMask;
   }

   @Override
   public boolean equals(Object o)
   {
      if (!(o instanceof IpV4Subnet))
      {
         return false;
      }
      IpV4Subnet ipV4Subnet = (IpV4Subnet) o;
      return ipV4Subnet.subnet == subnet && ipV4Subnet.cidrMask == cidrMask;
   }

   /**
    * Compare two IpV4Subnet
    */
   public int compareTo(IpV4Subnet o)
   {
      if (o.subnet == subnet && o.cidrMask == cidrMask)
      {
         return 0;
      }
      if (o.subnet < subnet)
      {
         return 1;
      }
      else if (o.subnet > subnet)
      {
         return -1;
      }
      else if (o.cidrMask < cidrMask)
      {
         // greater Mask means less IpAddresses so -1
         return -1;
      }
      return 1;
   }

   /**
    * Simple test functions
    * @param args
    *          where args[0] is the netmask (standard or CIDR notation) and optional args[1] is
    *          the inetAddress to test with this IpV4Subnet
    */
   public static void main(String[] args)
   {
      if (args.length != 0)
      {
         IpV4Subnet ipV4Subnet = null;
         try
         {
            ipV4Subnet = new IpV4Subnet(args[0]);
         }
         catch (UnknownHostException e)
         {
            return;
         }
         if (args.length > 1)
         {
            try
            {
               System.out.println("Is IN: " + args[1] + " " + ipV4Subnet.contains(args[1]));
            }
            catch (UnknownHostException e)
            {
            }
         }
      }
   }
}


text:
install:
	gem install atomizr

atom:
	atomizr -i "snippets/**/*.sublime-snippet" -o snippets.cson --merge
	mv _output/snippets.cson snippets/snippets.cson
	echo "There's currently a bug in atomizr; please open snippets/snippets.cson and escape the values for alignItems and justifyContent. Additionally, add a comma in the initial '.source.js,source.jsx' declaration."


text:
package org.tolweb.tapestry.xml.taxaimport;

import java.io.Serializable;

import org.tolweb.hibernate.MappedNode;

public class BtolTuple extends NodeTuple<MappedNode> implements Serializable {

	/** */
	private static final long serialVersionUID = -6491308810176326347L;
	private boolean hasAdditionalFields;
	private boolean hasStatuses;

	public BtolTuple(MappedNode node) {
		super(node);
	}

	/**
	 * @return the hasAdditionalFields
	 */
	public boolean getHasAdditionalFields() {
		return hasAdditionalFields;
	}

	/**
	 * @param hasAdditionalFields the hasAdditionalFields to set
	 */
	public void setHasAdditionalFields(boolean hasAdditionalFields) {
		this.hasAdditionalFields = hasAdditionalFields;
	}

	/**
	 * @return the hasStatuses
	 */
	public boolean getHasStatuses() {
		return hasStatuses;
	}

	/**
	 * @param hasStatuses the hasStatuses to set
	 */
	public void setHasStatuses(boolean hasStatuses) {
		this.hasStatuses = hasStatuses;
	}
}