text:
class CPRTMesh
{
public:
            CPRTMesh( void );
            ~CPRTMesh( void );

    HRESULT OnCreateDevice( LPDIRECT3DDEVICE9 pd3dDevice, D3DFORMAT fmt );
    HRESULT OnResetDevice();
    void    OnLostDevice();
    void    OnDestroyDevice();

    // General
    HRESULT LoadEffects( IDirect3DDevice9* pd3dDevice, const D3DCAPS9* pDeviceCaps );

    // Mesh
    HRESULT LoadMesh( IDirect3DDevice9* pd3dDevice, WCHAR* strMeshFileName );
    HRESULT SetMesh( IDirect3DDevice9* pd3dDevice, ID3DXMesh* pMesh );
    HRESULT AdjustMeshDecl( IDirect3DDevice9* pd3dDevice, ID3DXMesh** ppMesh );
    DWORD   GetNumVertices()
    {
        return m_pMesh->GetNumVertices();
    }
    ID3DXMesh* GetMesh()
    {
        return m_pMesh;
    }
    D3DXMATERIAL* GetMaterials()
    {
        return m_pMaterials;
    }
    DWORD   GetNumMaterials()
    {
        return m_dwNumMaterials;
    }
    bool    IsMeshLoaded()
    {
        return ( m_pMesh != NULL );
    }
    IDirect3DTexture9* GetAlbedoTexture()
    {
        return m_pAlbedoTextures[0];
    }
    float   GetObjectRadius()
    {
        return m_fObjectRadius;
    }
    const D3DXVECTOR3& GetObjectCenter()
    {
        return m_vObjectCenter;
    }

    // Misc
    void    GetVertexUnderMouse( const D3DXMATRIX* pmProj, const D3DXMATRIX* pmView, const D3DXMATRIX* pmWorld,
                                 unsigned int* uVert );
    void    GetSHTransferFunctionAtVertex( unsigned int uVert, int uTechnique, unsigned int uChan, float* pfVals );
    void    GetVertexPosition( unsigned int uVert, D3DXVECTOR3* pvPos );

    // N dot L
    void    RenderWithNdotL( IDirect3DDevice9* pd3dDevice, D3DXMATRIX* pmWorldViewProj, D3DXMATRIX* pmWorldInv,
                             bool bRenderWithAlbedoTexture, CDXUTDirectionWidget* aLightControl, int nNumLights,
                             float fLightScale );

    // SHIrradEnvMap
    void    RenderWithSHIrradEnvMap( IDirect3DDevice9* pd3dDevice, D3DXMATRIX* pmWorldViewProj,
                                     bool bRenderWithAlbedoTexture );
    void    ComputeSHIrradEnvMapConstants( float* pSHCoeffsRed, float* pSHCoeffsGreen, float* pSHCoeffsBlue );

    // PRT
    void    SetPRTBuffer( ID3DXPRTBuffer* pPRTBuffer, WCHAR* strFile );
    HRESULT LoadPRTBufferFromFile( WCHAR* strFile );
    HRESULT LoadCompPRTBufferFromFile( WCHAR* strFile );
    HRESULT CompressPRTBuffer( D3DXSHCOMPRESSQUALITYTYPE Quality, UINT NumClusters, UINT NumPCA, LPD3DXSHPRTSIMCB pCB=
                               NULL, LPVOID lpUserContext=NULL );
    void    ExtractCompressedDataForPRTShader();
    void    ComputeShaderConstants( float* pSHCoeffsRed, float* pSHCoeffsGreen, float* pSHCoeffsBlue,
                                    DWORD dwNumCoeffsPerChannel );
    void    RenderWithPRT( IDirect3DDevice9* pd3dDevice, D3DXMATRIX* pmWorldViewProj, bool bRenderWithAlbedoTexture );
    HRESULT SavePRTBufferToFile( WCHAR* strFile );
    HRESULT SaveCompPRTBufferToFile( WCHAR* strFile );

    DWORD   GetPRTOrder()
    {
        return m_dwPRTOrder;
    }
    bool    IsPRTUncompressedBufferLoaded()
    {
        return ( m_pPRTBuffer != NULL );
    }
    bool    IsPRTCompBufferLoaded()
    {
        return ( m_pPRTCompBuffer != NULL );
    }
    ID3DXPRTCompBuffer* GetPRTCompBuffer()
    {
        return m_pPRTCompBuffer;
    }
    ID3DXPRTBuffer* GetPRTBuffer()
    {
        return m_pPRTBuffer;
    }
    bool    IsPRTShaderDataExtracted()
    {
        return ( m_aPRTClusterBases != NULL );
    }
    bool    IsPRTEffectLoaded()
    {
        return ( m_pPRTEffect != NULL );
    }
    UINT    GetOrderFromNumCoeffs( UINT dwNumCoeffs );

    // LDPRT
    void    RenderWithLDPRT( IDirect3DDevice9* pd3dDevice, D3DXMATRIX* pmWorldViewProj, D3DXMATRIX* pmNormalXForm,
                             bool bUniform, bool bRenderWithAlbedo );
    void    SetLDPRTData( ID3DXPRTBuffer* pLDPRTBuff, D3DXVECTOR3* pShadingNormal );
    void    ComputeLDPRTConstants( float* pSHCoeffsRed, float* pSHCoeffsGreen, float* pSHCoeffsBlue,
                                   DWORD dwNumCoeffsPerChannel );
    static VOID WINAPI StaticFillCubeTextureWithSHCallback( D3DXVECTOR4* pOut, CONST D3DXVECTOR3* pTexCoord, CONST D3DXVECTOR3* pTexelSize, LPVOID pData );
    HRESULT LoadLDPRTFromFiles( WCHAR* strLDPRTFile, WCHAR* strShadingNormalsFile );
    HRESULT SaveLDPRTToFiles( WCHAR* strLDPRTFile, WCHAR* strShadingNormalsFile );
    HRESULT CreateLDPRTData();

protected:
    struct RELOAD_STATE
    {
        bool bUseReloadState;
        bool bLoadCompressed;
        WCHAR   strMeshFileName[MAX_PATH];
        WCHAR   strPRTBufferFileName[MAX_PATH];
        WCHAR   strLDPRTFile[MAX_PATH];
        WCHAR   strShadingNormalsFile[MAX_PATH];
        D3DXSHCOMPRESSQUALITYTYPE quality;
        UINT dwNumClusters;
        UINT dwNumPCA;
    } m_ReloadState;

    ///////////
    // Mesh
    ID3DXMesh* m_pMesh;
    CGrowableArray <IDirect3DTexture9*> m_pAlbedoTextures;
    D3DXMATERIAL* m_pMaterials;
    ID3DXBuffer* m_pMaterialBuffer;
    DWORD m_dwNumMaterials;
    float m_fObjectRadius;
    D3DXVECTOR3 m_vObjectCenter;
    LPDIRECT3DDEVICE9 m_pd3dDevice;
    D3DVIEWPORT9 m_ViewPort;

    ///////////
    // N dot L
    ID3DXEffect* m_pNDotLEffect;

    ///////////
    // SHIrradEnvMap
    ID3DXEffect* m_pSHIrradEnvMapEffect;

    ///////////
    // PRT
    ID3DXPRTBuffer* m_pPRTBuffer;
    ID3DXEffect* m_pPRTEffect;
    DWORD m_dwPRTOrder;
    ID3DXPRTCompBuffer* m_pPRTCompBuffer;
    // The basis buffer is a large array of floats where
    // Call ID3DXPRTCompBuffer::ExtractBasis() to extract the basis
    // for every cluster.  The basis for a cluster is an array of
    // (NumPCAVectors+1)*(NumChannels*Order^2) floats.
    // The "1+" is for the cluster mean.
    float* m_aPRTClusterBases;
    // m_aPRTConstants stores the incident radiance dotted with the transfer function.
    // Each cluster has an array of floats which is the size of
    // 4+MAX_NUM_CHANNELS*NUM_PCA_VECTORS. This number comes from: there can
    // be up to 3 channels (R,G,B), and each channel can
    // have up to NUM_PCA_VECTORS of PCA vectors.  Each cluster also has
    // a mean PCA vector which is described with 4 floats (and hence the +4).
    float* m_aPRTConstants;

    ///////////
    // LDPRT
    D3DXVECTOR3* m_pLDPRTShadingNormals;
    ID3DXPRTBuffer* m_pLDPRTBuffer;
    ID3DXMesh* m_pLDPRTMesh;
    ID3DXEffect* m_pLDPRTEffect;
    D3DXHANDLE m_hValidLDPRTTechnique;
    D3DXHANDLE m_hValidLDPRTTechniqueWithTex;
    IDirect3DCubeTexture9* m_pSHBasisTextures[9];  // Store SH basis functions using textures
};


text:
using System;
using System.Numerics;

class CheatSheet
{
    static void Main()
    {
        int rows = int.Parse(Console.ReadLine());
        int cols = int.Parse(Console.ReadLine());
        long verticallyStart = long.Parse(Console.ReadLine());
        long horizontallyStart = long.Parse(Console.ReadLine());

        BigInteger n = verticallyStart * horizontallyStart;
        BigInteger tempStart = n;

        BigInteger[,] matrix = new BigInteger[rows, cols];

        for (int i = 0; i < matrix.GetLength(0); i++)
        {
            for (int j = 0; j < matrix.GetLength(1); j++)
            {
                matrix[i, j] = tempStart;
                tempStart += verticallyStart;
            }
            n += horizontallyStart;
            tempStart = n;
            verticallyStart++;

        }

        for (int i = 0; i < matrix.GetLength(0); i++)
        {
            for (int j = 0; j < matrix.GetLength(1); j++)
            {
                Console.Write("{0} ", matrix[i, j]);
            }
            Console.WriteLine();
        }
    }
}

redpajama_set_name: RedPajamaGithub


text:
An example of a Meteor package using a file generated by *bonce*.

Run this example:

```
git clone git@github.com:elidoran/node-bonce.git
cd node-bonce/examples/with-options
npm install upper-case reverse-string
bonce
```

Note:

1. I used `npm install upper-case reverse-string' to install the modules into a *node_modules* directory. These modules will be included in the browserified file because of the options file. Meteor's build tool ignores the *node_modules* directory.
2. There is no *entry file* for Browserify because *bonce* generates it based on the *includes* and *require* in the options file.
3. There is an options file specifying all the common options. Some are comments to show how to put them in the file.
4. The generated file is *package.browserified.js* and is added to the package in its *package.js* file.


text:
title: About Project
created: 2020-10-07 00:29:26
template: page.html
---
Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac
cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit
amet risus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui.

Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac
cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit
amet risus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui.

Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac
cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit
amet risus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui.


text:
require File.expand_path('../application', __FILE__)

# Initialize the Rails application.
Userland::Application.initialize!


text:
package no.cantara.cs.dto;

import java.io.Serializable;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;

/**
 * Consider merge/reuse later, https://github.com/constretto/constretto-core/blob/master/constretto-core/src/main/java/org/constretto/internal/store/PropertiesStore.java
 * @author Erik Drolshammer 2015-08-07.
 */
public class NamedPropertiesStore implements Serializable {

	private static final long serialVersionUID = 755323393221223803L;

	public String fileName;
    public final LinkedHashMap<String, String> properties;

    public NamedPropertiesStore(LinkedHashMap<String, String> properties, String fileName) {
        this.properties = properties;
        this.fileName = fileName;
    }

    public NamedPropertiesStore() {
        this.properties = new LinkedHashMap<>();
    }

    @Override
    public String toString() {
        return "NamedPropertiesStore{" +
                "fileName='" + fileName + '\'' +
                ", properties.size=" + properties.size() +
                '}';
    }
}


text:
<!-- ======================================================================= -->
<!-- mobius_mako build file                                         -->
<!-- ======================================================================= -->
<project name="mobius_mako" default="prepare" basedir=".">
	<property file="${basedir}/build.properties" />

	<!-- Information -->
	<property name="project.name" value="mobius_mako" />
	<property name="project.version" value="1.0" />

	<!-- Source, Libraries, and Build -->
	<property name="src.dir" location="${basedir}/src" />
	<property name="lib.dir" location="${basedir}/lib" />
	<property name="build.dir" location="${basedir}/build" />
	<property name="classes.dir" location="${build.dir}/classes" />
	<property name="client.classes.dir" location="${classes.dir}/client" />
	<property name="server.classes.dir" location="${classes.dir}/server" />
	<property name="jars.dir" location="${build.dir}/jars" />
	<property name="client.project.jar" location="${jars.dir}/${project.name}_client-${project.version}.jar" />
	<property name="server.project.jar" location="${jars.dir}/${project.name}_server-${project.version}.jar" />

    <!-- Set by super project to append to build classpath -->
	<property name="client.extra.classpath" value="" />
	<property name="server.extra.classpath" value="" />
	<property name="server.packages" value="**/services/**" />

    <!-- =================================================================== -->
    <!-- The Build Classpath                                                 -->
    <!-- =================================================================== -->
    <path id="client.build.classpath">
        <fileset dir="${lib.dir}">
            <include name="**/*.jar" />
            <exclude name="**/mobius_mako_*_server*.jar" />
        </fileset>
		<pathelement path="${client.extra.classpath}"/>
    </path>
    <path id="server.build.classpath">
		<fileset dir="${lib.dir}">
            <include name="**/mobius_mako_*_server*.jar" />
        </fileset>
        <path refid="client.build.classpath" />
        <pathelement path="${client.classes.dir}"/>
        <pathelement path="${server.extra.classpath}"/>
    </path>

	<!-- =================================================================== -->
	<!-- Cleans up generated stuff                                           -->
	<!-- =================================================================== -->
	<target name="clean">
		<delete dir="${build.dir}" />
	</target>

	<!-- =================================================================== -->
	<!-- Prepares the build directory                                        -->
	<!-- =================================================================== -->
	<target name="prepare">
		<echo message="Preparing to build ${project.name}"/>
		<mkdir dir="${build.dir}" />
		<mkdir dir="${classes.dir}" />
		<mkdir dir="${client.classes.dir}" />
		<mkdir dir="${server.classes.dir}" />
		<mkdir dir="${jars.dir}" />
		<tstamp />
	</target>

	<!-- =================================================================== -->
	<!-- Compiles the source code                                            -->
	<!-- =================================================================== -->
	<target name="compile" depends="prepare" description="Compiles the source files">
		<javac srcdir="${src.dir}" destdir="${client.classes.dir}" debug="on" deprecation="off" optimize="off" excludes="${server.packages}">
			<classpath refid="client.build.classpath" />
		</javac>
		<copy todir="${client.classes.dir}" overwrite="true">
			<fileset dir="${src.dir}">
				<include name="**/*.gif"/>
			</fileset>
		</copy>
		<javac srcdir="${src.dir}" destdir="${server.classes.dir}" debug="on" deprecation="off" optimize="off" includes="${server.packages}">
			<classpath refid="server.build.classpath" />
		</javac>
		<copy todir="${server.classes.dir}" overwrite="true">
			<fileset dir="${src.dir}">
				<include name="**/*.xsd" />
			</fileset>
		</copy>
	</target>

	<!-- =================================================================== -->
	<!-- Create Jar                                                          -->
	<!-- =================================================================== -->
	<target name="jar" depends="compile" description="Builds the Jar Files">
		<jar jarfile="${client.project.jar}" basedir="${client.classes.dir}" defaultExcludes="false" update="no">
			<manifest>
				<attribute name="Created-By" value="${user.name}" />
			</manifest>
		</jar>
		<jar jarfile="${server.project.jar}" basedir="${server.classes.dir}" defaultExcludes="false" update="no">
			<manifest>
				<attribute name="Created-By" value="${user.name}" />
			</manifest>
		</jar>
	</target>

	<!-- =================================================================== -->
	<!-- Builds the Env                                                      -->
	<!-- =================================================================== -->
	<target name="build" description="Builds the entire application" depends="compile, jar" />

	<!-- =================================================================== -->
	<!-- Builds the entire Env and deploys the jar                           -->
	<!-- =================================================================== -->
	<target name="all" description="Build and Dist the entire application" depends="clean, build" />

</project>


text:
title=Ruby Client Yardoc
date=2016-07-18
type=page
tags=hawkular, ruby-client
status=published
~~~~~~

<iframe src="http://www.hawkular.org/hawkular-client-ruby/" style="border:none;" width="1000" height="1700"></iframe>


text:
Crystal

To use this language, use the class "language-crystal".

Number literals with underscores and postfix

1_u32
123_456.789e-10_f64

Attributes

@[AlwaysInline]
def foo
	1
end

Macro expansions

{% for key, value in {foo: 100, bar: 20} %}
	def {{ key.id }}
		{{ value }}
	end
{% end %}

Known failures

There are certain edge cases where Prism will fail.
	There are always such cases in every regex-based syntax highlighter.
	However, Prism dares to be open and honest about them.
	If a failure is listed here, it doesn't mean it will never be fixed. This is more of a "known bugs" list, just with a certain type of bug.

Attriubte-like substrings

" @[AlwaysInline] "

Macro expansions in strings

" {{ foo }} "
" {% bar %} "


text:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_selected="true"
        android:drawable="@drawable/ic_add_box_black_36dp" />
    <item android:state_selected="false"
        android:drawable="@drawable/ic_add_box_grey600_36dp" />
</selector>


text:
__revision__ = '$Id: models.py 28 2009-10-22 15:03:02Z jarek.zgoda $'

import re

from django.db import models
from django.core.urlresolvers import reverse
from django.conf import settings
from django.contrib.sites.models import Site
from django.contrib.contenttypes.models import ContentType
from django.contrib.contenttypes.fields import GenericForeignKey
from django.utils.timezone import now as timezone_now

from zerver.lib.send_email import send_email
from zerver.lib.utils import generate_random_token
from zerver.models import PreregistrationUser, EmailChangeStatus
from typing import Any, Dict, Optional, Text, Union

B16_RE = re.compile('^[a-f0-9]{40}$')

def generate_key():
    # type: () -> Text
    return generate_random_token(40)

class ConfirmationManager(models.Manager):
    url_pattern_name = 'confirmation.views.confirm'

    def confirm(self, confirmation_key):
        # type: (str) -> Union[bool, PreregistrationUser, EmailChangeStatus]
        if B16_RE.search(confirmation_key):
            try:
                confirmation = self.get(confirmation_key=confirmation_key)
            except self.model.DoesNotExist:
                return False

            time_elapsed = timezone_now() - confirmation.date_sent
            if time_elapsed.total_seconds() > settings.EMAIL_CONFIRMATION_DAYS * 24 * 3600:
                return False

            obj = confirmation.content_object
            obj.status = getattr(settings, 'STATUS_ACTIVE', 1)
            obj.save(update_fields=['status'])
            return obj
        return False

    def get_link_for_object(self, obj, host):
        # type: (Union[ContentType, int], str) -> Text
        key = generate_key()
        self.create(content_object=obj, date_sent=timezone_now(), confirmation_key=key)
        return self.get_activation_url(key, host)

    def get_activation_url(self, confirmation_key, host):
        # type: (Text, str) -> Text
        return u'%s%s%s' % (settings.EXTERNAL_URI_SCHEME,
                            host,
                            reverse(self.url_pattern_name,
                                    kwargs={'confirmation_key': confirmation_key}))

class EmailChangeConfirmationManager(ConfirmationManager):
    url_pattern_name = 'zerver.views.user_settings.confirm_email_change'

class Confirmation(models.Model):
    content_type = models.ForeignKey(ContentType)
    object_id = models.PositiveIntegerField()
    content_object = GenericForeignKey('content_type', 'object_id')
    date_sent = models.DateTimeField('sent')
    confirmation_key = models.CharField('activation key', max_length=40)

    objects = ConfirmationManager()

    class Meta(object):
        verbose_name = 'confirmation email'
        verbose_name_plural = 'confirmation emails'

    def __unicode__(self):
        # type: () -> Text
        return 'confirmation email for %s' % (self.content_object,)

class EmailChangeConfirmation(Confirmation):
    class Meta(object):
        proxy = True

    objects = EmailChangeConfirmationManager()

# Conirmation pathways for which there is no content_object that we need to
# keep track of.

def check_key_is_valid(creation_key):
    # type: (Text) -> bool
    if not RealmCreationKey.objects.filter(creation_key=creation_key).exists():
        return False
    days_sofar = (timezone_now() - RealmCreationKey.objects.get(creation_key=creation_key).date_created).days
    # Realm creation link expires after settings.REALM_CREATION_LINK_VALIDITY_DAYS
    if days_sofar <= settings.REALM_CREATION_LINK_VALIDITY_DAYS:
        return True
    return False

def generate_realm_creation_url():
    # type: () -> Text
    key = generate_key()
    RealmCreationKey.objects.create(creation_key=key, date_created=timezone_now())
    return u'%s%s%s' % (settings.EXTERNAL_URI_SCHEME,
                        settings.EXTERNAL_HOST,
                        reverse('zerver.views.create_realm',
                                kwargs={'creation_key': key}))

class RealmCreationKey(models.Model):
    creation_key = models.CharField('activation key', max_length=40)
    date_created = models.DateTimeField('created', default=timezone_now)


text:
<?php

/*
 * This file is a part of the BenStore PHP Framework.
* All rights reserved.
* (C) Bence Szabo 2013
*
*/

/**
 *
 * Image functions
 */
class BaseFileHelper {

	/**
	 *
	 * Application instance.
	 */
	private $app;

	/**
	 *
	 * Setting application instance.
	 */
	public function setApp($value) {
		$this->app = $value;
	}

	/**
	 *
	 * Creates resized, converted image file.
	 */
	public function createThumbnail($source, $dest, $desttype = 'png', $maxwidth = null, $maxheight = null) {

		if (!in_array($desttype, array('png', 'jpg')))
			return false;

		$imgdata = getimagesize($source);
		if ($imgdata === false)
			return false;

		list($width, $height, $type) = $imgdata;
		if ($type == 2 || $type == 3) {
			if ($type == 2) {
				$img_src = imagecreatefromjpeg($source);
			}
			if ($type == 3) {
				$img_src = imagecreatefrompng($source);
			}
			$newwidth = $width;
			$newheight = $height;
			if ($maxwidth != null) {
				if ($newwidth > $maxwidth)
					$newwidth = $maxwidth;
				$rate = $width / $height;
				$newheight = $newwidth / $rate;
			}
			if ($maxheight != null) {
				if ($newheight > $maxheight) {
					$newheight = $maxheight;
					$newwidth = $rate * $newheight;
				}
			}
			$img_dest = imagecreatetruecolor($newwidth, $newheight);
			if ($type == 3) {
				$black = imagecolorallocate($img_dest, 0, 0, 0);
				imagecolortransparent($img_dest, $black);
				imagealphablending($img_dest, false);
			}
			imagecopyresampled($img_dest, $img_src, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
			imagesavealpha($img_dest, true);
			if (!is_dir(dirname($dest)))
				mkdir(dirname($dest));
			if ($desttype == 'png')
				imagepng($img_dest, $dest);
			if ($desttype == 'jpg')
				imagejpeg($img_dest, $dest);
			return true;
		} else {
			return false;
		}
	}

	function deleteDir($target) {
		if(is_dir($target)){
			$files = glob( $target . '*', GLOB_MARK );

			foreach( $files as $file )
			{
				$this->deleteDir( $file );
			}

			@rmdir( $target );
		} elseif(is_file($target)) {
			echo 'file<br/>';
			unlink( $target );
		}
	}

}

?>


text:
class MembershipsController < ApplicationController

  def create
    # binding.pry
    @user = User.find_by(id: params[:user_id])
    if @family = family = User.find_by(email: params[:email])
      Membership.create(user_id: @user.id, family_id: family.id)
      Membership.create(user_id: family.id, family_id: @user.id)
      if request.xhr?
        # binding.pry
        render partial: :membership
      end
      redirect_to @user
    else
      redirect_to @user
    end
  end

end