text:
Every ByteScout tool includes simple example C# source codes that you can get here or in the folder with installed ByteScout product. ByteScout Premium Suite is the set that includes 12 SDK products from ByteScout including tools and components for PDF, barcodes, spreadsheets, screen video recording. It can be applied to convert digital photos to pdf with pdf sdk using C#.

This prolific sample source code in C# for ByteScout Premium Suite contains various functions and other necessary options you should do calling the API to convert digital photos to pdf with pdf sdk. Just copy and paste the code into your C# application's code and follow the instructions. Check C# sample code samples to see if they respond to your needs and requirements for the project.

Trial version of ByteScout Premium Suite is available for free. Source code samples are included to help you with your C# app.

## REQUEST FREE TECH SUPPORT

[Click here to get in touch](https://bytescout.zendesk.com/hc/en-us/requests/new?subject=ByteScout%20Premium%20Suite%20Question)

or just send email to [support@bytescout.com](mailto:support@bytescout.com?subject=ByteScout%20Premium%20Suite%20Question)

## ON-PREMISE OFFLINE SDK

[Get Your 60 Day Free Trial](https://bytescout.com/download/web-installer?utm_source=github-readme)
[Explore SDK Docs](https://bytescout.com/documentation/index.html?utm_source=github-readme)
[Sign Up For Online Training](https://academy.bytescout.com/)

## ON-DEMAND REST WEB API

[Get your API key](https://pdf.co/documentation/api?utm_source=github-readme)
[Explore Web API Documentation](https://pdf.co/documentation/api?utm_source=github-readme)
[Explore Web API Samples](https://github.com/bytescout/ByteScout-SDK-SourceCode/tree/master/PDF.co%20Web%20API)

## VIDEO REVIEW

[https://www.youtube.com/watch?v=NEwNs2b9YN8](https://www.youtube.com/watch?v=NEwNs2b9YN8)

<!-- code block begin -->

##### ****Images.NETCore.csproj:**

```
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp2.0</TargetFramework>
    <EnableDefaultCompileItems>false</EnableDefaultCompileItems>
    <GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
    <GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
    <GenerateAssemblyFileVersionAttribute>false</GenerateAssemblyFileVersionAttribute>
    <GenerateAssemblyInformationalVersionAttribute>false</GenerateAssemblyInformationalVersionAttribute>
    <GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
    <GenerateAssemblyTitleAttribute>false</GenerateAssemblyTitleAttribute>
    <GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute>
    <GenerateAssemblyCopyrightAttribute>false</GenerateAssemblyCopyrightAttribute>
    <GenerateAssemblyTrademarkAttribute>false</GenerateAssemblyTrademarkAttribute>
    <GenerateAssemblyCultureAttribute>false</GenerateAssemblyCultureAttribute>
    <GenerateAssemblyDescriptionAttribute>false</GenerateAssemblyDescriptionAttribute>
  </PropertyGroup>
  <ItemGroup>
    <Compile Include="Program.cs" />
    <None Include="Image1.jpg">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </None>
    <None Include="Image2.jpg">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </None>
  </ItemGroup>
  <ItemGroup>
    <PackageReference Include="Microsoft.Windows.Compatibility" Version="2.0.0" />
  </ItemGroup>
  <ItemGroup>
    <Reference Include="Bytescout.PDF">
      <SpecificVersion>False</SpecificVersion>
      <HintPath>c:\Program Files\Bytescout PDF SDK\netcoreapp2.0\Bytescout.PDF.dll</HintPath>
    </Reference>
  </ItemGroup>
</Project>
```

<!-- code block end -->

<!-- code block begin -->

##### ****Images.VS2005.csproj:**

```
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
  <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    <ProjectGuid>{474F52FF-3928-44EA-8F6F-379E9DAA23FF}</ProjectGuid>
    <OutputType>Exe</OutputType>
    <RootNamespace>Images</RootNamespace>
    <AssemblyName>Images</AssemblyName>
    <FileAlignment>512</FileAlignment>
    <ProductVersion>8.0.50727</ProductVersion>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
    <PlatformTarget>AnyCPU</PlatformTarget>
    <DebugSymbols>true</DebugSymbols>
    <DebugType>full</DebugType>
    <Optimize>false</Optimize>
    <OutputPath>bin\Debug\</OutputPath>
    <DefineConstants>DEBUG;TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    <PlatformTarget>AnyCPU</PlatformTarget>
    <DebugType>pdbonly</DebugType>
    <Optimize>true</Optimize>
    <OutputPath>bin\Release\</OutputPath>
    <DefineConstants>TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
  </PropertyGroup>
  <ItemGroup>
    <Reference Include="Bytescout.PDF, Version=1.0.0.15, Culture=neutral, PublicKeyToken=f7dd1bd9d40a50eb, processorArchitecture=MSIL">
      <SpecificVersion>False</SpecificVersion>
    </Reference>
    <Reference Include="System" />
    <Reference Include="System.Data" />
    <Reference Include="System.Drawing" />
  </ItemGroup>
  <ItemGroup>
    <Compile Include="Program.cs" />
  </ItemGroup>
  <ItemGroup>
    <Content Include="Image1.jpg">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </Content>
    <Content Include="Image2.jpg">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </Content>
  </ItemGroup>
  <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
  <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
       Other similar extension points exist, see Microsoft.Common.targets.
  <Target Name="BeforeBuild">
  </Target>
  <Target Name="AfterBuild">
  </Target>
  -->
</Project>
```

<!-- code block end -->

<!-- code block begin -->

##### ****Images.VS2008.csproj:**

```
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
  <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    <ProjectGuid>{474F52FF-3928-44EA-8F6F-379E9DAA23FF}</ProjectGuid>
    <OutputType>Exe</OutputType>
    <RootNamespace>Images</RootNamespace>
    <AssemblyName>Images</AssemblyName>
    <TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
    <FileAlignment>512</FileAlignment>
    <ProductVersion>9.0.30729</ProductVersion>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
    <PlatformTarget>AnyCPU</PlatformTarget>
    <DebugSymbols>true</DebugSymbols>
    <DebugType>full</DebugType>
    <Optimize>false</Optimize>
    <OutputPath>bin\Debug\</OutputPath>
    <DefineConstants>DEBUG;TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    <PlatformTarget>AnyCPU</PlatformTarget>
    <DebugType>pdbonly</DebugType>
    <Optimize>true</Optimize>
    <OutputPath>bin\Release\</OutputPath>
    <DefineConstants>TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
  </PropertyGroup>
  <ItemGroup>
    <Reference Include="Bytescout.PDF, Version=1.0.0.15, Culture=neutral, PublicKeyToken=f7dd1bd9d40a50eb, processorArchitecture=MSIL">
      <SpecificVersion>False</SpecificVersion>
    </Reference>
    <Reference Include="System" />
    <Reference Include="System.Data" />
    <Reference Include="System.Drawing" />
  </ItemGroup>
  <ItemGroup>
    <Compile Include="Program.cs" />
  </ItemGroup>
  <ItemGroup>
    <Content Include="Image1.jpg">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </Content>
    <Content Include="Image2.jpg">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </Content>
  </ItemGroup>
  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
  <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
       Other similar extension points exist, see Microsoft.Common.targets.
  <Target Name="BeforeBuild">
  </Target>
  <Target Name="AfterBuild">
  </Target>
  -->
</Project>
```

<!-- code block end -->

<!-- code block begin -->

##### ****Images.VS2010.csproj:**

```
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
  <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    <ProjectGuid>{474F52FF-3928-44EA-8F6F-379E9DAA23FF}</ProjectGuid>
    <OutputType>Exe</OutputType>
    <RootNamespace>Images</RootNamespace>
    <AssemblyName>Images</AssemblyName>
    <TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
    <FileAlignment>512</FileAlignment>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
    <PlatformTarget>AnyCPU</PlatformTarget>
    <DebugSymbols>true</DebugSymbols>
    <DebugType>full</DebugType>
    <Optimize>false</Optimize>
    <OutputPath>bin\Debug\</OutputPath>
    <DefineConstants>DEBUG;TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    <PlatformTarget>AnyCPU</PlatformTarget>
    <DebugType>pdbonly</DebugType>
    <Optimize>true</Optimize>
    <OutputPath>bin\Release\</OutputPath>
    <DefineConstants>TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
  </PropertyGroup>
  <ItemGroup>
    <Reference Include="Bytescout.PDF, Version=1.0.0.15, Culture=neutral, PublicKeyToken=f7dd1bd9d40a50eb, processorArchitecture=MSIL">
      <SpecificVersion>False</SpecificVersion>
    </Reference>
    <Reference Include="System" />
    <Reference Include="System.Data" />
    <Reference Include="System.Drawing" />
  </ItemGroup>
  <ItemGroup>
    <Compile Include="Program.cs" />
  </ItemGroup>
  <ItemGroup>
    <Content Include="Image1.jpg">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </Content>
    <Content Include="Image2.jpg">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </Content>
  </ItemGroup>
  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
  <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
       Other similar extension points exist, see Microsoft.Common.targets.
  <Target Name="BeforeBuild">
  </Target>
  <Target Name="AfterBuild">
  </Target>
  -->
</Project>
```

<!-- code block end -->

<!-- code block begin -->

##### ****Images.VS2012.csproj:**

```
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
  <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    <ProjectGuid>{474F52FF-3928-44EA-8F6F-379E9DAA23FF}</ProjectGuid>
    <OutputType>Exe</OutputType>
    <RootNamespace>Images</RootNamespace>
    <AssemblyName>Images</AssemblyName>
    <TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
    <FileAlignment>512</FileAlignment>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
    <PlatformTarget>AnyCPU</PlatformTarget>
    <DebugSymbols>true</DebugSymbols>
    <DebugType>full</DebugType>
    <Optimize>false</Optimize>
    <OutputPath>bin\Debug\</OutputPath>
    <DefineConstants>DEBUG;TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    <PlatformTarget>AnyCPU</PlatformTarget>
    <DebugType>pdbonly</DebugType>
    <Optimize>true</Optimize>
    <OutputPath>bin\Release\</OutputPath>
    <DefineConstants>TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
  </PropertyGroup>
  <ItemGroup>
    <Reference Include="Bytescout.PDF, Version=1.0.0.15, Culture=neutral, PublicKeyToken=f7dd1bd9d40a50eb, processorArchitecture=MSIL">
      <SpecificVersion>False</SpecificVersion>
    </Reference>
    <Reference Include="System" />
    <Reference Include="System.Data" />
    <Reference Include="System.Drawing" />
  </ItemGroup>
  <ItemGroup>
    <Compile Include="Program.cs" />
  </ItemGroup>
  <ItemGroup>
    <Content Include="Image1.jpg">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </Content>
    <Content Include="Image2.jpg">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </Content>
  </ItemGroup>
  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
  <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
       Other similar extension points exist, see Microsoft.Common.targets.
  <Target Name="BeforeBuild">
  </Target>
  <Target Name="AfterBuild">
  </Target>
  -->
</Project>
```

<!-- code block end -->

<!-- code block begin -->

##### ****Images.VS2013.csproj:**

```
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
  <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    <ProjectGuid>{474F52FF-3928-44EA-8F6F-379E9DAA23FF}</ProjectGuid>
    <OutputType>Exe</OutputType>
    <RootNamespace>Images</RootNamespace>
    <AssemblyName>Images</AssemblyName>
    <TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
    <FileAlignment>512</FileAlignment>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
    <PlatformTarget>AnyCPU</PlatformTarget>
    <DebugSymbols>true</DebugSymbols>
    <DebugType>full</DebugType>
    <Optimize>false</Optimize>
    <OutputPath>bin\Debug\</OutputPath>
    <DefineConstants>DEBUG;TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    <PlatformTarget>AnyCPU</PlatformTarget>
    <DebugType>pdbonly</DebugType>
    <Optimize>true</Optimize>
    <OutputPath>bin\Release\</OutputPath>
    <DefineConstants>TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
  </PropertyGroup>
  <ItemGroup>
    <Reference Include="Bytescout.PDF, Version=1.0.0.15, Culture=neutral, PublicKeyToken=f7dd1bd9d40a50eb, processorArchitecture=MSIL">
      <SpecificVersion>False</SpecificVersion>
    </Reference>
    <Reference Include="System" />
    <Reference Include="System.Data" />
    <Reference Include="System.Drawing" />
  </ItemGroup>
  <ItemGroup>
    <Compile Include="Program.cs" />
  </ItemGroup>
  <ItemGroup>
    <Content Include="Image1.jpg">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </Content>
    <Content Include="Image2.jpg">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </Content>
  </ItemGroup>
  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
  <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
       Other similar extension points exist, see Microsoft.Common.targets.
  <Target Name="BeforeBuild">
  </Target>
  <Target Name="AfterBuild">
  </Target>
  -->
</Project>
```

<!-- code block end -->

<!-- code block begin -->

##### ****Images.VS2015.csproj:**

```
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
  <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    <ProjectGuid>{474F52FF-3928-44EA-8F6F-379E9DAA23FF}</ProjectGuid>
    <OutputType>Exe</OutputType>
    <RootNamespace>Images</RootNamespace>
    <AssemblyName>Images</AssemblyName>
    <TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
    <FileAlignment>512</FileAlignment>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
    <PlatformTarget>AnyCPU</PlatformTarget>
    <DebugSymbols>true</DebugSymbols>
    <DebugType>full</DebugType>
    <Optimize>false</Optimize>
    <OutputPath>bin\Debug\</OutputPath>
    <DefineConstants>DEBUG;TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    <PlatformTarget>AnyCPU</PlatformTarget>
    <DebugType>pdbonly</DebugType>
    <Optimize>true</Optimize>
    <OutputPath>bin\Release\</OutputPath>
    <DefineConstants>TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
  </PropertyGroup>
  <ItemGroup>
    <Reference Include="Bytescout.PDF, Version=1.0.0.15, Culture=neutral, PublicKeyToken=f7dd1bd9d40a50eb, processorArchitecture=MSIL">
      <SpecificVersion>False</SpecificVersion>
    </Reference>
    <Reference Include="System" />
    <Reference Include="System.Data" />
    <Reference Include="System.Drawing" />
  </ItemGroup>
  <ItemGroup>
    <Compile Include="Program.cs" />
  </ItemGroup>
  <ItemGroup>
    <Content Include="Image1.jpg">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </Content>
    <Content Include="Image2.jpg">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </Content>
  </ItemGroup>
  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
  <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
       Other similar extension points exist, see Microsoft.Common.targets.
  <Target Name="BeforeBuild">
  </Target>
  <Target Name="AfterBuild">
  </Target>
  -->
</Project>
```

<!-- code block end -->

<!-- code block begin -->

##### ****Program.cs:**

```
using System;
using System.Diagnostics;
using Bytescout.PDF;
using Image = Bytescout.PDF.Image;

namespace Images
{
    /// <summary>
    /// This example demonstrates how to add images in their proper orientation and size
    /// </summary>
    class Program
    {
        static void Main()
        {
            // Create new document
            Document pdfDocument = new Document();
            pdfDocument.RegistrationName = "demo";
            pdfDocument.RegistrationKey = "demo";

            // Input image array
            var arrImages = new string[]{ "Image1.jpg", "Image2.jpg" };

            // Process each image
            foreach (var itmImage in arrImages)
            {
                var sysImage = FixImageOrientation(itmImage);

                using (sysImage)
                {
                    var image = new Image(sysImage, ImageCompression.DCT, 75);
                    float w = sysImage.Width / sysImage.HorizontalResolution * 72f;
                    float h = sysImage.Height / sysImage.VerticalResolution * 72f;

                    // Create PDF page
                    var page = new Page(w, h);

                    var canvas = page.Canvas;
                    canvas.DrawImage(image, 0, 0, w, h);

                    // Add PDF document
                    pdfDocument.Pages.Add(page);
                }
            }

            // Save PDF document
            pdfDocument.Save("result.pdf");

            // Cleanup
            pdfDocument.Dispose();

            // Open result document in default associated application (for demo purpose)
            ProcessStartInfo processStartInfo = new ProcessStartInfo("result.pdf");
            processStartInfo.UseShellExecute = true;
            Process.Start(processStartInfo);
        }

        /// <summary>
        /// Fix image orientation
        /// </summary>
        static System.Drawing.Image FixImageOrientation(string fileName)
        {
            System.Drawing.Image sysImage = System.Drawing.Image.FromFile(fileName, false);

            // fix orientation by EXIF rotation tag
            const int exifRotationTag = 0x0112;
            int[] propertyItemIDs = sysImage.PropertyIdList;

            int found = Array.BinarySearch(propertyItemIDs, 0, propertyItemIDs.Length, exifRotationTag);

            if (found > -1)
            {
                System.Drawing.Imaging.PropertyItem pi = sysImage.GetPropertyItem(exifRotationTag);
                int orientation = pi.Value[0];

                switch (orientation)
                {
                    case 2:
                        sysImage.RotateFlip(System.Drawing.RotateFlipType.RotateNoneFlipX);
                        break;
                    case 3:
                        sysImage.RotateFlip(System.Drawing.RotateFlipType.Rotate180FlipNone);
                        break;
                    case 4:
                        sysImage.RotateFlip(System.Drawing.RotateFlipType.RotateNoneFlipY);
                        break;
                    case 5:
                        sysImage.RotateFlip(System.Drawing.RotateFlipType.Rotate90FlipX);
                        break;
                    case 6:
                        sysImage.RotateFlip(System.Drawing.RotateFlipType.Rotate90FlipNone);
                        break;
                    case 7:
                        sysImage.RotateFlip(System.Drawing.RotateFlipType.Rotate270FlipX);
                        break;
                    case 8:
                        sysImage.RotateFlip(System.Drawing.RotateFlipType.Rotate270FlipNone);
                        break;
                    default:
                        break;
                }

                sysImage.RemovePropertyItem(0x0112);
            }

            return sysImage;
        }

    }
}

```

<!-- code block end -->


text:
| Resource | Official documentation |
| -------- | ---------------------- |
| [Blocks](#blocks) | https://github.com/justintv/Twitch-API/blob/master/v3_resources/blocks.md |
| [Channels](#channels) | https://github.com/justintv/Twitch-API/blob/master/v3_resources/channels.md |
| [Chat](#chat) | https://github.com/justintv/Twitch-API/blob/master/v3_resources/chat.md |
| [Follows](#follows) | https://github.com/justintv/Twitch-API/blob/master/v3_resources/follows.md |
| [Games](#games) | https://github.com/justintv/Twitch-API/blob/master/v3_resources/games.md |
| [Ingests](#ingests) | https://github.com/justintv/Twitch-API/blob/master/v3_resources/ingests.md |
| [Search](#search) | https://github.com/justintv/Twitch-API/blob/master/v3_resources/search.md |
| [Streams](#streams) | https://github.com/justintv/Twitch-API/blob/master/v3_resources/streams.md |
| [Subscriptions](#subscriptions) | https://github.com/justintv/Twitch-API/blob/master/v3_resources/subscriptions.md |
| [Teams](#teams) | https://github.com/justintv/Twitch-API/blob/master/v3_resources/teams.md |
| [Users](#users) | https://github.com/justintv/Twitch-API/blob/master/v3_resources/users.md |
| [Videos](#videos) | https://github.com/justintv/Twitch-API/blob/master/v3_resources/videos.md |
### Blocks

* **getBlockedUsers($user, $params = [])** - Get user's block list
*AUTHENTICATED*
Scope:  `user_blocks_read`

* **blockUser($user, $target)** - Add target to user's block list
*AUTHENTICATED*
Scope: `user_blocks_edit`

* **unblockUser($user, $target)** - Delete target from user's block list
*AUTHENTICATED*
Scope: `user_blocks_edit`

### Channels

* **getChannel($user)** - Get channel object for $user

* **getChannel()** - Get authenticated user's channel
*AUTHENTICATED*
Scope: `channel_read`

* **getEditors($channel)** - Get a list of $channel editors
*AUTHENTICATED*
Scope: `channel_read`

* **getVideos($channel, $params = [])** - Get a list of $channel videos

* **updateChannel($channel, $params = [])** - Update $channel's status
*AUTHENTICATED*
Scope: `channel_editor`

* **resetStreamKey($channel)** - Resets $channel's stream key
*AUTHENTICATED*
Scope: `channel_stream`

* **startCommercial($channel, $length = 30)** - Starts a (30,60,90,120,150,180s) commercial
*AUTHENTICATED*
Scope: `channel_commercial`

* **getTeams($channel)** - Get a list of team objects for $channel

* **getFollows($channel, $params = [])** - Get a list of follow objects for $channel

### Chat

* **getChat($channel)** - Get a links object to all other chat enpoints

* **getEmoticons()** - Get a list of all emoticon objects for Twitch

* **getEmoticonImages($params = [])** - Get a list of emoticons

* **getBadges($channel)** - Get a list of chat badges that can be used in $channel's chat

### Follows

* **getFollowers($channel, $params = [])** - Get a list of follow objects for $channel

* **getFollows($user, $params = [])** - Get a list of follows objects for $user

* **getRelationship($user, $channel)** - Get relationship between $user and $channel

* **followChannel($user, $target, $notifications = false)** - Adds $user to $target's followers
*AUTHENTICATED*
Scope: `user_follows_edit`

* **unfollowChannel($user, $target, $notifications = false)** - Removes $user from $target's followers
*AUTHENTICATED*
Scope: `user_follows_edit`

### Games

* **getTopGames($params = [])** - Returns a list of games objects sorted by number of current viewers on Twitch, most popular first

### Ingests

* **getIngests()** - Returns a list of ingest objects

### Search

* **searchChannels($query, $params = [])** - Returns a list of channel objects matching the search query

* **searchStreams($query, $params = [])** - Returns a list of stream objects matching the search query

* **searchGames($query, $params = [])** - Returns a list of game objects matching the search query

### Streams

* **getStreams($params = [])** - Returns a list of stream objects that are queried by a number

* **getFeatured($params = [])** - Returns a list of featured (promoted) stream objects

* **getSummary($params = [])** - Returns a summary of current streams

* **getFollowed($params = [])** - Returns a list of stream objects that the authenticated user is following
*AUTHENTICATED*
Scope: `user_read`

### Subscriptions

* **getSubscriptions($channel, $params = [])** - Returns a list of subscription objects sorted by subscription relationship creation
*AUTHENTICATED*
Scope: `channel_subscriptions`

* **getSubscription($channel, $user)** - Returns a subscription object for $channel witch includes the $user
*AUTHENTICATED*
Scope: `channel_check_subscription`

* **getSubscription($user, $channel)** - Returns a $channel object that $user subscribes to
*AUTHENTICATED*
Scope: `user_subscriptions`

### Teams

* **getTeams($params = [])** - Returns a list of active teams

* **getTeam($team)** - Returns a team object for $team

### Users

* **getUser()** - Returns a user object
*AUTHENTICATED*
Scope: `user_read`

* **getUser($name)** - Returns a user object

* **getFollowed($params = [])** - Returns a list of stream objects that the authenticated user is following
*AUTHENTICATED*
Scope: `user_read`

* **getFollowedVideos($params = [])** - Returns a list of video objects from channels that the authenticated user is following
*AUTHENTICATED*
Scope: `user_read`

### Videos

* **getVideo($id)** - Returns a video object

* **getTopVideos($params = [])** - Returns a list of videos created in a given time period sorted by

* **getChannelVideos($channel, $params = [])** - Returns a list of videos ordered by time of creation

* **getFollowedVideos($params = [])** - Returns a list of video objects from channels that the authenticated user is following
*AUTHENTICATED*
Scope: `user_read`

redpajama_set_name: RedPajamaGithub


text:
<!DOCTYPE html>

    <title>grapheo12's Blog</title>

    <meta http-equiv="content-type" content="text/html; charset=utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1">
    <meta name="robots" content="noodp"/>

    <link rel="stylesheet" href="https://grapheo12.in/style.css">
    <link rel="stylesheet" href="https://grapheo12.in/color/green.css">

        <link rel="stylesheet" href="https://grapheo12.in/color/background_black.css">

    <link rel="stylesheet" href="https://grapheo12.in/font-hack.css">

                            grapheo12

about me

tech

literature

life

music

slides & lectures

resume

contact me

A Day in Lausanne

            2021-07-04

                :: tags:
                #intern
                #epfl
                #travel

It's been a tumultous ride, but yes I was re-allowed to come to EPFL for the last month of my internship.
More on that later, someday.

I reached Lausanne on 29th June.
Today, was the first "official" trip around Lausanne.
Sandra from our lab went with me.

The Start: Uphill

Lausanne is on a hill,
which means there's a lot of steep roads.
I was home for 1.5 years and with 108kg on my belly,
it was pretty tough for me!

Sandra is an avid hiker.
Keeping up with her soon left me out of breath.
But I managed somehow.

Here's a picture of the road from 2 days back:

We then stopped to have lunch at Bleu Lezard restaurant.
Had a burger with some Alu bhaja (haters call them French fries).😏

Lausanne Cathedral

A little more of walking and we reached the famous Lausanne cathedral.

The cathedral foyer gives a scenic view of a large portion of Lausanne:

The Cathedral is an historic one.
It was the place of an important political declaration for the Vaud canton in 1798.
(Sorry I don't understand French and Google Translate can only be so good).

Saw someone play the organ for the first time.
(The real organ, not some Synth samples)
I tried to capture it in a video, but I was too busy walking.

<video src="/img/Lausanne/cathedral-organ.mp4" style="max-width: 100%" controls></video>

Here are some more photos of the cathedral.

Can you see the organ pipes in the back?

Here's the Piano Man (Billy Joel pun intended)

Those organ pipes, up close

The Altar

Yay! It's me

On the way to the Cathedral. Should have put this photo at first 😅. That's Sandra in front of me.

En route to Flon

Flon is kinda the central place in Lausanne (not counting the city centre though).
We had to do some walking from the cathedral to get to there.
Good thing it was downhill for sometime 😌.

On the way, I saw a museum.
I'll go visit it someday.
We didn't have time today.

Next, I saw the Town Hall.
There's Light and Sound show there in the winters.
(Sadly, this is summer and there's light till 9pm. Aaaaagghhhh!)
We don't know why the big flag is there.
Probably due to the recent Euro cup match.

Flon

Flon is beautiful in its own right.
It's the modern area of Lausanne,
with all the posh shops and restaurants.

There are 2 metros in Lausanne, M1 and M2.
The junction is here.

Here are some photos of Flon:

Elegance... I guess

MAD is a big nightclub in this area... Reminded me of POGO channel and Rob though

Ouchy

Ouchy (pronounced: Oo-Shi) is at one extreme end of Lausanne.
It is situated right next to the Lake.
It houses the Olympic museum as well (I will go inside some other day. It will take one full day).

The Lake is quite a long one.
It hasn't left my side since Geneva.
But it's narrow one.
You can see France on the other side.

People commute from France to Switzerland and back on boats.

Here is a steamer that set sail in front of us.

<video src="/img/Lausanne/ouchy-boat.mp4" style="max-width: 100%" controls></video>

A few more random clicks:

On the way to the Jetee

Maa, see they have flower gardens here

No cars allowed here on weekends

Another view of the lake

The End

With this, today's journey ended.
We went back to Gare (that is where my hotel is) by Metro.

It's me again... inside the metro.

                Not bored enough? See other posts....

                            Sleepless rant
                            →

                        ©
    2021
 Shubham Mishra

                        ::
                        Theme: Terminimal by pawroman


text:
<?php

namespace Twilio\Exceptions;

class EnvironmentException extends TwilioException {

}


text:
<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Moderation extends Model
{
	protected $table = 'moderation';

	public function user()
    {
        return $this->belongsTo('App\User');
    }

	public function forum()
    {
        return $this->belongsTo('App\Forum');
    }
}


text:
using Xunit;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

namespace System.SpanTests
{
    public static partial class ReadOnlySpanTests
    {
        // NOTE: IndexOverflow test is constrained to run on Windows and MacOSX because it
        //       causes problems on Linux due to the way deferred memory allocation works.
        //       On Linux, the allocation can succeed even if there is not enough memory
        //       but then the test may get killed by the OOM killer at the time the memory
        //       is accessed which triggers the full memory allocation.

        [Fact]
        [OuterLoop]
        [PlatformSpecific(TestPlatforms.Windows | TestPlatforms.OSX)]
        public static void IndexOverflow()
        {
            // If this test is run in a 32-bit process, the 3GB allocation will fail.
            if (Unsafe.SizeOf<IntPtr>() == sizeof(long))
            {
                //
                // Although Span constrains indexes to 0..2Gb, it does not similarly constrain index * sizeof(T).
                // Make sure that internal offset calculcations handle the >2Gb case properly.
                //

                unsafe
                {
                    if (!AllocationHelper.TryAllocNative((IntPtr)ThreeGiB, out IntPtr memBlock))
                        return; // It's not implausible to believe that a 3gb allocation will fail - if so, skip this test to avoid unnecessary test flakiness.

                    try
                    {
                        ref Guid memory = ref Unsafe.AsRef<Guid>(memBlock.ToPointer());
                        var span = new ReadOnlySpan<Guid>(memBlock.ToPointer(), s_guidThreeGiBLimit);

                        int bigIndex = checked(s_guidTwoGiBLimit + 1);
                        uint byteOffset = checked((uint)bigIndex * (uint)sizeof(Guid));
                        Assert.True(byteOffset > int.MaxValue);  // Make sure byteOffset actually overflows 2Gb, or this test is pointless.
                        Guid expectedGuid = Guid.NewGuid();
                        ref Guid expected = ref Unsafe.Add<Guid>(ref memory, bigIndex);
                        expected = expectedGuid;
                        Guid actualGuid = span[bigIndex];
                        Assert.Equal(expectedGuid, actualGuid);

                        ReadOnlySpan<Guid> slice = span.Slice(bigIndex);
                        Assert.True(Unsafe.AreSame<Guid>(ref expected, ref Unsafe.AsRef(in MemoryMarshal.GetReference(slice))));

                        slice = span.Slice(bigIndex, 1);
                        Assert.True(Unsafe.AreSame<Guid>(ref expected, ref Unsafe.AsRef(in MemoryMarshal.GetReference(slice))));
                    }
                    finally
                    {
                        AllocationHelper.ReleaseNative(ref memBlock);
                    }
                }
            }
        }

        private const long ThreeGiB = 3L * 1024L * 1024L * 1024L;
        private const long TwoGiB = 2L * 1024L * 1024L * 1024L;
        private const long OneGiB = 1L * 1024L * 1024L * 1024L;

        private static readonly int s_guidThreeGiBLimit = (int)(ThreeGiB / Unsafe.SizeOf<Guid>());  // sizeof(Guid) requires unsafe keyword and I don't want to mark the entire class unsafe.
        private static readonly int s_guidTwoGiBLimit = (int)(TwoGiB / Unsafe.SizeOf<Guid>());
    }
}


text:
'''
Example:
'''
import os,sys
parentdir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
sys.path.insert(0,parentdir)

from pyN import *

A = IzhikevichPopulation(name='thalamus', N=5, a=0.02, b=0.2, c=-65, d=6, v0=-70, u0=None)#tonic spiking
B = IzhikevichPopulation(name='cortex', N=10, a=0.02, b=0.25, c=-55, d=0.05, v0=-70, u0=None)#phasic bursting

brain = Network(populations=[A,B])
brain.connect(pre='thalamus', post='cortex', synapses="sparse-random")
brain.connect(pre='cortex', post='thalamus', synapses="sparse-random", delay=2.25,std=0.25)#takes awhile for cortex to get back to thalamus?

stim = [{'start':10,'stop':200,'mV':20,'neurons':[0]},{'start':50,'stop':300,'mV':30,'neurons':[i for i in range(3)]}]
results = brain.simulate(experiment_name='Reentrant Thalamocortical Circuit',T=600,dt=0.25, I_ext={'thalamus':stim}, save_data='../data/', properties_to_save=['psc','I_ext','spike_raster'],stdp=True)
show_data(results)


text:
export const addItem = (
  value,
  label,
  id,
  choiceId,
  groupId,
  customProperties,
  placeholder,
  keyCode,
) => ({
  type: 'ADD_ITEM',
  value,
  label,
  id,
  choiceId,
  groupId,
  customProperties,
  placeholder,
  keyCode,
});

export const removeItem = (id, choiceId) => ({
  type: 'REMOVE_ITEM',
  id,
  choiceId,
});

export const highlightItem = (id, highlighted) => ({
  type: 'HIGHLIGHT_ITEM',
  id,
  highlighted,
});

export const addChoice = (
  value,
  label,
  id,
  groupId,
  disabled,
  elementId,
  customProperties,
  placeholder,
  keyCode,
) => ({
  type: 'ADD_CHOICE',
  value,
  label,
  id,
  groupId,
  disabled,
  elementId,
  customProperties,
  placeholder,
  keyCode,
});

export const filterChoices = results => ({
  type: 'FILTER_CHOICES',
  results,
});

export const activateChoices = (active = true) => ({
  type: 'ACTIVATE_CHOICES',
  active,
});

export const clearChoices = () => ({
  type: 'CLEAR_CHOICES',
});

export const addGroup = (value, id, active, disabled) => ({
  type: 'ADD_GROUP',
  value,
  id,
  active,
  disabled,
});

export const clearAll = () => ({
  type: 'CLEAR_ALL',
});


text:
[![PyPI version](https://badge.fury.io/py/grlc.svg)](https://badge.fury.io/py/grlc)
[![DOI](https://zenodo.org/badge/46131212.svg)](https://zenodo.org/badge/latestdoi/46131212)
[![Build Status](https://travis-ci.org/CLARIAH/grlc.svg?branch=master)](https://travis-ci.org/CLARIAH/grlc)

grlc, the git repository linked data API constructor, automatically builds Web APIs using shared SPARQL queries. http://grlc.io/

If you use grlc in your work, please cite it as:

```
@InProceedings{merono2016grlc,
 author = {Mero{\~{n}}o-Pe{\~{n}}uela, Albert and Hoekstra, Rinke},
 title = {{grlc Makes GitHub Taste Like Linked Data APIs}},
 booktitle = {The Semantic Web: ESWC 2016 Satellite Events, Heraklion, Crete, Greece, May 29 -- June 2,  2016},
 year = {2016},
 publisher = {Springer},
 pages = {342--353},
 isbn = {978-3-319-47602-5},
 doi = {10.1007/978-3-319-47602-5_48}
}
```

## What is grlc?
grlc is a lightweight server that takes SPARQL queries (stored in a GitHub repository, in your local filesystem, or listed in a URL), and translates them to Linked Data Web APIs. This enables universal access to Linked Data. Users are not required to know SPARQL to query their data, but instead can access a web API.

## Quick tutorial
For a quick usage tutorial check out our wiki [walkthrough](https://github.com/CLARIAH/grlc/wiki/Quick-tutorial) and [list of features](https://github.com/CLARIAH/grlc/wiki/Features).

## Usage
grlc assumes that you have a collection of SPARQL queries as .rq files (like [this](https://github.com/CLARIAH/grlc-queries)). grlc will create one API operation for each SPARQL query/.rq file in the collection.

Your queries can add API parameters to each operation by using the [parameter mapping](https://github.com/CLARIAH/grlc/wiki/Parameter-Mapping) syntax. This allows your query to define query variables which will be mapped to API parameters for your API operation ([see here](https://github.com/CLARIAH/grlc-queries/blob/master/enumerate.rq) for an example).

Your queries can include special [decorators](#decorator-syntax) to add extra functionality to your API.

### Query location
grlc can load your query collection from different locations: from a GitHub repository (`api-git`), from local storage (`api-local`), and from a specification file (`api-url`). Each type of location has specific features and is accessible via different paths. However all location types produce the same beautiful APIs.

#### From a GitHub repository
> API path:
`http://grlc-server/api-git/<user>/<repo>`

grlc can build an API from any Github repository, specified by the GitHub user name of the owner (`<user>`) and repository name (`<repo>`).

For example, assuming your queries are stored on a Github repo: `https://github.com/CLARIAH/grlc-queries/`, point your browser to the following location
`http://grlc.io/api-git/CLARIAH/grlc-queries/`

grlc can make use of git's version control mechanism to generate an API based on a specific version of queries in the repository. This can be done by including the commit sha in the URL path (`http://grlc-server/api-git/<user>/<repo>/commit/<sha>`), for example: `http://grlc.io/api-git/CLARIAH/grlc-queries/commit/79ceef2ee814a12e2ec572ffaa2f8212a22bae23`

grlc can also use a subdirectory inside your Github repo. This can be done by including a subdirectory in the URL path (`http://grlc-server/api-git/<user>/<repo>/subdir/<subdir>`).

#### From local storage
> API path:
`http://grlc-server/api-local/`

grlc can generate an API from a local directory in the computer where your grlc server runs. You can configure the location of this directory in your [grlc server configuration file](#grlc-server-configuration). See also [how to install and run your own grlc instance](#install-and-run).

When the API is generated from a local directory, API information can be loaded from a configuration file in that folder. This file must be called `local-api-config.ini` and it has the following format:
```ini
[repo_info]
repo_title = Some title
api_description = Description of my API
contact_name = My name
contact_url = https://mypage/
licence_url = https://mylicence/
```

#### From a specification file
> API path:
`http://grlc-server/api-url/?specUrl=<specUrl>`

grlc can generate an API from a yaml specification file accessible on the web.

For example, assuming your queries are listed on spec file: `https://raw.githubusercontent.com/CLARIAH/grlc-queries/master/urls.yml`, point your browser to the following location
`http://grlc.io/api-url?specUrl=https://raw.githubusercontent.com/CLARIAH/grlc-queries/master/urls.yml`

##### Specification file syntax
A grlc API specification file is a YAML file which includes the necessary information to create a grlc API, most importantly a list of URLs to decorated and HTTP-dereferenceable SPARQL queries. This file should contain the following fields

 - `title`: Title of my API
 - `description`: API description
 - `contact`: Contact details of the API owner. This should include the `name` and `url` properties.
 - `licence`: A URL pointing to the licence file for the API.
 - `queries`: A list of URLs of SPARQL queries (with header decorators).

For example:
```YAML
title: Title of my API
description: Description of my API
contact:
  name: Contact Name
  url: https://www.mywebsite.org
licence: http://example.org/licence.html
queries:
  - https://www.mywebsite.org/query1.rq
  - https://www.mywebsite.org/query2.rq
  - https://www.otherwebsite.org/query3.rq
```

### grlc generated API

The API paths of all location types point to the generated [swagger-ui](https://swagger.io/) style API documentation. On the API documentation page, you can explore available API calls and execute individual API calls.

You can also view the swagger spec of your API, by visiting `<API-path>/swagger`, for example: `http://grlc.io/api-git/CLARIAH/grlc-queries/swagger`

### grlc query execution
When you call an API endpoint, grlc executes the SPARQL query for that endpoint by combining supplied parameters and decorators.

There are 4 options to specify your own endpoint:

* Add a `sparql_endpoint` on your [`config.ini`](#grlc-server-configuration)
* Add a `endpoint` parameter to your request: 'http://grlc.io/user/repo/query?endpoint=http://sparql-endpoint/'. You can add a `#+ endpoint_in_url: False` decorator if you DO NOT want to see the `endpoint` parameter in the swagger-ui of your API.
* Add the `#+ endpoint:` [decorator](#`endpoint`).
* Add the URL of the endpoint on a single line in an `endpoint.txt` file within the GitHub repository that contains the queries.

The endpoint call will return the result of executing the query as a json representation of rdflib.query.QueryResult (for other result formats, you can use content negotiation via HTTP `Accept` headers). For json responses, the schema of the response can be modified by using the `#+ transform:` [decorator](#`transform`).

## Decorator syntax
Special decorators are available to make your swagger-ui look nicer and to increase functionality. These are provided as comments at the start of your query file, making it still syntactically valid SPARQL. All decorators start with `#+ `, for example:

```SPARQL
#+ decorator_1: decorator value
#+ decorator_1: decorator value

SELECT * WHERE {
  ?s ?p ?o .
}
```
The following is a list of available decorators and their function:

### `summary`
Creates a summary of your query/operation. This is shown next to your operation name in the swagger-ui.

Syntax:
```
#+ summary: This is the summary of my query/operation
```

Example [query](https://github.com/CLARIAH/grlc-queries/blob/master/summary.rq) and the equivalent [API operation](http://grlc.io/api-git/CLARIAH/grlc-queries/#/default/get_summary).

### `description`
Creates a description of your query/operation. This is shown as the description of your operation in the swagger-ui.

Syntax:
```
#+ description: Extended description of my query/operation.
```

Example [query](https://github.com/CLARIAH/grlc-queries/blob/master/description.rq) and the equivalent [API operation](http://grlc.io/api-git/CLARIAH/grlc-queries/#/default/get_description).

### `endpoint`
Specifies a query-specific endpoint.

Syntax:
```
#+ endpoint: http://example.com/sparql
```

Example [query](https://github.com/CLARIAH/grlc-queries/blob/master/endpoint.rq) and the equivalent [API operation](http://grlc.io/api-git/CLARIAH/grlc-queries/#/default/get_endpoint).

### `pagination`
Paginates the results in groups of (for example) 100. Links to previous, next, first, and last result pages are provided as HTTP response headers to avoid polluting the payload (see details [here](https://developer.github.com/v3/guides/traversing-with-pagination/))

Syntax:
```
#+ pagination: 100
```

Example [query](https://github.com/CLARIAH/grlc-queries/blob/master/pagination.rq) and the equivalent [API operation](http://grlc.io/api-git/CLARIAH/grlc-queries/#/default/get_pagination).

### `method`
Indicates the HTTP request method (`GET` and `POST` are supported).

Syntax:
```
#+ method: GET
```

Example [query](https://github.com/CLARIAH/grlc-queries/blob/master/method.rq) and the equivalent [API operation](http://grlc.io/api-git/CLARIAH/grlc-queries/#/default/post_method).

### `tags`
Assign tags to your query/operation. Query/operations with the same tag are grouped together in the swagger-ui.

Syntax:
```
#+ tags:
#+   - firstTag
#+   - secondTag
```

Example [query](https://github.com/CLARIAH/grlc-queries/blob/master/tags.rq) and the equivalent [API operation](http://grlc.io/api-git/CLARIAH/grlc-queries/#/group1/get_tags).

### `defaults`
Set the default value in the swagger-ui for a specific parameter in the query.

Syntax:
```
#+ defaults:
#+   - param_name: default_value
```

Example [query](https://github.com/CLARIAH/grlc-queries/blob/master/defaults.rq) and the equivalent [API operation](http://grlc.io/api-git/CLARIAH/grlc-queries/#/default/get_defaults).

### `enumerate`
Indicates which parameters of your query/operation should get enumerations (and get dropdown menus in the swagger-ui) using the given values from the SPARQL endpoint. The values for each enumeration variable can also be specified into the query decorators to save endpoint requests and speed up the API generation.

Syntax:
```
#+ enumerate:
#+   - var1:
#+     - value1
#+     - value2
```

Example [query](https://github.com/CLARIAH/grlc-queries/blob/master/enumerate.rq) and the equivalent [API operation](http://grlc.io/api-git/CLARIAH/grlc-queries/#/default/get_enumerate).

Notice that these should be plain variable names without SPARQL/BASIL conventions (so `var1` instead of `?_var1_iri`)

###  `endpoint_in_url`
Allows/disallows the `endpoint` parameter from being provided as a URL parameter (allowed by default).

Syntax:
```
#+ endpoint_in_url: False
```

Example [query](https://github.com/CLARIAH/grlc-queries/blob/master/endpoint_url.rq) and the equivalent [API operation](http://grlc.io/api-git/CLARIAH/grlc-queries/#/default/get_endpoint_url).

###  `transform`
Allows  query results to be converted to the specified JSON structure, by using [SPARQLTransformer](https://github.com/D2KLab/py-sparql-transformer) syntax. Notice that the response content type must be set to `application/json` for the transformation to take effect.

Syntax:
```
#+ transform: {
#+     "key": "?p",
#+     "value": "?o",
#+     "$anchor": "key"
#+   }
```

Example [query](https://github.com/CLARIAH/grlc-queries/blob/master/transform.rq) and the equivalent [API operation](http://grlc.io/api-git/CLARIAH/grlc-queries/#/default/get_transform).

### Example APIs

Check these out:
- http://grlc.io/api-git/CLARIAH/grlc-queries
- http://grlc.io/api-url?specUrl=https://raw.githubusercontent.com/CLARIAH/grlc-queries/master/urls.yml
- http://grlc.io/api-git/CLARIAH/wp4-queries-hisco
- http://grlc.io/api-git/albertmeronyo/lodapi
- http://grlc.io/api-git/albertmeronyo/lsq-api
- https://grlc.io/api-git/CEDAR-project/Queries

You'll find the sources of these and many more in [GitHub](https://github.com/search?o=desc&q=endpoint+summary+language%3ASPARQL&s=indexed&type=Code&utf8=%E2%9C%93)

Use [this GitHub search](https://github.com/search?q=endpoint+summary+language%3ASPARQL&type=Code&utf8=%E2%9C%93) to see examples from other grlc users.

## Install and run
You can use grlc in different ways:
 - [Via grlc.io](#grlc.io): you can use the [grlc.io service](https://grlc.io/)
 - [Via Docker](#Docker): you can use the [grlc docker image](https://hub.docker.com/r/clariah/grlc) and start your own grlc server.
 - [Via pip](#Pip): you can install the [grlc Python package](https://pypi.org/project/grlc/) and start your own grlc server or use grlc as a Python library.

More details for each of these options are given below.

### grlc.io
The easiest way to use grlc is by visiting [grlc.io](http://grlc.io/) and using this service to convert SPARQL queries into a RESTful API. Your queries can be [stored on a github repo](#from-a-github-repository) or can be [listed on a specification file](#from-a-specification-file).

### Docker
To run grlc via [docker](https://www.docker.com/), you'll need a working installation of docker. To deploy grlc, just pull the [latest image from Docker hub](https://hub.docker.com/r/clariah/grlc/). :
```bash
docker run -it --rm -p 8088:80 clariah/grlc
```

The docker image allows you to setup several environment variable such as `GRLC_SERVER_NAME` `GRLC_GITHUB_ACCESS_TOKEN` and `GRLC_SPARQL_ENDPOINT`:
```bash
docker run -it --rm -p 8088:80 -e GRLC_SERVER_NAME=grlc.io -e GRLC_GITHUB_ACCESS_TOKEN=xxx -e GRLC_SPARQL_ENDPOINT=http://dbpedia.org/sparql -e DEBUG=true clariah/grlc
```

### Pip
If you want to run grlc locally or use it as a library, you can install grlc on your machine. Grlc is [registered in PyPi](https://pypi.org/project/grlc/) so you can install it using pip.

#### Prerequisites
grlc has the following requirements:
- Python3
- development files (depending on your OS):
```bash
sudo apt-get install libevent-dev python-all-dev
```

#### pip install
Once the base requirements are satisfied, you can install grlc like this:
```bash
pip install grlc
```

Once grlc is installed, you have several options:
 - [Stand alone server](#Standalone-server)
 - [Using a WSGI server](#Using-a-WSGI-server)
 - [As a python library](#Grlc-library)

#### Standalone server
grlc includes a command line tool which you can use to start your own grlc server:
```bash
grlc-server
```

#### Using a WSGI server
You can run grlc using a WSGI server such as gunicorn as follows:
```bash
gunicorn grlc.server:app
```

If you want to use your own gunicorn configuration, for example `gunicorn_config.py`:
```python
workers = 5
worker_class = 'gevent'
bind = '0.0.0.0:8088'
```
Then you can run it as:
```bash
gunicorn -c gunicorn_config.py grlc.server:app
```

**Note:** Since `gunicorn` does not work under Windows, you can use `waitress` instead:
```bash
waitress-serve --port=8088 grlc.server:app
```

If you want to run grlc at system boot as a service, you can find example upstart scripts at [upstart/](upstart/grlc-docker.conf)

#### grlc library
You can use grlc as a library directly from your own python script. See the [usage example](https://github.com/CLARIAH/grlc/blob/master/doc/notebooks/GrlcFromNotebook.ipynb) to find out more.

#### grlc server configuration
Regardless of how you are running your grlc server, you will need to configure it using the `config.ini` file. Have a look at the [example config file](./config.default.ini) to see how it this file is structured.

The configuration file contains the following variables:
 - `github_access_token` [access token](#github-access-token) to communicate with Github API.
 - `local_sparql_dir` local storage directory where [local queries](#from-local-storage) are located.
 - `server_name` name of the server (e.g. grlc.io)
 - `sparql_endpoint` default SPARQL endpoint
 - `user` and `password` SPARQL endpoint default authentication (if required, specify `'none'` if not required)
 - `debug` enable debug level logging.

##### GitHub access token
In order for grlc to communicate with GitHub, you'll need to tell grlc what your access token is:

1. Get a GitHub personal access token. In your GitHub's profile page, go to _Settings_, then _Developer settings_, _Personal access tokens_, and _Generate new token_
2. You'll get an access token string, copy it and save it somewhere safe (GitHub won't let you see it again!)
3. Edit your `config.ini` or `docker-compose.yml` as value of the environment variable `GRLC_GITHUB_ACCESS_TOKEN`.

# Contribute!
grlc needs **you** to continue bringing Semantic Web content to developers, applications and users. No matter if you are just a curious user, a developer, or a researcher; there are many ways in which you can contribute:

- File in bug reports
- Request new features
- Set up your own environment and start hacking

Check our [contributing](CONTRIBUTING.md) guidelines for these and more, and join us today!

If you cannot code, that's no problem! There's still plenty you can contribute:

- Share your experience at using grlc in Twitter (mention the handle **@grlcldapi**)
- If you are good with HTML/CSS, [let us know](mailto:albert.meronyo@gmail.com)

## Related tools
- [SPARQL2Git](https://github.com/albertmeronyo/SPARQL2Git) is a Web interface for editing SPARQL queries and saving them in GitHub as grlc APIs.
- [grlcR](https://github.com/CLARIAH/grlcR) is a package for R that brings Linked Data into your R environment easily through grlc.
- [Hay's tools](https://tools.wmflabs.org/hay/directory/#/showall) lists grlc as a Wikimedia-related tool :-)

## This is what grlc users are saying
- [Flavour your Linked Data with grlc](https://blog.esciencecenter.nl/flavour-your-linked-data-with-garlic-98bfbb358e06), by Carlos Martinez
- [Converting any SPARQL endpoint to an OpenAPI](http://chem-bla-ics.blogspot.com/2018/07/converting-any-sparql-endpoint-to.html) by Egon Willighagen

Quotes from grlc users:
> A cool project that can convert a random SPARQL endpoint into an OpenAPI endpoint

> It enables us to quickly integrate any new API requirements in a matter of seconds, without having to worry about configuration or deployment of the system

> You can store your SPARQL queries on GitHub and then you can run your queries on your favourite programming language (Python, Javascript, etc.) using a Web API (including swagger documentation) just as easily as loading data from a web page

**Contributors:**	[Albert Meroño](https://github.com/albertmeronyo), [Rinke Hoekstra](https://github.com/RinkeHoekstra), [Carlos Martínez](https://github.com/c-martinez)

**Copyright:**	Albert Meroño, Rinke Hoekstra, Carlos Martínez
**License:**	MIT License (see [LICENSE.txt](LICENSE.txt))

## Academic publications

- Albert Meroño-Peñuela, Rinke Hoekstra. "grlc Makes GitHub Taste Like Linked Data APIs". The Semantic Web – ESWC 2016 Satellite Events, Heraklion, Crete, Greece, May 29 – June 2, 2016, Revised Selected Papers. LNCS 9989, pp. 342-353 (2016). ([PDF](https://link.springer.com/content/pdf/10.1007%2F978-3-319-47602-5_48.pdf))
- Albert Meroño-Peñuela, Rinke Hoekstra. "SPARQL2Git: Transparent SPARQL and Linked Data API Curation via Git". In: Proceedings of the 14th Extended Semantic Web Conference (ESWC 2017), Poster and Demo Track. Portoroz, Slovenia, May 28th – June 1st, 2017 (2017). ([PDF](https://www.albertmeronyo.org/wp-content/uploads/2017/04/sparql2git-transparent-sparql-4.pdf))
- Albert Meroño-Peñuela, Rinke Hoekstra. "Automatic Query-centric API for Routine Access to Linked Data". In: The Semantic Web – ISWC 2017, 16th International Semantic Web Conference. Lecture Notes in Computer Science, vol 10587, pp. 334-339 (2017). ([PDF](https://www.albertmeronyo.org/wp-content/uploads/2017/07/ISWC2017_paper_430.pdf))
- Pasquale Lisena, Albert Meroño-Peñuela, Tobias Kuhn, Raphaël Troncy. "Easy Web API Development with SPARQL Transformer". In: The Semantic Web – ISWC 2019, 18th International Semantic Web Conference. Lecture Notes in Computer Science, vol 11779, pp. 454-470 (2019). ([PDF](https://www.albertmeronyo.org/wp-content/uploads/2019/06/ISWC2019_paper_237.pdf))


text:
<?php namespace redhotmayo\dataaccess;

class DataAccessStorage {
    const MYSQL = 'mysql';
}


text:
<?php

use yii\db\Migration;
use yii\db\Expression;
use app\models\Special;
use app\models\Subweapon;
use app\models\Weapon;
use app\models\WeaponType;
use app\models\DeathReasonType;

class m160304_132438_weapon extends Migration
{
    public function safeUp()
    {
        $this->batchInsert(
            'weapon',
            [ 'id', 'type_id', 'key', 'name', 'subweapon_id', 'special_id', 'canonical_id', 'main_group_id' ],
            [
                [
                    new Expression("nextval('weapon_id_seq'::regclass)"),
                    WeaponType::findOne(['key' => 'shooter'])->id,
                    'sshooter_wasabi',
                    'Wasabi Splattershot',
                    Subweapon::findOne(['key' => 'splashbomb'])->id,
                    Special::findOne(['key' => 'tornado'])->id,
                    new Expression("currval('weapon_id_seq'::regclass)"),
                    Weapon::findOne(['key' => 'sshooter'])->id,
                ],
                [
                    new Expression("nextval('weapon_id_seq'::regclass)"),
                    WeaponType::findOne(['key' => 'shooter'])->id,
                    'prime_berry',
                    'Berry Splattershot Pro',
                    Subweapon::findOne(['key' => 'kyubanbomb'])->id,
                    Special::findOne(['key' => 'bombrush'])->id,
                    new Expression("currval('weapon_id_seq'::regclass)"),
                    Weapon::findOne(['key' => 'prime'])->id,
                ],
                [
                    new Expression("nextval('weapon_id_seq'::regclass)"),
                    WeaponType::findOne(['key' => 'charger'])->id,
                    'squiclean_g',
                    'Fresh Squiffer',
                    Subweapon::findOne(['key' => 'kyubanbomb'])->id,
                    Special::findOne(['key' => 'daioika'])->id,
                    new Expression("currval('weapon_id_seq'::regclass)"),
                    Weapon::findOne(['key' => 'squiclean_a'])->id,
                ],
            ]
        );

        $type = DeathReasonType::findOne(['key' => 'main'])->id;
        $this->batchInsert(
            'death_reason',
            [ 'type_id', 'key', 'name', 'weapon_id' ],
            [
                [ $type, 'sshooter_wasabi', 'Wasabi Splattershot', Weapon::findOne(['key' => 'sshooter_wasabi'])->id ],
                [ $type, 'prime_berry', 'Berry Splattershot Pro',Weapon::findOne(['key' => 'prime_berry'])->id ],
                [ $type, 'squiclean_g', 'Fresh Squiffer', Weapon::findOne(['key' => 'squiclean_g'])->id ],
            ]
        );
    }

    public function safeDown()
    {
        $this->delete('death_reason', ['key' => [ 'sshooter_wasabi', 'prime_berry', 'squiclean_g']]);
        $this->delete('weapon', ['key' => [ 'sshooter_wasabi', 'prime_berry', 'squiclean_g']]);
    }
}


text:
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.inferno.projectx.materials.AddMaterial">

    <android.support.design.widget.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/AppTheme.AppBarOverlay">

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="?attr/colorPrimary"
            app:popupTheme="@style/AppTheme.PopupOverlay" />

    </android.support.design.widget.AppBarLayout>

    <ImageView
        android:id="@+id/image"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:minWidth="100dp"
        android:minHeight="100dp"
        app:layout_anchor="@+id/contentPanel"
        app:layout_anchorGravity="center_horizontal"
        android:background="@mipmap/ic_launcher"
        android:elevation="@dimen/card_elevation_8dp"/>

    <RelativeLayout
        android:id="@+id/contentPanel"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_marginTop="60dp"
        app:layout_behavior="@string/appbar_scrolling_view_behavior">

        <include layout="@layout/content_add_material" />

    </RelativeLayout>

</android.support.design.widget.CoordinatorLayout>


text:
package org.mrgeo.data.accumulo.utils;

import org.apache.accumulo.core.client.Connector;
import org.apache.accumulo.core.client.Instance;
import org.apache.accumulo.core.client.ZooKeeperInstance;
import org.apache.accumulo.core.client.mock.MockInstance;
import org.apache.accumulo.core.client.security.tokens.PasswordToken;
import org.apache.commons.codec.binary.Base64;
import org.mrgeo.core.MrGeoConstants;
import org.mrgeo.data.DataProviderException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.Properties;

public class AccumuloConnector {

	private static Logger log = LoggerFactory
			.getLogger(AccumuloConnector.class);

	private static Connector conn = null;

	public static String encodeAccumuloProperties(String r) {
		StringBuffer sb = new StringBuffer();
		// sb.append(MrGeoAccumuloConstants.MRGEO_ACC_ENCODED_PREFIX);
		Properties props = getAccumuloProperties();
		props.setProperty(MrGeoAccumuloConstants.MRGEO_ACC_KEY_RESOURCE, r);
		Enumeration<?> e = props.keys();
		while (e.hasMoreElements()) {
			String k = (String) e.nextElement();
			String v = props.getProperty(k);
			if (sb.length() > 0) {
				sb.append(MrGeoAccumuloConstants.MRGEO_ACC_ENCODED_DELIM);
			}
			sb.append(k + "=" + v);
		}
		byte[] enc = Base64.encodeBase64(sb.toString().getBytes());
		String retStr = new String(enc);
		retStr = MrGeoAccumuloConstants.MRGEO_ACC_ENCODED_PREFIX + retStr;

		return retStr;
	} // end encodeAccumuloProperties

	public static Properties decodeAccumuloProperties(String s) {
		Properties retProps = new Properties();

		if (!s.startsWith(MrGeoAccumuloConstants.MRGEO_ACC_ENCODED_PREFIX)) {
			return retProps;
		}
		String enc = s.replaceFirst(
				MrGeoAccumuloConstants.MRGEO_ACC_ENCODED_PREFIX, "");
		byte[] decBytes = Base64.decodeBase64(enc.getBytes());
		String dec = new String(decBytes);
		String[] pairs = dec
				.split(MrGeoAccumuloConstants.MRGEO_ACC_ENCODED_DELIM);
		for (String p : pairs) {
			String[] els = p.split("=");
			if (els.length == 1) {
				retProps.setProperty(els[0], "");
			} else {
				retProps.setProperty(els[0], els[1]);
			}
		}

		return retProps;
	} // end decodeAccumuloProperties

	public static boolean isEncoded(String s) {
		return s.startsWith(MrGeoAccumuloConstants.MRGEO_ACC_ENCODED_PREFIX);
	}

	// TODO: need to make sure the path is correctly set - think about MRGEO
	// environment variables
	public static String getAccumuloPropertiesLocation() {
		String conf = System.getenv(MrGeoConstants.MRGEO_ENV_HOME);
		if (conf == null) {
			conf = "/opt/mrgeo";
		}
		if (conf != null) {
			if (!conf.endsWith(File.separator)) {
				conf += File.separator;
			}
		} else {
			conf = "";
		}
		conf += "conf" + File.separator
				+ MrGeoAccumuloConstants.MRGEO_ACC_CONF_FILE_NAME;
		log.info("looking for conf at: " + conf);
		File f = new File(conf);
		if (!f.exists()) {
			return null;
		}
		return conf;
	}

	public static Properties getAccumuloProperties() {

		if (checkMock()) {
			Properties p = new Properties();
			p.setProperty(MrGeoAccumuloConstants.MRGEO_ACC_KEY_INSTANCE, System
					.getProperty(MrGeoAccumuloConstants.MRGEO_ACC_KEY_INSTANCE));
			p.setProperty(MrGeoAccumuloConstants.MRGEO_ACC_KEY_USER, System
					.getProperty(MrGeoAccumuloConstants.MRGEO_ACC_KEY_USER));
			p.setProperty(MrGeoAccumuloConstants.MRGEO_ACC_KEY_PASSWORD, System
					.getProperty(MrGeoAccumuloConstants.MRGEO_ACC_KEY_PASSWORD));
			p.setProperty(MrGeoAccumuloConstants.MRGEO_ACC_KEY_AUTHS,
					MrGeoAccumuloConstants.MRGEO_ACC_AUTHS_U);
			return p;
		}

		// find the config file
		String conf = getAccumuloPropertiesLocation();
		if (conf != null) {
			File f = new File(conf);
			if (!f.exists()) {
				return null;
			}
			log.debug("using " + f.getAbsolutePath());

			Properties p = new Properties();
			try {
				p.load(new FileInputStream(f));
				return p;
			} catch (FileNotFoundException fnfe) {
				return null;
			} catch (Exception e) {
				return null;
			}
		}
		return null;
	} // end getAccumuloProperties

	public static Connector getConnector() throws DataProviderException {

		if (checkMock()) {
			return getMockConnector();
		}

		// find the config file
		String conf = getAccumuloPropertiesLocation();
		if (conf != null) {
			File f = new File(conf);
			if (f.exists()) {

				log.debug("connector from information in "
						+ f.getAbsolutePath());

				return getConnector(f);
			}
		}

		// if you are here - now look for the file in the CLASSPATH
		try {
			InputStream is = AccumuloConnector.class
					.getResourceAsStream(MrGeoAccumuloConstants.MRGEO_ACC_CONF_FILE_NAME);
			Properties p = new Properties();
			p.load(is);
			is.close();

			log.debug("connector information found in classpath file.");

			return getConnector(p);

		} catch (Exception e) {
			log.debug("failure to load file from classpath file");
			e.printStackTrace();
			throw new DataProviderException(
					"failure to load file from classpath file - "
							+ e.getMessage());

		}

		// return null;
	} // end getConnector

	public static Connector getConnector(File f) throws DataProviderException {
		Properties p = new Properties();
		try {
			p.load(new FileInputStream(f));
		} catch (FileNotFoundException fnfe) {
			throw new DataProviderException(fnfe.getLocalizedMessage());
		} catch (Exception e) {
			throw new DataProviderException(
					"problem loading connector for file " + f.getAbsolutePath()
							+ " - " + e.getMessage());
		}

		return getConnector(p);
	} // end getConnector - File

	public static Connector getConnector(Properties p)
			throws DataProviderException {
		String pw = p
				.getProperty(MrGeoAccumuloConstants.MRGEO_ACC_KEY_PASSWORD);
		String pwenc = p
				.getProperty(MrGeoAccumuloConstants.MRGEO_ACC_KEY_PWENCODED64);
		if (pwenc != null) {
			if (pwenc.toLowerCase().equals("true")) {
				pw = new String(Base64.decodeBase64(pw.getBytes()));
			}
		}

		return getConnector(
				p.getProperty(MrGeoAccumuloConstants.MRGEO_ACC_KEY_INSTANCE),
				p.getProperty(MrGeoAccumuloConstants.MRGEO_ACC_KEY_ZOOKEEPERS),
				p.getProperty(MrGeoAccumuloConstants.MRGEO_ACC_KEY_USER), pw);

	} // end getConnector - File

	public static Connector getConnector(String instance, String zookeepers,
			String user, String pass) throws DataProviderException {

		if (conn != null) {
			return conn;
		}
		if (checkMock()) {
			return getMockConnector(instance, user, pass);
		}

		Instance inst = new ZooKeeperInstance(instance, zookeepers);
		try {
			conn = inst.getConnector(user, new PasswordToken(pass.getBytes()));
			return conn;
		} catch (Exception e) {
			e.printStackTrace();
			throw new DataProviderException("problem creating connector "
					+ e.getMessage());
		}
	} // end getConnector

	public static boolean checkMock() {
		if (System.getProperty("mock") != null) {
			return true;
		}

		return false;
	} // end checkMock

	public static Connector getMockConnector() throws DataProviderException {

		return getMockConnector(
				System.getProperty(MrGeoAccumuloConstants.MRGEO_ACC_KEY_INSTANCE),
				System.getProperty(MrGeoAccumuloConstants.MRGEO_ACC_KEY_USER),
				System.getProperty(MrGeoAccumuloConstants.MRGEO_ACC_KEY_PASSWORD));

	} // end getMockConnector

	/**
	 * For testing.
	 *
	 * @param instance
	 * @param user
	 * @param pass
	 * @return
	 */
	public static Connector getMockConnector(String instance, String user,
			String pass) throws DataProviderException {
		Instance mock = new MockInstance(instance);
		Connector conn = null;
		try {
			conn = mock.getConnector(user, pass.getBytes());
		} catch (Exception e) {
			throw new DataProviderException(
					"problem creating mock connector - " + e.getMessage());
		}

		return conn;
	} // end getMockConnector

	public static String getReadAuthorizations(String curAuths) {

		// if the incoming string is valid - use that
		if (curAuths != null) {
			return curAuths;
		}

		String retStr = MrGeoAccumuloConstants.MRGEO_ACC_NOAUTHS;
		// get the properties of the system
		Properties props = AccumuloConnector.getAccumuloProperties();

		// look for items in the properties
		if (props != null
				&& props.containsKey(MrGeoAccumuloConstants.MRGEO_ACC_KEY_DEFAULT_READ_AUTHS)) {
			String a = props
					.getProperty(MrGeoAccumuloConstants.MRGEO_ACC_KEY_DEFAULT_READ_AUTHS);

			// check if the default read is "null"
			if (!a.equals("null")) {
				// ah - valid defaults
				retStr = a;
			}
		}

		return retStr;

	} // end getReadAuthorizations

	public static boolean deleteTable(String table){
		ArrayList<String> ignore = AccumuloUtils.getIgnoreTables();
		try{
			Connector conn = AccumuloConnector.getConnector();
			conn.tableOperations().delete(table);
			return true;
		} catch(Exception e){
			e.printStackTrace();
		}
		return false;
	} // end deleteTable

	public static void main(String args[]) throws Exception {
		// String myEnc = AccumuloConnector.encodeAccumuloProperties("rrr");
		// System.out.println("Encoded: " + myEnc);
		// Properties props = AccumuloConnector.decodeAccumuloProperties(myEnc);
		// Enumeration<?> e = props.keys();
		// while(e.hasMoreElements()){
		// String k = (String)e.nextElement();
		// String v = props.getProperty(k);
		// System.out.println("\t" + k + "\t= " + v);
		// }

		// Connector c = AccumuloConnector.getMockConnector("accumulo", "root",
		// "");
		// Connector c2 = AccumuloConnector.getMockConnector("accumulo", "root",
		// "");
		// c.tableOperations().create("junk");
		// SortedSet<String> list = c.tableOperations().list();
		// for(String l : list){
		// System.out.println(l);
		// }
		// SortedSet<String> list2 = c2.tableOperations().list();
		// for(String l2 : list2){
		// System.out.println(l2);
		// }

	} // end main

} // end AccumuloConnector


text:
#include "MainTestHarness.h"

#include "PacketQueue.h"
#include "Utilities/StandardMutex.h"
#include "Utilities/StandardAutoResetEvent.h"
#include "PacketGenerators/FloatNumberSequenceGenerator.h"
#include "PacketProcessors/SimpleOutputPacketProcessor.h"
#include <thread>
#include <windows.h>

/*
	MainTestHarness starts package producer and consumer threads. Both threads use
	the same PacketQueue object for communication. Threads will execute forever.
*/

const size_t MAXIMAL_INPUT_PACKET_SIZE = 10; // Maximum 100 floats can be created in input packet
const size_t FIXED_PACKET_SIZE = 20; // Each output packet will contain 10 floats

/*
	Each producer's cycle uses FloatNumberSequenceGenerator to generate package of random size and pushes
	generated packet to the queue.
*/
void producerWorker(PacketQueue* packetQueuePointer) {
	PacketQueue& packetQueue = *packetQueuePointer;

	IAmPacketGenerator& packetGenerator = FloatNumberSequenceGenerator(MAXIMAL_INPUT_PACKET_SIZE);
	for (;;) {
		const Packet& packet = packetGenerator.GenerateRandomLength();
		packetQueue.Push(packet);

		Sleep(1000);
	}
}

/*
	Each consumer's cycle extracts the packet of specified size from the queue (or waits f there is no
	enough data) and processes the extracted packet using SimpleOutputPacketProcessor.
*/
void consumerWorker(PacketQueue* packetQueuePointer) {
	PacketQueue& packetQueue = *packetQueuePointer;

	IAmPacketProcessor& packetProcessor = SimpleOutputPacketProcessor();
	for (;;) {
		Packet packet = packetQueue.WaitForPacketOfSize(FIXED_PACKET_SIZE);
		packetProcessor.Process(packet);
	}
}

int MainTestHarness::Run(int argc, char* argv[]) {
	PacketQueue& packetQueue = PacketQueue(StandardMutex(), StandardAutoResetEvent());

	std::thread producer(producerWorker, &packetQueue);
	std::thread consumer(consumerWorker, &packetQueue);

	producer.join();
	consumer.join();

	return 0;
}


text:
package ee.tartu.jpg.stuudium.utils;

import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;

import org.json.JSONException;
import org.json.JSONObject;

import ee.tartu.jpg.stuudium.data.Assignment;
import ee.tartu.jpg.stuudium.data.DataMap;
import ee.tartu.jpg.stuudium.data.DataSet;
import ee.tartu.jpg.stuudium.data.Event;
import ee.tartu.jpg.stuudium.data.Journal;
import ee.tartu.jpg.stuudium.data.LoginData;
import ee.tartu.jpg.stuudium.data.Person;
import ee.tartu.jpg.stuudium.data.User;

/**
 * Provides helper methods to put and receive Stuudium data from local database.
 */
public class StuudiumDatabaseHelper extends SQLiteOpenHelper {

    private static final String TAG = "StuudiumDatabaseHelper";

    private static final int DATABASE_VERSION = 1;
    private static final String DATABASE_NAME = "stuudium.db";

    private static final String TABLE_LOGIN_DATA = "s_login_data";
    private static final String TABLE_USER = "s_user";
    private static final String TABLE_PEOPLE = "s_people";
    private static final String TABLE_EVENTS = "s_events";
    private static final String TABLE_JOURNALS = "s_journals";
    private static final String TABLE_ASSIGNMENTS = "s_assignments";

    private static final String COL_ID = "ID";
    private static final String COL_SUBJECT = "SUBJECT";
    private static final String COL_PERSON_ID = "USERID";
    private static final String COL_JSON = "JSON_CONTENT";
    private static final String COL_ACCESS_TOKEN = "ACCESS_TOKEN";
    private static final String COL_EXPIRES_IN = "EXPIRES_IN";
    private static final String COL_REQUEST_TIME = "REQUEST_TIME";

    public StuudiumDatabaseHelper(Context context) {
        super(context, DATABASE_NAME, null, DATABASE_VERSION);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        db.execSQL("CREATE TABLE " + TABLE_LOGIN_DATA + "(" + COL_ID + " INTEGER PRIMARY KEY CHECK (" + COL_ID + " = 0), " + COL_ACCESS_TOKEN + " TEXT, " + COL_EXPIRES_IN + " INTEGER, " + COL_REQUEST_TIME + " INTEGER)");
        db.execSQL("CREATE TABLE " + TABLE_USER + "(" + COL_ID + " INTEGER PRIMARY KEY CHECK (" + COL_ID + " = 0), " + COL_JSON + " TEXT)");
        db.execSQL("CREATE TABLE " + TABLE_PEOPLE + "(" + COL_ID + " TEXT PRIMARY KEY, " + COL_JSON + " TEXT)");
        db.execSQL("CREATE TABLE " + TABLE_EVENTS + "(" + COL_ID + " TEXT, " + COL_PERSON_ID + " TEXT, " + COL_JSON + " TEXT, PRIMARY KEY (" + COL_ID + ", " + COL_PERSON_ID + "))");
        db.execSQL("CREATE TABLE " + TABLE_JOURNALS + "(" + COL_SUBJECT + " TEXT, " + COL_PERSON_ID + " TEXT, " + COL_JSON + " TEXT, PRIMARY KEY (" + COL_SUBJECT + ", " + COL_PERSON_ID + "))");
        db.execSQL("CREATE TABLE " + TABLE_ASSIGNMENTS + "(" + COL_ID + " TEXT, " + COL_PERSON_ID + " TEXT, " + COL_JSON + " TEXT, PRIMARY KEY (" + COL_ID + ", " + COL_PERSON_ID + "))");
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        db.execSQL("DROP TABLE IF EXISTS " + TABLE_LOGIN_DATA);
        db.execSQL("DROP TABLE IF EXISTS " + TABLE_USER);
        db.execSQL("DROP TABLE IF EXISTS " + TABLE_EVENTS);
        db.execSQL("DROP TABLE IF EXISTS " + TABLE_JOURNALS);
        db.execSQL("DROP TABLE IF EXISTS " + TABLE_ASSIGNMENTS);
        db.execSQL("DROP TABLE IF EXISTS " + TABLE_PEOPLE);
        onCreate(db);
    }

    public boolean setLoginData(String accessToken, long expiresIn, long requestTime) {
        SQLiteDatabase db = getWritableDatabase();
        ContentValues contentValues = new ContentValues();
        contentValues.put(COL_ID, 0);
        contentValues.put(COL_ACCESS_TOKEN, accessToken);
        contentValues.put(COL_EXPIRES_IN, expiresIn);
        contentValues.put(COL_REQUEST_TIME, requestTime);
        long result = db.insertWithOnConflict(TABLE_LOGIN_DATA, null, contentValues, SQLiteDatabase.CONFLICT_REPLACE);
        return result != -1;
    }

    public boolean removeLoginData() {
        SQLiteDatabase db = getWritableDatabase();
        int result = db.delete(TABLE_LOGIN_DATA, COL_ID + "=0", null);
        return result > 0;
    }

    public boolean setUser(String json) {
        SQLiteDatabase db = getWritableDatabase();
        ContentValues contentValues = new ContentValues();
        contentValues.put(COL_ID, 0);
        contentValues.put(COL_JSON, json);
        long result = db.insertWithOnConflict(TABLE_USER, null, contentValues, SQLiteDatabase.CONFLICT_REPLACE);
        return result != -1;
    }

    public boolean removeUser() {
        SQLiteDatabase db = getWritableDatabase();
        int result = db.delete(TABLE_USER, COL_ID + "=0", null);
        return result > 0;
    }

    public boolean insertStuudiumEvent(String id, String personid, String json) {
        SQLiteDatabase db = getWritableDatabase();
        ContentValues contentValues = new ContentValues();
        contentValues.put(COL_ID, id);
        contentValues.put(COL_PERSON_ID, personid);
        contentValues.put(COL_JSON, json);
        long result = db.insertWithOnConflict(TABLE_EVENTS, null, contentValues, SQLiteDatabase.CONFLICT_REPLACE);
        return result != -1;
    }

    public boolean insertStuudiumJournal(String subject, String personid, String json) {
        SQLiteDatabase db = getWritableDatabase();
        ContentValues contentValues = new ContentValues();
        contentValues.put(COL_SUBJECT, subject);
        contentValues.put(COL_PERSON_ID, personid);
        contentValues.put(COL_JSON, json);
        long result = db.insertWithOnConflict(TABLE_JOURNALS, null, contentValues, SQLiteDatabase.CONFLICT_REPLACE);
        return result != -1;
    }

    public boolean insertStuudiumAssignment(String id, String personid, String json) {
        SQLiteDatabase db = getWritableDatabase();
        ContentValues contentValues = new ContentValues();
        contentValues.put(COL_ID, id);
        contentValues.put(COL_PERSON_ID, personid);
        contentValues.put(COL_JSON, json);
        long result = db.insertWithOnConflict(TABLE_ASSIGNMENTS, null, contentValues, SQLiteDatabase.CONFLICT_REPLACE);
        return result != -1;
    }

    public boolean insertStuudiumPerson(String id, String json) {
        SQLiteDatabase db = getWritableDatabase();
        ContentValues contentValues = new ContentValues();
        contentValues.put(COL_ID, id);
        contentValues.put(COL_JSON, json);
        long result = db.insertWithOnConflict(TABLE_PEOPLE, null, contentValues, SQLiteDatabase.CONFLICT_REPLACE);
        return result != -1;
    }

    public boolean removeAllData() {
        SQLiteDatabase db = getWritableDatabase();
        int result = db.delete(TABLE_USER, null, null)
                + db.delete(TABLE_LOGIN_DATA, null, null)
                + db.delete(TABLE_EVENTS, null, null)
                + db.delete(TABLE_ASSIGNMENTS, null, null)
                + db.delete(TABLE_JOURNALS, null, null)
                + db.delete(TABLE_PEOPLE, null, null);
        return result > 0;
    }

    public boolean removeStuudiumPerson(String id) {
        SQLiteDatabase db = getWritableDatabase();
        int result = db.delete(TABLE_EVENTS, COL_PERSON_ID + "=?", new String[]{id})
                + db.delete(TABLE_ASSIGNMENTS, COL_PERSON_ID + "=?", new String[]{id})
                + db.delete(TABLE_JOURNALS, COL_PERSON_ID + "=?", new String[]{id})
                + db.delete(TABLE_PEOPLE, COL_ID + "=?", new String[]{id});
        return result > 0;
    }

    public boolean removeStuudiumEvent(String id) {
        SQLiteDatabase db = getWritableDatabase();
        int result = db.delete(TABLE_EVENTS, COL_ID + "=?", new String[]{id});
        return result > 0;
    }

    public boolean removeStuudiumAssignment(String id) {
        SQLiteDatabase db = getWritableDatabase();
        int result = db.delete(TABLE_ASSIGNMENTS, COL_ID + "=?", new String[]{id});
        return result > 0;
    }

    public boolean removeStuudiumJournal(String subject) {
        SQLiteDatabase db = getWritableDatabase();
        int result = db.delete(TABLE_JOURNALS, COL_SUBJECT + "=?", new String[]{subject});
        return result > 0;
    }

    public LoginData requestLoginData() {
        SQLiteDatabase db = getReadableDatabase();
        Cursor c = db.rawQuery("SELECT * FROM " + TABLE_LOGIN_DATA, null);
        LoginData loginData = null;
        if (c.moveToFirst()) {
            String access_token = c.getString(1);
            long expires_in = c.getLong(2);
            long request_time = c.getLong(3);
            loginData = new LoginData(access_token, expires_in, request_time);
        }
        c.close();
        return loginData;
    }

    public User requestUser() {
        SQLiteDatabase db = getReadableDatabase();
        Cursor c = db.rawQuery("SELECT * FROM " + TABLE_USER, null);
        User user = null;
        if (c.moveToFirst()) try {
            JSONObject json = new JSONObject(c.getString(1));
            user = new User(json);
        } catch (JSONException e) {
            Log.e(TAG, "Failed to parse JSON", e);
        }
        c.close();
        return user;
    }

    public DataMap<String, Person> requestPeople() {
        SQLiteDatabase db = getReadableDatabase();
        Cursor c = db.rawQuery("SELECT * FROM " + TABLE_PEOPLE, null);
        DataMap<String, Person> events = new DataMap<>();
        if (c.moveToFirst()) do try {
            String id = c.getString(0);
            JSONObject json = new JSONObject(c.getString(1));
            events.put(id, new Person(json));
        } catch (JSONException e) {
            Log.e(TAG, "Failed to parse JSON", e);
        } while (c.moveToNext());
        c.close();
        return events;
    }

    public DataSet<Event> requestEvents(String personId) {
        SQLiteDatabase db = getReadableDatabase();
        Cursor c = db.rawQuery("SELECT * FROM " + TABLE_EVENTS + " WHERE " + COL_PERSON_ID + "=?", new String[]{personId});
        DataSet<Event> events = new DataSet<>();
        if (c.moveToFirst()) do try {
            JSONObject json = new JSONObject(c.getString(2));
            events.add(new Event(json));
        } catch (JSONException e) {
            Log.e(TAG, "Failed to parse JSON", e);
        } while (c.moveToNext());
        c.close();
        return events;
    }

    public DataSet<Assignment> requestAssignments(String personId) {
        SQLiteDatabase db = getReadableDatabase();
        Cursor c = db.rawQuery("SELECT * FROM " + TABLE_ASSIGNMENTS + " WHERE " + COL_PERSON_ID + "=?", new String[]{personId});
        DataSet<Assignment> events = new DataSet<>();
        if (c.moveToFirst()) do try {
            JSONObject json = new JSONObject(c.getString(2));
            events.add(new Assignment(personId, json));
        } catch (JSONException e) {
            Log.e(TAG, "Failed to parse JSON", e);
        } while (c.moveToNext());
        c.close();
        return events;
    }

    public DataSet<Journal> requestJournals(String personId) {
        SQLiteDatabase db = getReadableDatabase();
        Cursor c = db.rawQuery("SELECT * FROM " + TABLE_JOURNALS + " WHERE " + COL_PERSON_ID + "=?", new String[]{personId});
        DataSet<Journal> events = new DataSet<>();
        if (c.moveToFirst()) do try {
            JSONObject json = new JSONObject(c.getString(2));
            events.add(new Journal(json));
        } catch (JSONException e) {
            Log.e(TAG, "Failed to parse JSON", e);
        } while (c.moveToNext());
        c.close();
        return events;
    }
}


text:
package blue.lapis.pore.impl.event.player;

import static com.google.common.base.Preconditions.checkNotNull;

import org.apache.commons.lang.NotImplementedException;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerVelocityEvent;
import org.bukkit.util.Vector;
import org.spongepowered.api.event.entity.living.player.PlayerEvent;

public class PorePlayerVelocityEvent extends PlayerVelocityEvent {

    private final PlayerEvent handle;

    public PorePlayerVelocityEvent(PlayerEvent handle) {
        super(null, null);
        this.handle = checkNotNull(handle, "handle");
    }

    public PlayerEvent getHandle() {
        return handle;
    }

    @Override
    public Player getPlayer() {
        throw new NotImplementedException();
    }

    @Override
    public Vector getVelocity() {
        throw new NotImplementedException();
    }

    @Override
    public void setVelocity(Vector velocity) {
        throw new NotImplementedException();
    }

    @Override
    public boolean isCancelled() {
        throw new NotImplementedException();
    }

    @Override
    public void setCancelled(boolean cancel) {
        throw new NotImplementedException();
    }

}


text:
angular.module('angularPromiseButtons', [
]);

angular.module('angularPromiseButtons')
    .directive('promiseBtn', ['angularPromiseButtons', '$parse', function (angularPromiseButtons, $parse)
    {
        'use strict';

        var CLICK_EVENT = 'click';
        var CLICK_ATTR = 'ngClick';
        var SUBMIT_EVENT = 'submit';
        var SUBMIT_ATTR = 'ngSubmit';

        return {
            restrict: 'EA',
            scope: {
                promiseBtn: '=',
                promiseBtnOptions: '=?'
            },
            link: function (scope, el, attrs)
            {
                var providerCfg = angularPromiseButtons.config;
                var cfg = providerCfg;
                var promiseWatcher;

                function handleLoading(btnEl)
                {
                    if (cfg.btnLoadingClass && !cfg.addClassToCurrentBtnOnly) {
                        btnEl.addClass(cfg.btnLoadingClass);
                    }
                    if (cfg.disableBtn && !cfg.disableCurrentBtnOnly) {
                        btnEl.attr('disabled', 'disabled');
                    }
                }

                function handleLoadingFinished(btnEl)
                {
                    if (cfg.btnLoadingClass) {
                        btnEl.removeClass(cfg.btnLoadingClass);
                    }
                    if (cfg.disableBtn) {
                        btnEl.removeAttr('disabled');
                    }
                }

                function initPromiseWatcher(watchExpressionForPromise, btnEl)
                {
                    // watch promise to resolve or fail
                    scope.$watch(watchExpressionForPromise, function (mVal)
                    {
                        // for regular promises
                        if (mVal && mVal.then) {
                            handleLoading(btnEl);
                            mVal.finally(function ()
                            {
                                handleLoadingFinished(btnEl);
                            });
                        }
                        // for $resource
                        else if (mVal && mVal.$promise) {
                            handleLoading(btnEl);
                            mVal.$promise.finally(function ()
                            {
                                handleLoadingFinished(btnEl);
                            });
                        }
                    });
                }

                function getCallbacks(expression)
                {
                    return expression
                    // split by ; to get different functions if any
                        .split(';')
                        .map(function (callback)
                        {
                            // return getter function
                            return $parse(callback);
                        });
                }

                function appendSpinnerTpl(btnEl)
                {
                    btnEl.append(cfg.spinnerTpl);
                }

                function addHandlersForCurrentBtnOnly(btnEl)
                {
                    // handle current button only options via click
                    if (cfg.addClassToCurrentBtnOnly) {
                        btnEl.on(CLICK_EVENT, function ()
                        {
                            btnEl.addClass(cfg.btnLoadingClass);
                        });
                    }

                    if (cfg.disableCurrentBtnOnly) {
                        btnEl.on(CLICK_EVENT, function ()
                        {
                            btnEl.attr('disabled', 'disabled');
                        });
                    }
                }

                function initHandlingOfViewFunctionsReturningAPromise(eventToHandle, attrToParse, btnEl)
                {
                    // we need to use evalAsync here, as
                    // otherwise the click or submit event
                    // won't be ready to be replaced
                    scope.$evalAsync(function ()
                    {
                        var callbacks = getCallbacks(attrs[attrToParse]);

                        // unbind original click event
                        el.unbind(eventToHandle);

                        // rebind, but this time watching it's return value
                        el.bind(eventToHandle, function ()
                        {
                            // Make sure we run the $digest cycle
                            scope.$apply(function ()
                            {
                                callbacks.forEach(function (cb)
                                {
                                    // execute function on parent scope
                                    // as we're in an isolate scope here
                                    var promise = cb(scope.$parent, {$event: eventToHandle});

                                    // only init watcher if not done before
                                    if (!promiseWatcher) {
                                        promiseWatcher = initPromiseWatcher(function ()
                                        {
                                            return promise;
                                        }, btnEl);
                                    }
                                });
                            });
                        });
                    });
                }

                function getSubmitBtnChildren(el)
                {
                    var submitBtnEls = [];
                    var allButtonEls = el.find('button');

                    for (var i = 0; i < allButtonEls.length; i++) {
                        var btnEl = allButtonEls[i];
                        if (angular.element(btnEl).attr('type') === 'submit') {
                            submitBtnEls.push(btnEl);
                        }
                    }
                    return angular.element(submitBtnEls);
                }

                // INIT
                // check if there is any value given via attrs.promiseBtn
                if (!attrs.promiseBtn) {
                    // handle ngClick function directly returning a promise
                    if (attrs.hasOwnProperty(CLICK_ATTR)) {
                        appendSpinnerTpl(el);
                        addHandlersForCurrentBtnOnly(el);
                        initHandlingOfViewFunctionsReturningAPromise(CLICK_EVENT, CLICK_ATTR, el);
                    }
                    // handle ngSubmit function directly returning a promise
                    else if (attrs.hasOwnProperty(SUBMIT_ATTR)) {
                        // get child submits for form elements
                        var btnElements = getSubmitBtnChildren(el);

                        appendSpinnerTpl(btnElements);
                        addHandlersForCurrentBtnOnly(btnElements);
                        initHandlingOfViewFunctionsReturningAPromise(SUBMIT_EVENT, SUBMIT_ATTR, btnElements);
                    }
                }
                // handle promises passed via scope.promiseBtn
                else {
                    appendSpinnerTpl(el);
                    addHandlersForCurrentBtnOnly(el);
                    // handle promise passed directly via attribute as variable
                    initPromiseWatcher(function ()
                    {
                        return scope.promiseBtn;
                    }, el);
                }

                // watch and update options being changed
                scope.$watch('promiseBtnOptions', function (newVal)
                {
                    if (angular.isObject(newVal)) {
                        cfg = angular.extend({}, providerCfg, newVal);
                    }
                }, true);
            }
        };
    }]);

angular.module('angularPromiseButtons')
    .provider('angularPromiseButtons', function angularPromiseButtonsProvider()
    {
        'use strict';

        // *****************
        // DEFAULTS & CONFIG
        // *****************

        var config = {
            spinnerTpl: '',
            disableBtn: true,
            btnLoadingClass: 'is-loading',
            addClassToCurrentBtnOnly: false,
            disableCurrentBtnOnly: false
        };

        // *****************
        // SERVICE-FUNCTIONS
        // *****************

        // *************************
        // PROVIDER-CONFIG-FUNCTIONS
        // *************************

        return {
            extendConfig: function (newConfig)
            {
                config = angular.extend(config, newConfig);
            },

            // ************************************************
            // ACTUAL FACTORY FUNCTION - used by the directive
            // ************************************************

            $get: function ()
            {
                return {
                    config: config
                };
            }
        };
    });


text:
package io.jenetics.util;

import java.util.stream.Stream;

/**
 * @param <T> the object type this factory creates.
 *
 * @author Franz Wilhelmstötter
 * @since 1.0
 * @version 3.0
 */
@FunctionalInterface
public interface Factory<T> {

	/**
	 * Create a new instance of type T.
	 *
	 * @return a new instance of type T
	 */
	T newInstance();

	/**
	 * Return a new stream of object instances, created by this factory.
	 *
	 * @since 3.0
	 *
	 * @return a stream of objects, created by this factory
	 */
	default Stream<T> instances() {
		return Stream.generate(this::newInstance);
	}

}


text:
function y = fix_regression_name_inconsistency (rname)
	y=upper(rname);