text:
<?php

namespace Emercoin\OAuthBundle\Security\Providers;

use Emercoin\OAuthBundle\Entity\User;
use Emercoin\OAuthBundle\Helper\InfoCardRequest;
use FOS\UserBundle\Model\UserManagerInterface;
use FOS\UserBundle\Security\UserProvider;
use Symfony\Bridge\Monolog\Logger;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
use Symfony\Component\Security\Core\Exception\UsernameNotFoundException;
use Emercoin\OAuthBundle\Helper\StorageRequest as EmercoinRequest;

class CertificateProvider extends UserProvider
{
    protected $userManager;

    /** @var Request */
    protected $request;

    protected $server;

    public function __construct(UserManagerInterface $userManager, RequestStack $requestStack, Logger $logger, $dsn)
    {
        parent::__construct($userManager);
        $this->userManager = $userManager;
        $this->request = $requestStack->getCurrentRequest();
        $this->logger = $logger;
        $this->dsn = $dsn;
        if (!$this->request) {
            return;
        }
        $this->server = $this->request->server;
    }

    protected function getSSLSerial()
    {
        if (!$this->request) {
            return null;
        }

        if (!$this->server->has('SSL_CLIENT_CERT')) {
            throw new AccessDeniedHttpException('No certificate presented, or missing flag +ExportCertData');
        }

        if (!$this->server->has('SSL_CLIENT_M_SERIAL')) {
            throw new AccessDeniedHttpException('This certificate has no serial number');
        }

        $serial = str_pad(strtolower($this->server->get('SSL_CLIENT_M_SERIAL')), 16, 0, STR_PAD_LEFT);

        if ($serial[0] == '0') {
            throw new AccessDeniedHttpException('Wrong serial number - must not start from zero');
        }

        try {
            $request = new EmercoinRequest('name_show', 'ssl:'.$serial, $this->dsn);
        } catch (\ErrorException $e) {
            throw new AccessDeniedHttpException('Error while connecting to Emercoin API');
        }

        if ($request->getData()['expires_in'] <= 0) {
            throw new AccessDeniedHttpException('NVS record expired, and is not trustable');
        }

        // Compute certificate fingerprint, using algo, defined in the NVS value
        list($algo, $emercoin_fingerprint) = explode('=', $request->getData()['value']);
        $certificate_fingerprint = hash(
            $algo,
            base64_decode(
                preg_replace(
                    '/\-+BEGIN CERTIFICATE\-+|-+END CERTIFICATE\-+|\n|\r/',
                    '',
                    $this->server->get('SSL_CLIENT_CERT')
                )
            )
        );

        if ($emercoin_fingerprint !== $certificate_fingerprint) {
            throw new AccessDeniedHttpException('False certificate provided');
        }

        return $serial;
    }

    public function loadUserByUsername($username)
    {
        $serial = $this->getSSLSerial();
        if (!$serial) {
            throw new UsernameNotFoundException('No user with such certificate SN');
        }

        $infocardRequest = new InfoCardRequest('name_show', $this->server->get('SSL_CLIENT_S_DN_UID'), $this->dsn, $this->server);

        $user = $this->userManager->findUserBy(['serial' => $serial]);

        if (!$user) {
            /** @var User $user */
            $user = $this->userManager->createUser();
            if (strlen($this->server->get('SSL_CLIENT_S_DN_Email')) > 0) {
                $user->setEmail($this->server->get('SSL_CLIENT_S_DN_Email'));
                $user->setEmailCanonical($this->server->get('SSL_CLIENT_S_DN_Email'));
                $user->setUsername($this->server->get('SSL_CLIENT_S_DN_Email'));
                $user->setUsernameCanonical($this->server->get('SSL_CLIENT_S_DN_Email'));
            } else {
                $login = uniqid();
                $user->setEmail($login.'@localhost.com');
                $user->setEmailCanonical($login.'@localhost.com');
                $user->setUsername($login.'@localhost.com');
                $user->setUsernameCanonical($login.'@localhost.com');
            }

            $password = hash('sha256', uniqid("pass", true));
            $user->setPassword($password);
            $user->setEnabled(true);
            $user->setSerial($serial);
        }

        $infocard = array();
        foreach ($this->server as $key => $value) {
            if (preg_match('/^(SSL_CLIENT(?!_CERT.*)|REMOTE_ADDR|HTTP_USER_AGENT).*/im', $key)) {
                $infocard[$key] = $value;
            }
        }

        $infocard['infocard'] = $infocardRequest->getInfocard();
        $user->setInfocard(json_encode($infocard, JSON_UNESCAPED_UNICODE));

        return $user;
    }
}


text:
<?xml version="1.0" encoding="utf-8"?>
<resources>
    <color name="colorPrimary">#3F51B5</color>
    <color name="colorPrimaryDark">#303F9F</color>
    <color name="colorAccent">#FF4081</color>

    <color name="colorItemBackground">#121212</color>
    <color name="colorItemTextColor">#b3b3b3</color>
</resources>

redpajama_set_name: RedPajamaGithub


text:
#include "VKNShader.h"

#include <ios>
#include <iostream>
#include <fstream>
#include "Core/Assets/AssetManager.h"
#include "VKNRHI.h"
#include "VKNDeviceContext.h"
#include "RHI/ShaderPreProcessor.h"
#include "Core/Platform/PlatformCore.h"
#include "ShaderReflection.h"
#include "Core/Utils/FileUtils.h"

VKNShader::VKNShader()
{}

VKNShader::~VKNShader()
{}

EShaderError::Type VKNShader::AttachAndCompileShaderFromFile(const char * filename, EShaderType::Type type, const char * Entrypoint)
{
	if (type != EShaderType::SHADER_VERTEX && type != EShaderType::SHADER_FRAGMENT && type != EShaderType::SHADER_GEOMETRY && type != EShaderType::SHADER_COMPUTE)
	{
		return EShaderError::Type();
	}

	entyPoint = Entrypoint;
	std::vector<char> data = VKNShader::ComplieShader_Local(filename, type, true, filename);

	VkPipelineShaderStageCreateInfo I = {};
	I.module = createShaderModule(data);
	I.stage = ConvStage(type);
	I.sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO;
	I.pName = StringUtils::CopyStringToCharArray(entyPoint);
	Stages.push_back(I);
	return EShaderError::SHADER_ERROR_NONE;
}

std::vector<char> VKNShader::readFile(const std::string& filename)
{
	std::ifstream file(filename, std::ios::ate | std::ios::binary);
	if (!file.is_open())
	{
		throw std::runtime_error("failed to open file!");
	}
	size_t fileSize = (size_t)file.tellg();
	std::vector<char> buffer(fileSize);
	file.seekg(0);
	file.read(buffer.data(), fileSize);
	file.close();

	return buffer;
}
VkShaderModule VKNShader::createShaderModule(const std::vector<char>& code)
{
	VkShaderModuleCreateInfo createInfo = {};
	createInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO;
	createInfo.codeSize = code.size();
	createInfo.pCode = reinterpret_cast<const uint32_t*>(code.data());
	VkShaderModule shaderModule;
	if (vkCreateShaderModule(VKNRHI::GetVDefaultDevice()->device, &createInfo, nullptr, &shaderModule) != VK_SUCCESS)
	{
		throw std::runtime_error("failed to create shader module!");
	}
	return shaderModule;
}

const TBuiltInResource DefaultTBuiltInResource = {
	/* .MaxLights = */ 32,
	/* .MaxClipPlanes = */ 6,
	/* .MaxTextureUnits = */ 32,
	/* .MaxTextureCoords = */ 32,
	/* .MaxVertexAttribs = */ 64,
	/* .MaxVertexUniformComponents = */ 4096,
	/* .MaxVaryingFloats = */ 64,
	/* .MaxVertexTextureImageUnits = */ 32,
	/* .MaxCombinedTextureImageUnits = */ 80,
	/* .MaxTextureImageUnits = */ 32,
	/* .MaxFragmentUniformComponents = */ 4096,
	/* .MaxDrawBuffers = */ 32,
	/* .MaxVertexUniformVectors = */ 128,
	/* .MaxVaryingVectors = */ 8,
	/* .MaxFragmentUniformVectors = */ 16,
	/* .MaxVertexOutputVectors = */ 16,
	/* .MaxFragmentInputVectors = */ 15,
	/* .MinProgramTexelOffset = */ -8,
	/* .MaxProgramTexelOffset = */ 7,
	/* .MaxClipDistances = */ 8,
	/* .MaxComputeWorkGroupCountX = */ 65535,
	/* .MaxComputeWorkGroupCountY = */ 65535,
	/* .MaxComputeWorkGroupCountZ = */ 65535,
	/* .MaxComputeWorkGroupSizeX = */ 1024,
	/* .MaxComputeWorkGroupSizeY = */ 1024,
	/* .MaxComputeWorkGroupSizeZ = */ 64,
	/* .MaxComputeUniformComponents = */ 1024,
	/* .MaxComputeTextureImageUnits = */ 16,
	/* .MaxComputeImageUniforms = */ 8,
	/* .MaxComputeAtomicCounters = */ 8,
	/* .MaxComputeAtomicCounterBuffers = */ 1,
	/* .MaxVaryingComponents = */ 60,
	/* .MaxVertexOutputComponents = */ 64,
	/* .MaxGeometryInputComponents = */ 64,
	/* .MaxGeometryOutputComponents = */ 128,
	/* .MaxFragmentInputComponents = */ 128,
	/* .MaxImageUnits = */ 8,
	/* .MaxCombinedImageUnitsAndFragmentOutputs = */ 8,
	/* .MaxCombinedShaderOutputResources = */ 8,
	/* .MaxImageSamples = */ 0,
	/* .MaxVertexImageUniforms = */ 0,
	/* .MaxTessControlImageUniforms = */ 0,
	/* .MaxTessEvaluationImageUniforms = */ 0,
	/* .MaxGeometryImageUniforms = */ 0,
	/* .MaxFragmentImageUniforms = */ 8,
	/* .MaxCombinedImageUniforms = */ 8,
	/* .MaxGeometryTextureImageUnits = */ 16,
	/* .MaxGeometryOutputVertices = */ 256,
	/* .MaxGeometryTotalOutputComponents = */ 1024,
	/* .MaxGeometryUniformComponents = */ 1024,
	/* .MaxGeometryVaryingComponents = */ 64,
	/* .MaxTessControlInputComponents = */ 128,
	/* .MaxTessControlOutputComponents = */ 128,
	/* .MaxTessControlTextureImageUnits = */ 16,
	/* .MaxTessControlUniformComponents = */ 1024,
	/* .MaxTessControlTotalOutputComponents = */ 4096,
	/* .MaxTessEvaluationInputComponents = */ 128,
	/* .MaxTessEvaluationOutputComponents = */ 128,
	/* .MaxTessEvaluationTextureImageUnits = */ 16,
	/* .MaxTessEvaluationUniformComponents = */ 1024,
	/* .MaxTessPatchComponents = */ 120,
	/* .MaxPatchVertices = */ 32,
	/* .MaxTessGenLevel = */ 64,
	/* .MaxViewports = */ 16,
	/* .MaxVertexAtomicCounters = */ 0,
	/* .MaxTessControlAtomicCounters = */ 0,
	/* .MaxTessEvaluationAtomicCounters = */ 0,
	/* .MaxGeometryAtomicCounters = */ 0,
	/* .MaxFragmentAtomicCounters = */ 8,
	/* .MaxCombinedAtomicCounters = */ 8,
	/* .MaxAtomicCounterBindings = */ 1,
	/* .MaxVertexAtomicCounterBuffers = */ 0,
	/* .MaxTessControlAtomicCounterBuffers = */ 0,
	/* .MaxTessEvaluationAtomicCounterBuffers = */ 0,
	/* .MaxGeometryAtomicCounterBuffers = */ 0,
	/* .MaxFragmentAtomicCounterBuffers = */ 1,
	/* .MaxCombinedAtomicCounterBuffers = */ 1,
	/* .MaxAtomicCounterBufferSize = */ 16384,
	/* .MaxTransformFeedbackBuffers = */ 4,
	/* .MaxTransformFeedbackInterleavedComponents = */ 64,
	/* .MaxCullDistances = */ 8,
	/* .MaxCombinedClipAndCullDistances = */ 8,
	/* .MaxSamples = */ 4,
	/* .maxMeshOutputVerticesNV = */ 256,
	/* .maxMeshOutputPrimitivesNV = */ 512,
	/* .maxMeshWorkGroupSizeX_NV = */ 32,
	/* .maxMeshWorkGroupSizeY_NV = */ 1,
	/* .maxMeshWorkGroupSizeZ_NV = */ 1,
	/* .maxTaskWorkGroupSizeX_NV = */ 32,
	/* .maxTaskWorkGroupSizeY_NV = */ 1,
	/* .maxTaskWorkGroupSizeZ_NV = */ 1,
	/* .maxMeshViewCountNV = */ 4,

	/* .limits = */ {
	/* .nonInductiveForLoops = */ 1,
	/* .whileLoops = */ 1,
	/* .doWhileLoops = */ 1,
	/* .generalUniformIndexing = */ 1,
	/* .generalAttributeMatrixVectorIndexing = */ 1,
	/* .generalVaryingIndexing = */ 1,
	/* .generalSamplerIndexing = */ 1,
	/* .generalVariableIndexing = */ 1,
	/* .generalConstantMatrixVectorIndexing = */ 1,
} };
class TIncluder : public glslang::TShader::Includer
{
public:
	virtual void releaseInclude(glslang::TShader::Includer::IncludeResult*) override
	{}
};
bool VKNShader::GenerateSpirv(const std::string Source, ComplieInfo & CompilerInfo, std::string & OutErrors, std::vector<char>& OutSpirv, std::string name)
{
	glslang::InitializeProcess();
	glslang::TProgram* Program = new glslang::TProgram();

	EShLanguage Stage = (CompilerInfo.stage);
	glslang::TShader* Shader = new glslang::TShader(Stage);
	const char* GlslSourceSkipHeader = Source.c_str();
	Shader->setStrings(&GlslSourceSkipHeader, 1);
	EShMessages Messages = (EShMessages)(EShMsgDefault | EShMsgDebugInfo | EShMsgSpvRules | EShMsgVulkanRules);
	if (CompilerInfo.HLSL)
	{
		Messages = (EShMessages)(Messages | EShMsgReadHlsl);
	}
	int ClientInputSemanticsVersion = 100; // maps to, say, #define VULKAN 100
	glslang::EShTargetClientVersion VulkanClientVersion = glslang::EShTargetVulkan_1_0;
	glslang::EShTargetLanguageVersion TargetVersion = glslang::EShTargetSpv_1_0;
	if (CompilerInfo.HLSL)
	{
		Shader->setEnvInput(glslang::EShSourceHlsl, Stage, glslang::EShClientVulkan, ClientInputSemanticsVersion);
	}
	else
	{
		Shader->setEnvInput(glslang::EShSourceGlsl, Stage, glslang::EShClientVulkan, ClientInputSemanticsVersion);
	}
	Shader->setShiftBindingForSet(glslang::EResSampler, VKNShader::GetBindingOffset(ShaderParamType::Sampler), 0);
	Shader->setShiftBindingForSet(glslang::EResTexture, VKNShader::GetBindingOffset(ShaderParamType::SRV), 0);
	Shader->setShiftBindingForSet(glslang::EResUav, VKNShader::GetBindingOffset(ShaderParamType::UAV), 0);
	Shader->setShiftBindingForSet(glslang::EResUbo, VKNShader::GetBindingOffset(ShaderParamType::CBV), 0);
	Shader->setInvertY(true);
	Shader->setEnvClient(glslang::EShClientVulkan, VulkanClientVersion);
	Shader->setEnvTarget(glslang::EShTargetSpv, TargetVersion);
	Shader->setEntryPoint(entyPoint.c_str());

	TIncluder inc;
	const int DefaultVersion = 450;
	if (!Shader->parse(&DefaultTBuiltInResource, DefaultVersion, ENoProfile, false, false, Messages, inc))
	{
		OutErrors += Program->getInfoLog();
		OutErrors += Program->getInfoDebugLog();
		OutErrors += Shader->getInfoLog();
		return false;
	}
	Program->addShader(Shader);
	if (!Program->link(Messages))
	{
		OutErrors += Program->getInfoLog();
		OutErrors += Program->getInfoDebugLog();
		return false;
	}
	Program->mapIO();
	if (!Program->getIntermediate(Stage))
	{
		OutErrors += Program->getInfoLog();
		OutErrors += Program->getInfoDebugLog();
		return false;
	}

	spv::SpvBuildLogger logger;
	glslang::SpvOptions spvOptions;
	spvOptions.disableOptimizer = true;
	spvOptions.validate = true;
	spvOptions.generateDebugInfo = true;
	std::vector<uint32_t> WordSpirv;
	glslang::GlslangToSpv(*Program->getIntermediate((EShLanguage)Stage), WordSpirv, &logger, &spvOptions);

	WriteBlobs(name, WordSpirv);

	//convert word code to byte code - why is it the output
	for (int i = 0; i < WordSpirv.size(); i++)
	{
		char* BytePointer = (char*)&WordSpirv[i];
		OutSpirv.push_back(BytePointer[0]);
		OutSpirv.push_back(BytePointer[1]);
		OutSpirv.push_back(BytePointer[2]);
		OutSpirv.push_back(BytePointer[3]);
	}
	ShaderReflection::ReflectShader_SPVCross(WordSpirv, GeneratedParams, IsCompute);
	SafeDelete(Program);
	return true;
}

void VKNShader::WriteBlobs(std::string shadername, std::vector<uint32_t>& WordSpirv)
{
	std::string root = AssetManager::GetShaderCacheDir();
	root += std::string(shadername)+".spv";
	FileUtils::CreateDirectoriesToFullPath(root);
	glslang::OutputSpvBin(WordSpirv, root.c_str());
}

std::vector<char> VKNShader::ComplieShader(std::string name, EShaderType::Type T, bool HLSL /*= false*/)
{
	if (HLSL)
	{
		name.append(".hlsl");
	}
	std::string data = AssetManager::Get()->LoadFileWithInclude(name);
	std::string errors = "";
	std::vector<char> spirv = std::vector<char>();
	ComplieInfo t;
	t.stage = GetStage(T);
	t.HLSL = HLSL;
	GenerateSpirv(data, t, errors, spirv, "");
	return spirv;
}

std::vector<char> VKNShader::ComplieShader_Local(std::string name, EShaderType::Type T, bool HLSL, std::string ShaderDebugName)
{
	if (HLSL)
	{
		name.append(".hlsl");
	}
	std::string data = AssetManager::Get()->LoadFileWithInclude(name);
	std::string errors = "";
	std::vector<char> spirv = std::vector<char>();
	ComplieInfo t;
	t.stage = GetStage(T);
	t.HLSL = HLSL;
	ShaderPreProcessor::PreProcessDefines(Defines, data);
	GenerateSpirv(data, t, errors, spirv, ShaderDebugName);
	if (errors.length() > 0)
	{
		std::string Log = "Shader Compile Output: ";
		Log.append(name);
		Log.append("\n");
		Log::LogMessage(Log);
	}
	return spirv;
}

std::vector<VkPipelineShaderStageCreateInfo> VKNShader::GetShaderStages()
{
	return Stages;
}

EShLanguage VKNShader::GetStage(EShaderType::Type T)
{
	switch (T)
	{
		case EShaderType::SHADER_VERTEX:
			return EShLanguage::EShLangVertex;
			break;
		case EShaderType::SHADER_FRAGMENT:
			return EShLanguage::EShLangFragment;
			break;
		case EShaderType::SHADER_GEOMETRY:
			return EShLanguage::EShLangGeometry;
			break;
		case EShaderType::SHADER_COMPUTE:
			return EShLanguage::EShLangCompute;
			break;
		case EShaderType::SHADER_HULL:
			break;
		case EShaderType::SHADER_DOMAIN:
			break;
		case EShaderType::SHADER_RT_LIB:
			break;
	}
	ensure(false);
	return EShLangCount;
}

VkShaderStageFlagBits VKNShader::ConvStage(EShaderType::Type T)
{
	switch (T)
	{
		case EShaderType::SHADER_VERTEX:
			return VkShaderStageFlagBits::VK_SHADER_STAGE_VERTEX_BIT;
			break;
		case EShaderType::SHADER_FRAGMENT:
			return VkShaderStageFlagBits::VK_SHADER_STAGE_FRAGMENT_BIT;
			break;
		case EShaderType::SHADER_GEOMETRY:
			return VkShaderStageFlagBits::VK_SHADER_STAGE_GEOMETRY_BIT;
			break;
		case EShaderType::SHADER_COMPUTE:
			return VkShaderStageFlagBits::VK_SHADER_STAGE_COMPUTE_BIT;
			break;
		case EShaderType::SHADER_HULL:
			break;
		case EShaderType::SHADER_DOMAIN:
			break;
		case EShaderType::SHADER_RT_LIB:
			break;
	}
	ensure(false);
	return VkShaderStageFlagBits::VK_SHADER_STAGE_ALL;
}

int VKNShader::GetBindingOffset(ShaderParamType::Type Type)
{
	switch (Type)
	{
		case ShaderParamType::SRV:
			return 200;
			break;
		case ShaderParamType::UAV:
			return 0; //doesn't work
			break;
		case ShaderParamType::Buffer:
			return 0;//doen't work properly
		case ShaderParamType::CBV:
			return 100;
			break;
		case ShaderParamType::RootConstant:
			return 0;
			break;
		case ShaderParamType::Sampler:
			return 500;
			break;
		case ShaderParamType::Limit:
			break;
	}
	ensure(false);
	return 0;
}


text:
layout: page
permalink: /local/
title: Dining and Local Information
tags: [info]
image:
  feature: banner.jpg
  credit: ESO, Nathaniel C. Sheetz
  creditlink:
share: true
---

Local Information
-----------------
The town of State College and the university campus
combine to offer a relaxed, college town atmosphere with many shops,
restaurants and points
of interest. Recreational opportunities abound including fine golf
courses, tennis courts, gymnasiums and swimming
facilities. For maps and tourism information
visit the Central
Pennsylvania
Convention &
Visitors Bureau online.

Dining
------

###Downtown Restaurants:

- India Pavilion (Indian)
- Cosy Thai Bistro (Thai)
- Green Bowl (make your own stir fry)
- Pho 11 (Vietnamese)
- Brother's Pizza
- The Tavern
- Herwigs (Austrian, not very vegetarian friendly)
- Pita Cabana (Mediterranean)
- The Corner Room (American grill)
- Berkey Creamery (ice cream, on-campus)

###Downtown Coffeeshops:
- Webster's
- The Cheese Shop
- Saint's
- Panera
- Starbucks

###Downtown Bars:
- Zeno's (large beer selection)
- Local Whiskey a.k.a. "The Second" (large whiskey selection)
- Liberty

###Driveable Restaurants:
- Otto's (popular local brewery/restaurant)
- Faccia Luna Pizzeria (wood oven pizzeria/Italina)
- The Greek (greek)
- The Original Waffle House (breakfast/lunch only)
- Meyer Dairy (ice cream)

Walking Route Between Days Inn and Conference Site
--------------------------------------------------
<iframe src="https://www.google.com/maps/embed?pb=!1m29!1m12!1m3!1d6040.9273513625585!2d-77.8695919565871!3d40.79580358033324!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!4m14!1i0!3e2!4m5!1s0x89cea8a218acb4b7%3A0xed573d73f1845079!2sDays+Inn+State+College%2C+240+S+Pugh+St%2C+State+College%2C+PA+16801!3m2!1d40.793547!2d-77.858408!4m5!1s0x89cea67bfb92c563%3A0x1bcced81e460c7ad!2sThe+Nittany+Lion+Inn+of+the+Pennsylvania+State+University%2C+200+W+Park+Ave%2C+State+College%2C+PA+16803!3m2!1d40.797247!2d-77.87080499999999!5e0!3m2!1sen!2sus!4v1415999012389" width="600" height="450" frameborder="0" style="border:0">