text:
#include "config.h"
#include "GraphicsSurface.h"

#if USE(GRAPHICS_SURFACE)
#include "TextureMapperGL.h"

#define EGL_EGLEXT_PROTOTYPES // This must be defined before including egl.h and eglext.h.
#include <EGL/egl.h>
#include <EGL/eglext.h>

#if PLATFORM(QT)
#include <QGuiApplication>
#include <QOpenGLContext>
#include <qpa/qplatformnativeinterface.h>
#endif

namespace WebCore {

#define STRINGIFY(...) #__VA_ARGS__

static GLuint loadShader(GLenum type, const GLchar *shaderSrc)
{
    GLuint shader;
    GLint compiled;

    shader = glCreateShader(type);
    if (!shader)
        return 0;

    glShaderSource(shader, 1, &shaderSrc, 0);
    glCompileShader(shader);
    glGetShaderiv(shader, GL_COMPILE_STATUS, &compiled);
    if (!compiled) {
        glDeleteShader(shader);
        return 0;
    }
    return shader;
}

struct GraphicsSurfacePrivate {
public:
    GraphicsSurfacePrivate(const IntSize& size, GraphicsSurfaceToken token)
        : m_token(token)
        , m_detachedContext(0)
        , m_detachedReadSurface(0)
        , m_detachedDrawSurface(0)
        , m_size(size)
        , m_eglDisplay(0)
        , m_eglContext(0)
        , m_eglConfig(0)
        , m_eglFrontBufferSurface(0)
        , m_eglBackBufferSurface(0)
        , m_initialFrontBufferShareHandle(token.frontBufferHandle)
        , m_frontBufferShareHandle(token.frontBufferHandle)
        , m_backBufferShareHandle(token.backBufferHandle)
        , m_frontBufferTexture(0)
        , m_shaderProgram(0)
    {
        initializeShaderProgram();
    }

    GraphicsSurfacePrivate(const PlatformGraphicsContext3D shareContext, const IntSize& size, GraphicsSurface::Flags flags)
        : m_detachedContext(0)
        , m_detachedReadSurface(0)
        , m_detachedDrawSurface(0)
        , m_size(size)
        , m_eglDisplay(0)
        , m_eglContext(0)
        , m_eglConfig(0)
        , m_eglFrontBufferSurface(0)
        , m_eglBackBufferSurface(0)
        , m_initialFrontBufferShareHandle(0)
        , m_frontBufferShareHandle(0)
        , m_backBufferShareHandle(0)
        , m_frontBufferTexture(0)
        , m_shaderProgram(0)
    {
        initializeShaderProgram();

        static PFNEGLQUERYSURFACEPOINTERANGLEPROC eglQuerySurfacePointerANGLE = 0;
        if (!eglQuerySurfacePointerANGLE) {
            eglQuerySurfacePointerANGLE = reinterpret_cast<PFNEGLQUERYSURFACEPOINTERANGLEPROC>(eglGetProcAddress("eglQuerySurfacePointerANGLE"));
            if (!eglQuerySurfacePointerANGLE)
                return;
        }

        if (!m_eglDisplay || !m_eglContext || !m_eglConfig) {
            m_eglDisplay = eglGetCurrentDisplay();

#if PLATFORM(QT)
            QPlatformNativeInterface* nativeInterface = QGuiApplication::platformNativeInterface();
            m_eglConfig = static_cast<EGLConfig>(nativeInterface->nativeResourceForContext(QByteArrayLiteral("eglConfig"), shareContext));
            EGLContext eglShareContext = static_cast<EGLContext>(nativeInterface->nativeResourceForContext(QByteArrayLiteral("eglContext"), shareContext));
#endif
            EGLint contextAttributes[] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE };
            m_eglContext = eglCreateContext(m_eglDisplay, m_eglConfig, eglShareContext, contextAttributes);
        }

        EGLint attributes[] = {
            EGL_WIDTH, size.width(),
            EGL_HEIGHT, size.height(),
            EGL_TEXTURE_FORMAT, EGL_TEXTURE_RGB,
            EGL_TEXTURE_TARGET, EGL_TEXTURE_2D,
            EGL_NONE
        };

        m_eglFrontBufferSurface = eglCreatePbufferSurface(m_eglDisplay, m_eglConfig, attributes);
        m_eglBackBufferSurface = eglCreatePbufferSurface(m_eglDisplay, m_eglConfig, attributes);
        if (m_eglFrontBufferSurface == EGL_NO_SURFACE || m_eglBackBufferSurface == EGL_NO_SURFACE)
            return;

        eglQuerySurfacePointerANGLE(m_eglDisplay, m_eglFrontBufferSurface, EGL_D3D_TEXTURE_2D_SHARE_HANDLE_ANGLE, &m_frontBufferShareHandle);
        eglQuerySurfacePointerANGLE(m_eglDisplay, m_eglBackBufferSurface, EGL_D3D_TEXTURE_2D_SHARE_HANDLE_ANGLE, &m_backBufferShareHandle);

        m_initialFrontBufferShareHandle = m_frontBufferShareHandle;

        m_token = GraphicsSurfaceToken(m_frontBufferShareHandle, m_backBufferShareHandle);
    }

    ~GraphicsSurfacePrivate()
    {
        releaseFrontBufferTexture();

        if (m_eglBackBufferSurface)
            eglDestroySurface(m_eglDisplay, m_eglBackBufferSurface);

        if (m_shaderProgram)
            glDeleteProgram(m_shaderProgram);
        m_shaderProgram = 0;

        if (m_eglDisplay && m_eglContext)
            eglDestroyContext(m_eglDisplay, m_eglContext);
    }

    void copyFromTexture(uint32_t texture, const IntRect& sourceRect)
    {
        if (!makeCurrent())
            return;
        glBindFramebuffer(GL_FRAMEBUFFER, 0);
        drawTexture(texture);
        glFinish();
        doneCurrent();
    }

    bool makeCurrent()
    {
        m_detachedContext = eglGetCurrentContext();
        m_detachedReadSurface = eglGetCurrentSurface(EGL_READ);
        m_detachedDrawSurface = eglGetCurrentSurface(EGL_DRAW);

        return eglMakeCurrent(m_eglDisplay, m_eglBackBufferSurface, m_eglBackBufferSurface, m_eglContext);
    }

    bool doneCurrent()
    {
        if (!m_detachedContext || !m_detachedDrawSurface || !m_detachedReadSurface)
            return false;

        bool success = eglMakeCurrent(m_eglDisplay, m_detachedDrawSurface, m_detachedReadSurface, m_detachedContext);
        m_detachedContext = 0;
        m_detachedReadSurface = 0;
        m_detachedDrawSurface = 0;
        return success;
    }

    PlatformGraphicsSurface swapBuffers()
    {
        if (m_frontBufferTexture)
            releaseFrontBufferTexture();
        std::swap(m_eglFrontBufferSurface, m_eglBackBufferSurface);
        std::swap(m_frontBufferShareHandle, m_backBufferShareHandle);

        return m_frontBufferShareHandle;
    }

    GraphicsSurfaceToken token() const
    {
        return m_token;
    }

    uint32_t frontBufferTextureID()
    {
        if (!m_eglFrontBufferSurface) {
            m_eglFrontBufferSurface = createSurfaceFromShareHandle(m_size, m_frontBufferShareHandle);

            glGenTextures(1, &m_frontBufferTexture);
            glActiveTexture(GL_TEXTURE0);
            glBindTexture(GL_TEXTURE_2D, m_frontBufferTexture);
            eglBindTexImage(m_eglDisplay, m_eglFrontBufferSurface, EGL_BACK_BUFFER);

            glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
            glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
            glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
            glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
        }

        return m_frontBufferTexture;
    }

    PlatformGraphicsSurface initialFrontBufferShareHandle() const
    {
        return m_initialFrontBufferShareHandle;
    }

    PlatformGraphicsSurface frontBufferShareHandle() const
    {
        return m_frontBufferShareHandle;
    }

    PlatformGraphicsSurface backBufferShareHandle() const
    {
        return m_backBufferShareHandle;
    }

    void releaseFrontBufferTexture()
    {
        if (m_frontBufferTexture) {
            eglReleaseTexImage(m_eglDisplay, m_eglFrontBufferSurface, EGL_BACK_BUFFER);
            glDeleteTextures(1, &m_frontBufferTexture);
            m_frontBufferTexture = 0;
        }

        if (m_eglFrontBufferSurface)
            eglDestroySurface(m_eglDisplay, m_eglFrontBufferSurface);
        m_eglFrontBufferSurface = 0;
    }

    IntSize size() const
    {
        return m_size;
    }

protected:
    void initializeShaderProgram()
    {
        if (m_shaderProgram)
            return;

        GLchar vShaderStr[] =
            STRINGIFY(
                attribute highp vec2 vertex;
                attribute highp vec2 textureCoordinates;
                varying highp vec2 textureCoords;
                void main(void)
                {
                    gl_Position = vec4(vertex, 0.0, 1.0);
                    textureCoords = textureCoordinates;
                }
            );

        GLchar fShaderStr[] =
            STRINGIFY(
                varying highp vec2 textureCoords;
                uniform sampler2D texture;
                void main(void)
                {
                    highp vec3 color = texture2D(texture, textureCoords).rgb;
                    gl_FragColor = vec4(clamp(color, 0.0, 1.0), 1.0);
                }
            );

        GLuint vertexShader;
        GLuint fragmentShader;
        GLint linked;

        vertexShader = loadShader(GL_VERTEX_SHADER, vShaderStr);
        fragmentShader = loadShader(GL_FRAGMENT_SHADER, fShaderStr);
        if (!vertexShader || !fragmentShader)
            return;

        m_shaderProgram = glCreateProgram();
        if (!m_shaderProgram)
            return;

        glAttachShader(m_shaderProgram, vertexShader);
        glAttachShader(m_shaderProgram, fragmentShader);

        glLinkProgram(m_shaderProgram);
        glGetProgramiv(m_shaderProgram, GL_LINK_STATUS, &linked);
        if (!linked) {
            glDeleteProgram(m_shaderProgram);
            m_shaderProgram = 0;
        }

        m_vertexAttr = glGetAttribLocation(m_shaderProgram, "vertex");
        m_textureCoordinatesAttr = glGetAttribLocation(m_shaderProgram, "textureCoordinates");
        m_textureUniform = glGetAttribLocation(m_shaderProgram, "texture");

        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
    }

    EGLSurface createSurfaceFromShareHandle(const IntSize& size, HANDLE shareHandle)
    {
        if (!m_eglDisplay  || !m_eglConfig) {
            m_eglDisplay = eglGetCurrentDisplay();

#if PLATFORM(QT)
            QPlatformNativeInterface* nativeInterface = QGuiApplication::platformNativeInterface();
            m_eglConfig = static_cast<EGLConfig>(nativeInterface->nativeResourceForContext(QByteArrayLiteral("eglConfig"), QOpenGLContext::currentContext()));
#endif
        }

        EGLint attributes[] = {
            EGL_WIDTH, size.width(),
            EGL_HEIGHT, size.height(),
            EGL_TEXTURE_FORMAT, EGL_TEXTURE_RGB,
            EGL_TEXTURE_TARGET, EGL_TEXTURE_2D,
            EGL_NONE
        };

        EGLSurface surface = eglCreatePbufferFromClientBuffer(m_eglDisplay, EGL_D3D_TEXTURE_2D_SHARE_HANDLE_ANGLE, reinterpret_cast<EGLClientBuffer>(shareHandle), m_eglConfig, attributes);
        ASSERT(surface);

        return surface;
    }

    void drawTexture(uint32_t texture)
    {
        glUseProgram(m_shaderProgram);

        glBindBuffer(GL_ARRAY_BUFFER, 0);
        glBindTexture(GL_TEXTURE_2D, texture);

        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);

        GLfloat afVertices[] = {
            -1, -1,
             1, -1,
            -1,  1,
             1,  1
        };
        glVertexAttribPointer(m_vertexAttr, 2, GL_FLOAT, GL_FALSE, 0, afVertices);

        GLfloat aftextureCoordinates[] = {
            0, 1,
            1, 1,
            0, 0,
            1, 0
        };
        glVertexAttribPointer(m_textureCoordinatesAttr, 2, GL_FLOAT, GL_FALSE, 0, aftextureCoordinates);

        glUniform1i(m_textureUniform, 0);

        glEnableVertexAttribArray(m_vertexAttr);
        glEnableVertexAttribArray(m_textureCoordinatesAttr);

        glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);

        glDisableVertexAttribArray(m_vertexAttr);
        glDisableVertexAttribArray(m_textureCoordinatesAttr);

        glBindTexture(GL_TEXTURE_2D, 0);
    }

private:
    GraphicsSurfaceToken m_token;
    EGLContext m_detachedContext;
    EGLSurface m_detachedReadSurface;
    EGLSurface m_detachedDrawSurface;
    IntSize m_size;
    EGLDisplay m_eglDisplay;
    EGLContext m_eglContext;
    EGLConfig m_eglConfig;
    EGLSurface m_eglFrontBufferSurface;
    EGLSurface m_eglBackBufferSurface;
    PlatformGraphicsSurface m_initialFrontBufferShareHandle;
    PlatformGraphicsSurface m_frontBufferShareHandle;
    PlatformGraphicsSurface m_backBufferShareHandle;
    GLuint m_frontBufferTexture;
    GLint m_shaderProgram;

    GLuint m_vertexAttr;
    GLuint m_textureCoordinatesAttr;
    GLuint m_textureUniform;
};

GraphicsSurfaceToken GraphicsSurface::platformExport()
{
    return m_private->token();
}

uint32_t GraphicsSurface::platformGetTextureID()
{
    return m_private->frontBufferTextureID();
}

void GraphicsSurface::platformCopyToGLTexture(uint32_t target, uint32_t id, const IntRect& targetRect, const IntPoint& offset)
{
    // Currently not implemented.
}

void GraphicsSurface::platformCopyFromTexture(uint32_t texture, const IntRect& sourceRect)
{
    m_private->copyFromTexture(texture, sourceRect);
}

void GraphicsSurface::platformPaintToTextureMapper(TextureMapper* textureMapper, const FloatRect& targetRect, const TransformationMatrix& transform, float opacity)
{
    IntSize size = m_private->size();
    FloatRect rectOnContents(FloatPoint::zero(), size);
    TransformationMatrix adjustedTransform = transform;
    adjustedTransform.multiply(TransformationMatrix::rectToRect(rectOnContents, targetRect));
    static_cast<TextureMapperGL*>(textureMapper)->drawTexture(platformGetTextureID(), 0, size, rectOnContents, adjustedTransform, opacity);
}

uint32_t GraphicsSurface::platformFrontBuffer() const
{
    if (m_private->initialFrontBufferShareHandle() == m_private->frontBufferShareHandle())
        return 0;
    if (m_private->initialFrontBufferShareHandle() == m_private->backBufferShareHandle())
        return 1;
    return 0xFFFF;
}

uint32_t GraphicsSurface::platformSwapBuffers()
{
    m_private->swapBuffers();
    return platformFrontBuffer();
}

IntSize GraphicsSurface::platformSize() const
{
    return m_private->size();
}

PassRefPtr<GraphicsSurface> GraphicsSurface::platformCreate(const IntSize& size, Flags flags, const PlatformGraphicsContext3D shareContext)
{
    // Single buffered GraphicsSurface is currently not supported.
    if (flags & SupportsCopyToTexture || flags & SupportsSingleBuffered)
        return PassRefPtr<GraphicsSurface>();

    RefPtr<GraphicsSurface> surface = adoptRef(new GraphicsSurface(size, flags));
    surface->m_private = new GraphicsSurfacePrivate(shareContext, size, flags);

    if (!surface->m_private->frontBufferShareHandle() || !surface->m_private->backBufferShareHandle())
        return PassRefPtr<GraphicsSurface>();

    return surface;
}

PassRefPtr<GraphicsSurface> GraphicsSurface::platformImport(const IntSize& size, Flags flags, const GraphicsSurfaceToken& token)
{
    // Single buffered GraphicsSurface is currently not supported.
    if (flags & SupportsCopyToTexture || flags & SupportsSingleBuffered)
        return PassRefPtr<GraphicsSurface>();

    RefPtr<GraphicsSurface> surface = adoptRef(new GraphicsSurface(size, flags));
    surface->m_private = new GraphicsSurfacePrivate(size, token);

    if (!surface->m_private->frontBufferShareHandle() || !surface->m_private->backBufferShareHandle())
        return PassRefPtr<GraphicsSurface>();

    return surface;
}

char* GraphicsSurface::platformLock(const IntRect& rect, int* outputStride, LockOptions lockOptions)
{
    // GraphicsSurface is currently only being used for WebGL, which does not require this locking mechanism.
    return 0;
}

void GraphicsSurface::platformUnlock()
{
    // GraphicsSurface is currently only being used for WebGL, which does not require this locking mechanism.
}

void GraphicsSurface::platformDestroy()
{
    delete m_private;
    m_private = 0;
}

}
#endif


text:
using System.Collections.Generic;

namespace ReSharper.ContractExtensions.ProblemAnalyzers.PreconditionAnalyzers.MalformContractAnalyzers
{
    internal class PreconditionVisibilityValidator
    {
        public static IEnumerable<ValidationRule> GetValidationRules()
        {
            yield break;
        }
    }
}

redpajama_set_name: RedPajamaGithub


text:
import json
from cStringIO import StringIO

import pytest

from Crypt import CryptBitcoin

@pytest.mark.usefixtures("resetSettings")
class TestUserContent:
    def testSigners(self, site):
        # File info for not existing user file
        file_info = site.content_manager.getFileInfo("data/users/notexist/data.json")
        assert file_info["content_inner_path"] == "data/users/notexist/content.json"
        valid_signers = site.content_manager.getValidSigners("data/users/notexist/content.json")
        assert valid_signers == ["14wgQ4VDDZNoRMFF4yCDuTrBSHmYhL3bet", "notexist", "1TeSTvb4w2PWE81S2rEELgmX2GCCExQGT"]

        # File info for exsitsing user file
        valid_signers = site.content_manager.getValidSigners("data/users/1J6UrZMkarjVg5ax9W4qThir3BFUikbW6C/content.json")
        assert '1TeSTvb4w2PWE81S2rEELgmX2GCCExQGT' in valid_signers  # The site address
        assert '14wgQ4VDDZNoRMFF4yCDuTrBSHmYhL3bet' in valid_signers  # Admin user defined in data/users/content.json
        assert '1J6UrZMkarjVg5ax9W4qThir3BFUikbW6C' in valid_signers  # The user itself
        assert len(valid_signers) == 3  # No more valid signers

        # Valid signer for banned user
        user_content = site.storage.loadJson("data/users/1J6UrZMkarjVg5ax9W4qThir3BFUikbW6C/content.json")
        user_content["cert_user_id"] = "bad@zeroid.bit"

        valid_signers = site.content_manager.getValidSigners("data/users/1J6UrZMkarjVg5ax9W4qThir3BFUikbW6C/content.json", user_content)
        assert '1TeSTvb4w2PWE81S2rEELgmX2GCCExQGT' in valid_signers  # The site address
        assert '14wgQ4VDDZNoRMFF4yCDuTrBSHmYhL3bet' in valid_signers  # Admin user defined in data/users/content.json
        assert not '1J6UrZMkarjVg5ax9W4qThir3BFUikbW6C' in valid_signers  # The user itself

    def testRules(self, site):
        # We going to manipulate it this test rules based on data/users/content.json
        user_content = site.storage.loadJson("data/users/1J6UrZMkarjVg5ax9W4qThir3BFUikbW6C/content.json")

        # Known user
        user_content["cert_auth_type"] = "web"
        user_content["cert_user_id"] = "nofish@zeroid.bit"
        rules = site.content_manager.getRules("data/users/1J6UrZMkarjVg5ax9W4qThir3BFUikbW6C/content.json", user_content)
        assert rules["max_size"] == 100000
        assert "1J6UrZMkarjVg5ax9W4qThir3BFUikbW6C" in rules["signers"]

        # Unknown user
        user_content["cert_auth_type"] = "web"
        user_content["cert_user_id"] = "noone@zeroid.bit"
        rules = site.content_manager.getRules("data/users/1J6UrZMkarjVg5ax9W4qThir3BFUikbW6C/content.json", user_content)
        assert rules["max_size"] == 10000
        assert "1J6UrZMkarjVg5ax9W4qThir3BFUikbW6C" in rules["signers"]

        # User with more size limit based on auth type
        user_content["cert_auth_type"] = "bitmsg"
        user_content["cert_user_id"] = "noone@zeroid.bit"
        rules = site.content_manager.getRules("data/users/1J6UrZMkarjVg5ax9W4qThir3BFUikbW6C/content.json", user_content)
        assert rules["max_size"] == 15000
        assert "1J6UrZMkarjVg5ax9W4qThir3BFUikbW6C" in rules["signers"]

        # Banned user
        user_content["cert_auth_type"] = "web"
        user_content["cert_user_id"] = "bad@zeroid.bit"
        rules = site.content_manager.getRules("data/users/1J6UrZMkarjVg5ax9W4qThir3BFUikbW6C/content.json", user_content)
        assert "1J6UrZMkarjVg5ax9W4qThir3BFUikbW6C" not in rules["signers"]

    def testVerify(self, site):
        privatekey = "5KUh3PvNm5HUWoCfSUfcYvfQ2g3PrRNJWr6Q9eqdBGu23mtMntv"  # For 1TeSTvb4w2PWE81S2rEELgmX2GCCExQGT
        user_inner_path = "data/users/1CjfbrbwtP8Y2QjPy12vpTATkUT7oSiPQ9/content.json"
        data_dict = site.storage.loadJson(user_inner_path)
        users_content = site.content_manager.contents["data/users/content.json"]

        data = StringIO(json.dumps(data_dict))
        assert site.content_manager.verifyFile(user_inner_path, data, ignore_same=False)

        # Test max size exception by setting allowed to 0
        rules = site.content_manager.getRules(user_inner_path, data_dict)
        assert rules["max_size"] == 10000
        assert users_content["user_contents"]["permission_rules"][".*"]["max_size"] == 10000

        users_content["user_contents"]["permission_rules"][".*"]["max_size"] = 0
        rules = site.content_manager.getRules(user_inner_path, data_dict)
        assert rules["max_size"] == 0
        data = StringIO(json.dumps(data_dict))
        assert not site.content_manager.verifyFile(user_inner_path, data, ignore_same=False)
        users_content["user_contents"]["permission_rules"][".*"]["max_size"] = 10000  # Reset

        # Test max optional size exception
        # 1 MB gif = Allowed
        data_dict["files_optional"]["peanut-butter-jelly-time.gif"]["size"] = 1024 * 1024
        del data_dict["signs"]  # Remove signs before signing
        data_dict["signs"] = {
            "1TeSTvb4w2PWE81S2rEELgmX2GCCExQGT": CryptBitcoin.sign(json.dumps(data_dict, sort_keys=True), privatekey)
        }
        data = StringIO(json.dumps(data_dict))
        assert site.content_manager.verifyFile(user_inner_path, data, ignore_same=False)

        # 100 MB gif = Not allowed
        data_dict["files_optional"]["peanut-butter-jelly-time.gif"]["size"] = 100 * 1024 * 1024
        del data_dict["signs"]  # Remove signs before signing
        data_dict["signs"] = {
            "1TeSTvb4w2PWE81S2rEELgmX2GCCExQGT": CryptBitcoin.sign(json.dumps(data_dict, sort_keys=True), privatekey)
        }
        data = StringIO(json.dumps(data_dict))
        assert not site.content_manager.verifyFile(user_inner_path, data, ignore_same=False)
        data_dict["files_optional"]["peanut-butter-jelly-time.gif"]["size"] = 1024 * 1024  # Reset

        # hello.exe = Not allowed
        data_dict["files_optional"]["hello.exe"] = data_dict["files_optional"]["peanut-butter-jelly-time.gif"]
        del data_dict["signs"]  # Remove signs before signing
        data_dict["signs"] = {
            "1TeSTvb4w2PWE81S2rEELgmX2GCCExQGT": CryptBitcoin.sign(json.dumps(data_dict, sort_keys=True), privatekey)
        }
        data = StringIO(json.dumps(data_dict))
        assert not site.content_manager.verifyFile(user_inner_path, data, ignore_same=False)
        del data_dict["files_optional"]["hello.exe"]  # Reset

        # Includes not allowed in user content
        data_dict["includes"] = { "other.json": { } }
        del data_dict["signs"]  # Remove signs before signing
        data_dict["signs"] = {
            "1TeSTvb4w2PWE81S2rEELgmX2GCCExQGT": CryptBitcoin.sign(json.dumps(data_dict, sort_keys=True), privatekey)
        }
        data = StringIO(json.dumps(data_dict))
        assert not site.content_manager.verifyFile(user_inner_path, data, ignore_same=False)

    def testCert(self, site):
        # user_addr = "1J6UrZMkarjVg5ax9W4qThir3BFUikbW6C"
        user_priv = "5Kk7FSA63FC2ViKmKLuBxk9gQkaQ5713hKq8LmFAf4cVeXh6K6A"
        # cert_addr = "14wgQ4VDDZNoRMFF4yCDuTrBSHmYhL3bet"
        cert_priv = "5JusJDSjHaMHwUjDT3o6eQ54pA6poo8La5fAgn1wNc3iK59jxjA"

        # Check if the user file is loaded
        assert "data/users/1J6UrZMkarjVg5ax9W4qThir3BFUikbW6C/content.json" in site.content_manager.contents
        user_content = site.content_manager.contents["data/users/1J6UrZMkarjVg5ax9W4qThir3BFUikbW6C/content.json"]
        rules_content = site.content_manager.contents["data/users/content.json"]

        # Override valid cert signers for the test
        rules_content["user_contents"]["cert_signers"]["zeroid.bit"] = [
            "14wgQ4VDDZNoRMFF4yCDuTrBSHmYhL3bet",
            "1iD5ZQJMNXu43w1qLB8sfdHVKppVMduGz"
        ]

        # Check valid cert signers
        rules = site.content_manager.getRules("data/users/1J6UrZMkarjVg5ax9W4qThir3BFUikbW6C/content.json", user_content)
        assert rules["cert_signers"] == {"zeroid.bit": [
            "14wgQ4VDDZNoRMFF4yCDuTrBSHmYhL3bet",
            "1iD5ZQJMNXu43w1qLB8sfdHVKppVMduGz"
        ]}

        # Sign a valid cert
        user_content["cert_sign"] = CryptBitcoin.sign("1J6UrZMkarjVg5ax9W4qThir3BFUikbW6C#%s/%s" % (
            user_content["cert_auth_type"],
            user_content["cert_user_id"].split("@")[0]
        ), cert_priv)

        # Verify cert
        assert site.content_manager.verifyCert("data/users/1J6UrZMkarjVg5ax9W4qThir3BFUikbW6C/content.json", user_content)

        # Verify if the cert is valid for other address
        assert not site.content_manager.verifyCert("data/users/badaddress/content.json", user_content)

        # Sign user content
        signed_content = site.content_manager.sign(
            "data/users/1J6UrZMkarjVg5ax9W4qThir3BFUikbW6C/content.json", user_priv, filewrite=False
        )

        # Test user cert
        assert site.content_manager.verifyFile(
            "data/users/1J6UrZMkarjVg5ax9W4qThir3BFUikbW6C/content.json",
            StringIO(json.dumps(signed_content)), ignore_same=False
        )

        # Test banned user
        cert_user_id = user_content["cert_user_id"]  # My username
        site.content_manager.contents["data/users/content.json"]["user_contents"]["permissions"][cert_user_id] = False
        assert not site.content_manager.verifyFile(
            "data/users/1J6UrZMkarjVg5ax9W4qThir3BFUikbW6C/content.json",
            StringIO(json.dumps(signed_content)), ignore_same=False
        )

        # Test invalid cert
        user_content["cert_sign"] = CryptBitcoin.sign(
            "badaddress#%s/%s" % (user_content["cert_auth_type"], user_content["cert_user_id"]), cert_priv
        )
        signed_content = site.content_manager.sign(
            "data/users/1J6UrZMkarjVg5ax9W4qThir3BFUikbW6C/content.json", user_priv, filewrite=False
        )
        assert not site.content_manager.verifyFile(
            "data/users/1J6UrZMkarjVg5ax9W4qThir3BFUikbW6C/content.json",
            StringIO(json.dumps(signed_content)), ignore_same=False
        )

        # Test banned user, signed by the site owner
        user_content["cert_sign"] = CryptBitcoin.sign("1J6UrZMkarjVg5ax9W4qThir3BFUikbW6C#%s/%s" % (
            user_content["cert_auth_type"],
            user_content["cert_user_id"].split("@")[0]
        ), cert_priv)
        cert_user_id = user_content["cert_user_id"]  # My username
        site.content_manager.contents["data/users/content.json"]["user_contents"]["permissions"][cert_user_id] = False

        site_privatekey = "5KUh3PvNm5HUWoCfSUfcYvfQ2g3PrRNJWr6Q9eqdBGu23mtMntv"  # For 1TeSTvb4w2PWE81S2rEELgmX2GCCExQGT
        del user_content["signs"]  # Remove signs before signing
        user_content["signs"] = {
            "1TeSTvb4w2PWE81S2rEELgmX2GCCExQGT": CryptBitcoin.sign(json.dumps(user_content, sort_keys=True), site_privatekey)
        }
        assert site.content_manager.verifyFile(
            "data/users/1J6UrZMkarjVg5ax9W4qThir3BFUikbW6C/content.json",
            StringIO(json.dumps(user_content)), ignore_same=False
        )

    def testMissingCert(self, site):
        user_priv = "5Kk7FSA63FC2ViKmKLuBxk9gQkaQ5713hKq8LmFAf4cVeXh6K6A"
        cert_priv = "5JusJDSjHaMHwUjDT3o6eQ54pA6poo8La5fAgn1wNc3iK59jxjA"

        user_content = site.content_manager.contents["data/users/1J6UrZMkarjVg5ax9W4qThir3BFUikbW6C/content.json"]
        rules_content = site.content_manager.contents["data/users/content.json"]

        # Override valid cert signers for the test
        rules_content["user_contents"]["cert_signers"]["zeroid.bit"] = [
            "14wgQ4VDDZNoRMFF4yCDuTrBSHmYhL3bet",
            "1iD5ZQJMNXu43w1qLB8sfdHVKppVMduGz"
        ]

        # Sign a valid cert
        user_content["cert_sign"] = CryptBitcoin.sign("1J6UrZMkarjVg5ax9W4qThir3BFUikbW6C#%s/%s" % (
            user_content["cert_auth_type"],
            user_content["cert_user_id"].split("@")[0]
        ), cert_priv)
        signed_content = site.content_manager.sign(
            "data/users/1J6UrZMkarjVg5ax9W4qThir3BFUikbW6C/content.json", user_priv, filewrite=False
        )

        assert site.content_manager.verifyFile(
            "data/users/1J6UrZMkarjVg5ax9W4qThir3BFUikbW6C/content.json",
            StringIO(json.dumps(signed_content)), ignore_same=False
        )

        # Test removed cert
        # user_content["cert_sign"]
        del user_content["cert_auth_type"]
        del user_content["signs"]  # Remove signs before signing
        user_content["signs"] = {
            "1TeSTvb4w2PWE81S2rEELgmX2GCCExQGT": CryptBitcoin.sign(json.dumps(user_content, sort_keys=True), user_priv)
        }
        print "--- Signed content", user_content
        assert not site.content_manager.verifyFile(
            "data/users/1J6UrZMkarjVg5ax9W4qThir3BFUikbW6C/content.json",
            StringIO(json.dumps(user_content)), ignore_same=False
        )


text:
.hover{fill: #eee !important; cursor: pointer !important;}
.no-hover{fill: #fff;}

.axis path{fill: none;stroke:#b6b6b6;shape-rendering: crispEdges;}
div.tooltip { position: absolute; text-align: left; width: 150px; min-height: 30px; padding: 1em; font: 12px sans-serif; background: #efefef; border: 1px solid #dbdbdb; border-radius: 5px; pointer-events: none; color: #000; }


text:
let plus_
let weex_
let BroadcastChannel_

function getRuntime () {
  return typeof window === 'object' && typeof navigator === 'object' && typeof document === 'object' ? 'webview' : 'v8'
}

function getPageId () {
  return plus_.webview.currentWebview().id
}

let channel
let globalEvent
const callbacks = {}

function onPlusMessage (res) {
  const message = res.data && res.data.__message
  if (!message || !message.__page) {
    return
  }
  const pageId = message.__page
  const callback = callbacks[pageId]
  callback && callback(message)
  if (!message.keep) {
    delete callbacks[pageId]
  }
}

function addEventListener (pageId, callback) {
  if (getRuntime() === 'v8') {
    if (BroadcastChannel_) {
      channel && channel.close()
      channel = new BroadcastChannel_(getPageId())
      channel.onmessage = onPlusMessage
    } else if (!globalEvent) {
      globalEvent = weex_.requireModule('globalEvent')
      globalEvent.addEventListener('plusMessage', onPlusMessage)
    }
  } else {
    window.__plusMessage = onPlusMessage
  }
  callbacks[pageId] = callback
}

class Page {
  constructor (webview) {
    this.webview = webview
  }

  sendMessage (data) {
    const message = JSON.parse(JSON.stringify(({
      __message: {
        data
      }
    })))
    const id = this.webview.id
    if (BroadcastChannel_) {
      const channel = new BroadcastChannel_(id)
      channel.postMessage(message)
    } else {
      plus_.webview.postMessageToUniNView(message, id)
    }
  }

  close () {
    this.webview.close()
  }
}

export function showPage ({
  context = {},
  url,
  data = {},
  style = {},
  onMessage,
  onClose
}) {
  // eslint-disable-next-line
  plus_ = context.plus || plus
  // eslint-disable-next-line
  weex_ = context.weex || (typeof weex === 'object' ? weex : null)
  // eslint-disable-next-line
  BroadcastChannel_ = context.BroadcastChannel || (typeof BroadcastChannel === 'object' ? BroadcastChannel : null)
  const titleNView = {
    autoBackButton: true,
    titleSize: '17px'
  }
  const pageId = `page${Date.now()}`
  style = Object.assign({}, style)
  if (style.titleNView !== false && style.titleNView !== 'none') {
    style.titleNView = Object.assign(titleNView, style.titleNView)
  }
  const defaultStyle = {
    top: 0,
    bottom: 0,
    usingComponents: {},
    popGesture: 'close',
    scrollIndicator: 'none',
    animationType: 'pop-in',
    animationDuration: 200,
    uniNView: {
      // eslint-disable-next-line
      path: `${typeof VUE_APP_TEMPLATE_PATH === 'string' ? VUE_APP_TEMPLATE_PATH : ''}/${url}.js`,
      defaultFontSize: 16,
      viewport: plus_.screen.resolutionWidth
    }
  }
  style = Object.assign(defaultStyle, style)
  const page = plus_.webview.create('', pageId, style, {
    extras: {
      from: getPageId(),
      runtime: getRuntime(),
      data,
      useGlobalEvent: !BroadcastChannel_
    }
  })
  page.addEventListener('close', onClose)
  addEventListener(pageId, message => {
    if (typeof onMessage === 'function') {
      onMessage(message.data)
    }
    if (!message.keep) {
      page.close('auto')
    }
  })
  page.show(style.animationType, style.animationDuration)
  return new Page(page)
}


text:
import mq from 'mithril-query';
import m from 'mithril';
import prop from 'mithril/stream';
import {catarse} from '../../src/api';
import adminRadioAction from '../../src/c/admin-radio-action';

describe('AdminRadioAction', () => {
    const testModel = catarse.model('reward_details'),
        testStr = 'updated',
        errorStr = 'error!';

    let error = false,
        item,
        fakeData = {},
        $output;

    let args = {
        getKey: 'project_id',
        updateKey: 'contribution_id',
        selectKey: 'reward_id',
        radios: 'rewards',
        callToAction: 'Alterar Recompensa',
        outerLabel: 'Recompensa',
        getModel: testModel,
        updateModel: testModel,
        validate: () => {
            return undefined;
        }
    };

    let errorArgs = _.extend({}, args, {
        validate: () => {
            return errorStr;
        }
    });

    describe('view', () => {
        beforeAll(() => {
            item = _.first(RewardDetailsMockery());
            args.selectedItem = prop(item);
            $output = mq(adminRadioAction, {
                data: args,
                item: prop(item),
                radios: [{id: 'id', description: 'description'}],
                getKeyValue: () => {},
                updateKeyValue: () => {},
            });
        });

        it('shoud only render the outerLabel on first render', () => {
            expect($output.contains(args.outerLabel)).toBeTrue();
            expect($output.contains(args.callToAction)).toBeFalse();
        });

        describe('on action button click', () => {
            beforeAll(() => {
                $output.click('button');

            });

            it('should render a row of radio inputs', () => {
                const lastRequest = jasmine.Ajax.requests.mostRecent();
                expect($output.find('input[type="radio"]').length).toEqual(JSON.parse(lastRequest.responseText).length);
            });

            it('should render the description of the default selected radio', () => {
                $output.should.contain(item.description);
            });

            it('should send an patch request on form submit', () => {
                $output.click('#r-0');
                $output.trigger('form', 'onsubmit');

                const lastRequest = jasmine.Ajax.requests.mostRecent();
                // Should make a patch request to update item
                expect(lastRequest.method).toEqual('PATCH');
                pending();
            });

            describe('when new value is not valid', () => {
                beforeAll(() => {
                    $output = mq(adminRadioAction, {
                        data: errorArgs,
                        item: prop(item),
                        radios: [{id:item.id}]
                    });
                    $output.click('button');
                    $output.click('#r-0');

                });

                it('should present an error message when new value is invalid', () => {
                    $output.trigger('form', 'onsubmit');
                    $output.should.contain(errorStr);
                });
            });
        });
    });
});


text:
package org.wso2.carbon.apimgt.rest.api.store.dto;

import com.google.gson.annotations.SerializedName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.util.Objects;

/**
 * TagDTO
 */
public class TagDTO   {
  @SerializedName("name")
  private String name = null;

  @SerializedName("weight")
  private Integer weight = null;

  public TagDTO name(String name) {
    this.name = name;
    return this;
  }

   /**
   * Get name
   * @return name
  **/
  @ApiModelProperty(required = true, value = "")
  public String getName() {
    return name;
  }

  public void setName(String name) {
    this.name = name;
  }

  public TagDTO weight(Integer weight) {
    this.weight = weight;
    return this;
  }

   /**
   * Get weight
   * @return weight
  **/
  @ApiModelProperty(required = true, value = "")
  public Integer getWeight() {
    return weight;
  }

  public void setWeight(Integer weight) {
    this.weight = weight;
  }

  @Override
  public boolean equals(java.lang.Object o) {
    if (this == o) {
      return true;
    }
    if (o == null || getClass() != o.getClass()) {
      return false;
    }
    TagDTO tag = (TagDTO) o;
    return Objects.equals(this.name, tag.name) &&
        Objects.equals(this.weight, tag.weight);
  }

  @Override
  public int hashCode() {
    return Objects.hash(name, weight);
  }

  @Override
  public String toString() {
    StringBuilder sb = new StringBuilder();
    sb.append("class TagDTO {\n");

    sb.append("    name: ").append(toIndentedString(name)).append("\n");
    sb.append("    weight: ").append(toIndentedString(weight)).append("\n");
    sb.append("}");
    return sb.toString();
  }

  /**
   * Convert the given object to string with each line indented by 4 spaces
   * (except the first line).
   */
  private String toIndentedString(java.lang.Object o) {
    if (o == null) {
      return "null";
    }
    return o.toString().replace("\n", "\n    ");
  }
}


text:
package org.hisp.dhis.dxf2.metadata.objectbundle.hooks;

import org.hibernate.Session;
import org.hisp.dhis.common.IdentifiableObject;
import org.hisp.dhis.dataelement.DataElementOperand;
import org.hisp.dhis.dataset.DataSet;
import org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundle;
import org.hisp.dhis.period.PeriodType;

import java.util.Map;
import java.util.Set;

/**
 * @author Morten Olav Hansen <mortenoh@gmail.com>
 */
public class DataSetObjectBundleHook extends AbstractObjectBundleHook
{
    @Override
    public void preCreate( IdentifiableObject object, ObjectBundle bundle )
    {
        if ( !DataSet.class.isInstance( object ) ) return;
        DataSet dataSet = (DataSet) object;

        Session session = sessionFactory.getCurrentSession();

        for ( DataElementOperand dataElementOperand : dataSet.getCompulsoryDataElementOperands() )
        {
            preheatService.connectReferences( dataElementOperand, bundle.getPreheat(), bundle.getPreheatIdentifier() );
            session.save( dataElementOperand );
        }

        if ( dataSet.getPeriodType() != null )
        {
            PeriodType periodType = bundle.getPreheat().getPeriodTypeMap().get( dataSet.getPeriodType().getName() );
            dataSet.setPeriodType( periodType );
        }
    }

    @Override
    public void preUpdate( IdentifiableObject object, IdentifiableObject persistedObject, ObjectBundle bundle )
    {
        if ( !DataSet.class.isInstance( object ) ) return;
        DataSet dataSet = (DataSet) object;
        DataSet persistedDataSet = (DataSet) persistedObject;

        dataSet.getCompulsoryDataElementOperands().clear();
        persistedDataSet.getCompulsoryDataElementOperands().clear();

        if ( dataSet.getPeriodType() != null )
        {
            PeriodType periodType = bundle.getPreheat().getPeriodTypeMap().get( dataSet.getPeriodType().getName() );
            dataSet.setPeriodType( periodType );
        }

        sessionFactory.getCurrentSession().flush();
    }

    @Override
    @SuppressWarnings( "unchecked" )
    public void postUpdate( IdentifiableObject persistedObject, ObjectBundle bundle )
    {
        if ( !DataSet.class.isInstance( persistedObject ) ) return;
        if ( !bundle.getObjectReferences().containsKey( DataSet.class ) ) return;
        DataSet dataSet = (DataSet) persistedObject;

        Map<String, Object> references = bundle.getObjectReferences( DataSet.class ).get( dataSet.getUid() );
        if ( references == null ) return;

        Set<DataElementOperand> dataElementOperands = (Set<DataElementOperand>) references.get( "compulsoryDataElementOperands" );
        if ( dataElementOperands == null || dataElementOperands.isEmpty() ) return;

        for ( DataElementOperand dataElementOperand : dataElementOperands )
        {
            preheatService.connectReferences( dataElementOperand, bundle.getPreheat(), bundle.getPreheatIdentifier() );
            sessionFactory.getCurrentSession().save( dataElementOperand );
            dataSet.getCompulsoryDataElementOperands().add( dataElementOperand );
        }

        sessionFactory.getCurrentSession().update( dataSet );
    }
}


text:
using System;

namespace Amazon.Runtime
{
    /// <summary>
    /// The interface for an exception handler.
    /// </summary>
    public interface IExceptionHandler
    {
        /// <summary>
        /// Handles an exception for the given execution context.
        /// </summary>
        /// <param name="executionContext">The execution context, it contains the
        /// request and response context.</param>
        /// <param name="exception">The exception to handle.</param>
        /// <returns>
        /// Returns a boolean value which indicates if the original exception
        /// should be rethrown.
        /// This method can also throw a new exception to replace the original exception.
        /// </returns>
        bool Handle(IExecutionContext executionContext, Exception exception);
    }

    /// <summary>
    /// The interface for an exception handler with a generic parameter for the exception type.
    /// </summary>
    /// <typeparam name="T">The exception type.</typeparam>
    public interface IExceptionHandler<T> : IExceptionHandler where T : Exception
    {
        /// <summary>
        /// Handles an exception for the given execution context.
        /// </summary>
        /// <param name="executionContext">The execution context, it contains the
        /// request and response context.</param>
        /// <param name="exception">The exception to handle.</param>
        /// <returns>
        /// Returns a boolean value which indicates if the original exception
        /// should be rethrown.
        /// This method can also throw a new exception to replace the original exception.
        /// </returns>
        bool HandleException(IExecutionContext executionContext, T exception);
    }
}


text:
PinHead

<button md-raised-button (click)="login()" *ngIf="!(loggedIn$ | async)">Login with Pinterest</button>
<button md-icon-button (click)="logout()" title="Logout of Pinterest" *ngIf="(loggedIn$ | async)">
  power_settings_new
</button>


text:
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include <X11/Xlib.h>
#include <freerdp/utils/sleep.h>

#include "xf_encode.h"

XImage* xf_snapshot(xfPeerContext* xfp, int x, int y, int width, int height)
{
	XImage* image;
	xfInfo* xfi = xfp->info;

	if (xfi->use_xshm)
	{
		pthread_mutex_lock(&(xfp->mutex));

		XCopyArea(xfi->display, xfi->root_window, xfi->fb_pixmap,
				xfi->xdamage_gc, x, y, width, height, x, y);

		XSync(xfi->display, False);

		image = xfi->fb_image;

		pthread_mutex_unlock(&(xfp->mutex));
	}
	else
	{
		pthread_mutex_lock(&(xfp->mutex));

		image = XGetImage(xfi->display, xfi->root_window,
				x, y, width, height, AllPlanes, ZPixmap);

		pthread_mutex_unlock(&(xfp->mutex));
	}

	return image;
}

void xf_xdamage_subtract_region(xfPeerContext* xfp, int x, int y, int width, int height)
{
	XRectangle region;
	xfInfo* xfi = xfp->info;

	region.x = x;
	region.y = y;
	region.width = width;
	region.height = height;

#ifdef WITH_XFIXES
	pthread_mutex_lock(&(xfp->mutex));
	XFixesSetRegion(xfi->display, xfi->xdamage_region, &region, 1);
	XDamageSubtract(xfi->display, xfi->xdamage, xfi->xdamage_region, None);
	pthread_mutex_unlock(&(xfp->mutex));
#endif
}

void* xf_frame_rate_thread(void* param)
{
	xfInfo* xfi;
	xfEvent* event;
	xfPeerContext* xfp;
	freerdp_peer* client;
	uint32 wait_interval;

	client = (freerdp_peer*) param;
	xfp = (xfPeerContext*) client->context;
	xfi = xfp->info;

	wait_interval = 1000000 / xfp->fps;

	while (1)
	{
		// check if we should terminate
		pthread_testcancel();

		event = xf_event_new(XF_EVENT_TYPE_FRAME_TICK);
		xf_event_push(xfp->event_queue, (xfEvent*) event);
		freerdp_usleep(wait_interval);
	}
}

void* xf_monitor_updates(void* param)
{
	int fds;
	xfInfo* xfi;
	XEvent xevent;
	fd_set rfds_set;
	int select_status;
	int pending_events;
	xfPeerContext* xfp;
	freerdp_peer* client;
	uint32 wait_interval;
	struct timeval timeout;
	int x, y, width, height;
	XDamageNotifyEvent* notify;
	xfEventRegion* event_region;

	client = (freerdp_peer*) param;
	xfp = (xfPeerContext*) client->context;
	xfi = xfp->info;

	fds = xfi->xfds;
	wait_interval = (1000000 / 2500);
	memset(&timeout, 0, sizeof(struct timeval));

	pthread_create(&(xfp->frame_rate_thread), 0, xf_frame_rate_thread, (void*) client);

	while (1)
	{
		// check if we should terminate
		pthread_testcancel();

		FD_ZERO(&rfds_set);
		FD_SET(fds, &rfds_set);

		timeout.tv_sec = 0;
		timeout.tv_usec = wait_interval;
		select_status = select(fds + 1, &rfds_set, NULL, NULL, &timeout);

		if (select_status == -1)
		{
			printf("select failed\n");
		}
		else if (select_status == 0)
		{
			//printf("select timeout\n");
		}

		pthread_mutex_lock(&(xfp->mutex));
		pending_events = XPending(xfi->display);
		pthread_mutex_unlock(&(xfp->mutex));

		if (pending_events > 0)
		{
			pthread_mutex_lock(&(xfp->mutex));
			memset(&xevent, 0, sizeof(xevent));
			XNextEvent(xfi->display, &xevent);
			pthread_mutex_unlock(&(xfp->mutex));

			if (xevent.type == xfi->xdamage_notify_event)
			{
				notify = (XDamageNotifyEvent*) &xevent;

				x = notify->area.x;
				y = notify->area.y;
				width = notify->area.width;
				height = notify->area.height;

				xf_xdamage_subtract_region(xfp, x, y, width, height);

				event_region = xf_event_region_new(x, y, width, height);
				xf_event_push(xfp->event_queue, (xfEvent*) event_region);
			}
		}
	}

	return NULL;
}


text:
package org.wikipedia.savedpages;

import org.wikipedia.WikipediaApp;
import org.wikipedia.concurrency.SaneAsyncTask;
import org.wikipedia.page.PageTitle;

import android.util.Log;

public class SavedPageCheckTask extends SaneAsyncTask<Boolean> {
    private final PageTitle title;
    private final WikipediaApp app;

    public SavedPageCheckTask(PageTitle title, WikipediaApp app) {
        this.title = title;
        this.app = app;
    }

    @Override
    public Boolean performTask() throws Throwable {
        return SavedPage.DATABASE_TABLE.savedPageExists(app, title);
    }

    @Override
    public void onCatch(Throwable caught) {
        Log.w("SavedPageCheckTask", "Caught " + caught.getMessage(), caught);
    }
}


text:
(function () {
	angular
		.module('profileApp')
		.factory('office365Factory', office365Factory);

	function office365Factory($log, $http) {
		var office365 = {};

		// Methods
		office365.getUsers = getUsers;
		office365.getDirectReports = getDirectReports;
		office365.getGroups = getGroups;
		office365.getFiles = getFiles;
		office365.getManager = getManager;
		office365.getProfilePicture = getProfilePicture;

		/////////////////////////////////////////
		// End of exposed properties and methods.

		var baseUrl = 'https://graph.microsoft.com/beta';
		var tenantPath = '/' + tenant;

		/**
		 * Gets all users in the tenant.
		 */
		function getUsers() {
			var request = {
				method: 'GET',
				url: baseUrl + tenantPath + '/users'
			};

			return $http(request);
		};

		/**
		 * Gets the user's direct reports.
		 */
		function getDirectReports(objectId) {
			var request = {
				method: 'GET',
				url: baseUrl + tenantPath + '/users/' + objectId + '/directReports'
			};

			return $http(request);
		};

		/**
		 * Gets the groups the user is a member of.
		 */
		function getGroups(objectId) {
			var request = {
				method: 'GET',
				url: baseUrl + tenantPath + '/users/' + objectId + '/memberOf'
			};

			return $http(request);
		};

		/**
		 * Gets the user's files.
		 */
		function getFiles(objectId) {
			var request = {
				method: 'GET',
				url: baseUrl + tenantPath + '/users/' + objectId + '/files'
			};

			return $http(request);
		};

		/**
		 * Gets the user's manager.
		 */
		function getManager(objectId) {
			var request = {
				method: 'GET',
				url: baseUrl + tenantPath + '/users/' + objectId + '/manager'
			};

			return $http(request);
		};

		/**
		 * Gets the user's profile picture.
		 */
		function getProfilePicture(objectId) {
			var request = {
				method: 'GET',
				url: baseUrl + tenantPath + '/users/' + objectId + '/thumbnailPhoto',
				responseType: 'arraybuffer'
			};

			return $http(request);
		};

		return office365;
	};
})();

// *********************************************************
//
// O365-Angular-Profile, https://github.com/OfficeDev/O365-Angular-Profile
//
// Copyright (c) Microsoft Corporation
// All rights reserved.
//
// MIT License:
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
// *********************************************************


text:
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
  <component name="ChangeListManager">
    <list default="true" id="a118c54f-6693-4e4d-ab44-c9ac74223ffc" name="Default" comment="">
      <change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/_posts/2016-12-07-正方教学评价脚本.md" />
      <change type="MODIFICATION" beforePath="$PROJECT_DIR$/.idea/workspace.xml" afterPath="$PROJECT_DIR$/.idea/workspace.xml" />
    </list>
    <ignored path="HelloWorld_Blog.iws" />
    <ignored path=".idea/workspace.xml" />
    <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
    <option name="TRACKING_ENABLED" value="true" />
    <option name="SHOW_DIALOG" value="false" />
    <option name="HIGHLIGHT_CONFLICTS" value="true" />
    <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
    <option name="LAST_RESOLUTION" value="IGNORE" />
  </component>
  <component name="ChangesViewManager" flattened_view="true" show_ignored="false" />
  <component name="CreatePatchCommitExecutor">
    <option name="PATCH_PATH" value="" />
  </component>
  <component name="ExecutionTargetManager" SELECTED_TARGET="default_target" />
  <component name="FavoritesManager">
    <favorites_list name="HelloWorld_Blog" />
  </component>
  <component name="FileEditorManager">
    <leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
      <file leaf-file-name="2016-07-30-iOS 弹出半透明ViewController.md" pinned="false" current-in-tab="false">
        <entry file="file://$PROJECT_DIR$/_posts/2016-07-30-iOS 弹出半透明ViewController.md">
          <provider editor-type-id="MarkdownFxPreviewEditor">
            <state />
          </provider>
          <provider selected="true" editor-type-id="split-provider[text-editor;MarkdownPreviewEditor]">
            <state split_layout="FIRST">
              <first_editor relative-caret-position="459">
                <caret line="27" column="3" selection-start-line="27" selection-start-column="3" selection-end-line="27" selection-end-column="3" />
                <folding />
              </first_editor>
              <second_editor />
            </state>
          </provider>
        </entry>
      </file>
      <file leaf-file-name="2016-12-07-正方教学评价脚本.md" pinned="false" current-in-tab="true">
        <entry file="file://$PROJECT_DIR$/_posts/2016-12-07-正方教学评价脚本.md">
          <provider editor-type-id="MarkdownFxPreviewEditor">
            <state />
          </provider>
          <provider selected="true" editor-type-id="split-provider[text-editor;MarkdownPreviewEditor]">
            <state split_layout="FIRST">
              <first_editor relative-caret-position="289">
                <caret line="17" column="3" selection-start-line="17" selection-start-column="3" selection-end-line="17" selection-end-column="3" />
                <folding />
              </first_editor>
              <second_editor />
            </state>
          </provider>
        </entry>
      </file>
      <file leaf-file-name="2016-07-31-FullStack.md" pinned="false" current-in-tab="false">
        <entry file="file://$PROJECT_DIR$/_posts/2016-07-31-FullStack.md">
          <provider editor-type-id="MarkdownFxPreviewEditor">
            <state />
          </provider>
          <provider selected="true" editor-type-id="split-provider[text-editor;MarkdownPreviewEditor]">
            <state split_layout="FIRST">
              <first_editor relative-caret-position="17">
                <caret line="1" column="0" selection-start-line="1" selection-start-column="0" selection-end-line="7" selection-end-column="16" />
                <folding />
              </first_editor>
              <second_editor />
            </state>
          </provider>
        </entry>
      </file>
      <file leaf-file-name="_config.yml" pinned="false" current-in-tab="false">
        <entry file="file://$PROJECT_DIR$/_config.yml">
          <provider selected="true" editor-type-id="text-editor">
            <state relative-caret-position="697">
              <caret line="41" column="4" selection-start-line="41" selection-start-column="4" selection-end-line="41" selection-end-column="4" />
              <folding />
            </state>
          </provider>
        </entry>
      </file>
      <file leaf-file-name="index.html" pinned="false" current-in-tab="false">
        <entry file="file://$PROJECT_DIR$/index.html">
          <provider selected="true" editor-type-id="text-editor">
            <state relative-caret-position="595">
              <caret line="35" column="21" selection-start-line="35" selection-start-column="21" selection-end-line="35" selection-end-column="21" />
              <folding />
            </state>
          </provider>
        </entry>
      </file>
      <file leaf-file-name="2016-07-21-精致的爱国.md" pinned="false" current-in-tab="false">
        <entry file="file://$PROJECT_DIR$/_posts/2016-07-21-精致的爱国.md">
          <provider editor-type-id="MarkdownFxPreviewEditor">
            <state />
          </provider>
          <provider selected="true" editor-type-id="split-provider[text-editor;MarkdownPreviewEditor]">
            <state split_layout="FIRST">
              <first_editor relative-caret-position="561">
                <caret line="33" column="10" selection-start-line="33" selection-start-column="10" selection-end-line="33" selection-end-column="10" />
                <folding />
              </first_editor>
              <second_editor />
            </state>
          </provider>
        </entry>
      </file>
    </leaf>
  </component>
  <component name="FileTemplateManagerImpl">
    <option name="RECENT_TEMPLATES">
      <list>
        <option value="JavaScript File" />
      </list>
    </option>
  </component>
  <component name="Git.Settings">
    <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
  </component>
  <component name="IdeDocumentHistory">
    <option name="CHANGED_PATHS">
      <list>
        <option value="$PROJECT_DIR$/_includes/head.html" />
        <option value="$PROJECT_DIR$/_posts/2016-07-18-helloWorld.markdown" />
        <option value="$PROJECT_DIR$/_posts/2016-07-18-JavaScript小谈.markdown" />
        <option value="$PROJECT_DIR$/_posts/2016-07-18-全排列算法JavaScript实现.markdown" />
        <option value="$PROJECT_DIR$/index.html" />
        <option value="$PROJECT_DIR$/js/test.js" />
        <option value="$PROJECT_DIR$/_posts/2016-07-20-Pick Peaks.md" />
        <option value="$PROJECT_DIR$/_posts/2016-07-20-JavaScript Functional Programming" />
        <option value="$PROJECT_DIR$/_layouts/default.html" />
        <option value="$PROJECT_DIR$/_layouts/keynote.html" />
        <option value="$PROJECT_DIR$/js/jsmath.js" />
        <option value="$PROJECT_DIR$/_layouts/page.html" />
        <option value="$PROJECT_DIR$/_posts/2016-07-21-爱国主义四个字的第一个字是爱,不是恨.md" />
        <option value="$PROJECT_DIR$/_posts/2016-07-20-JavaScript Functional Programming.md" />
        <option value="$PROJECT_DIR$/_includes/footer.html" />
        <option value="$PROJECT_DIR$/about.html" />
        <option value="$PROJECT_DIR$/_posts/2016-07-21-中国大学的住宿环境到底怎么样.md" />
        <option value="$PROJECT_DIR$/_posts/2016-07-21-精致的爱国.md" />
        <option value="$PROJECT_DIR$/_posts/2016-07-20-JavaScript Functional Programming II.md" />
        <option value="$PROJECT_DIR$/_posts/2016-07-22-JavaScript_Functional_Programming_III.md" />
        <option value="$PROJECT_DIR$/_posts/2016-07-30-iOS 弹出半透明ViewController.md" />
        <option value="$PROJECT_DIR$/_posts/2016-07-31-FullStack.md" />
        <option value="$PROJECT_DIR$/_posts/2016-08-05-常用正则表达式.md" />
        <option value="$PROJECT_DIR$/_layouts/post.html" />
        <option value="$PROJECT_DIR$/_config.yml" />
        <option value="$PROJECT_DIR$/_posts/2016-12-07-正方教学评价脚本.md" />
      </list>
    </option>
  </component>
  <component name="JsBuildToolGruntFileManager" detection-done="true" sorting="DEFINITION_ORDER" />
  <component name="JsBuildToolPackageJson" detection-done="true" sorting="DEFINITION_ORDER" />
  <component name="JsGulpfileManager">
    <detection-done>true</detection-done>
    <sorting>DEFINITION_ORDER</sorting>
  </component>
  <component name="ProjectFrameBounds">
    <option name="x" value="4" />
    <option name="y" value="22" />
    <option name="width" value="1916" />
    <option name="height" value="1058" />
  </component>
  <component name="ProjectLevelVcsManager" settingsEditedManually="false">
    <OptionsSetting value="true" id="Add" />
    <OptionsSetting value="true" id="Remove" />
    <OptionsSetting value="true" id="Checkout" />
    <OptionsSetting value="true" id="Update" />
    <OptionsSetting value="true" id="Status" />
    <OptionsSetting value="true" id="Edit" />
    <ConfirmationsSetting value="0" id="Add" />
    <ConfirmationsSetting value="0" id="Remove" />
  </component>
  <component name="ProjectView">
    <navigator currentView="ProjectPane" proportions="" version="1">
      <flattenPackages />
      <showMembers />
      <showModules />
      <showLibraryContents />
      <hideEmptyPackages />
      <abbreviatePackageNames />
      <autoscrollToSource />
      <autoscrollFromSource />
      <sortByType />
      <manualOrder />
      <foldersAlwaysOnTop value="true" />
    </navigator>
    <panes>
      <pane id="Scope" />
      <pane id="Scratches" />
      <pane id="ProjectPane">
        <subPane>
          <PATH>
            <PATH_ELEMENT>
              <option name="myItemId" value="HelloWorld_Blog" />
              <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
            </PATH_ELEMENT>
          </PATH>
          <PATH>
            <PATH_ELEMENT>
              <option name="myItemId" value="HelloWorld_Blog" />
              <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
            </PATH_ELEMENT>
            <PATH_ELEMENT>
              <option name="myItemId" value="HelloWorld_Blog" />
              <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
            </PATH_ELEMENT>
          </PATH>
          <PATH>
            <PATH_ELEMENT>
              <option name="myItemId" value="HelloWorld_Blog" />
              <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
            </PATH_ELEMENT>
            <PATH_ELEMENT>
              <option name="myItemId" value="HelloWorld_Blog" />
              <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
            </PATH_ELEMENT>
            <PATH_ELEMENT>
              <option name="myItemId" value="_posts" />
              <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
            </PATH_ELEMENT>
          </PATH>
          <PATH>
            <PATH_ELEMENT>
              <option name="myItemId" value="HelloWorld_Blog" />
              <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
            </PATH_ELEMENT>
            <PATH_ELEMENT>
              <option name="myItemId" value="HelloWorld_Blog" />
              <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
            </PATH_ELEMENT>
            <PATH_ELEMENT>
              <option name="myItemId" value="_layouts" />
              <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
            </PATH_ELEMENT>
          </PATH>
        </subPane>
      </pane>
    </panes>
  </component>
  <component name="PropertiesComponent">
    <property name="last_opened_file_path" value="$PROJECT_DIR$/../tmp" />
    <property name="WebServerToolWindowFactoryState" value="false" />
    <property name="HbShouldOpenHtmlAsHb" value="" />
    <property name="js-jscs-nodeInterpreter" value="/usr/local/bin/node" />
    <property name="settings.editor.selected.configurable" value="reference.settingsdialog.IDE.editor.colors" />
    <property name="settings.editor.splitter.proportion" value="0.2" />
  </component>
  <component name="RecentsManager">
    <key name="MoveFile.RECENT_KEYS">
      <recent name="$PROJECT_DIR$/img/2016-07" />
      <recent name="$PROJECT_DIR$/_posts" />
      <recent name="$PROJECT_DIR$/img" />
    </key>
    <key name="CopyFile.RECENT_KEYS">
      <recent name="$PROJECT_DIR$/img" />
      <recent name="$PROJECT_DIR$/_includes" />
      <recent name="$PROJECT_DIR$" />
    </key>
  </component>
  <component name="RunManager" selected="JavaScript Debug.footer.html">
    <configuration default="false" name="footer.html" type="JavascriptDebugType" factoryName="JavaScript Debug" temporary="true" nameIsGenerated="true" uri="http://localhost:63342/HelloWorld_Blog/_includes/footer.html">
      <method />
    </configuration>
    <configuration default="true" type="DartCommandLineRunConfigurationType" factoryName="Dart Command Line Application">
      <method />
    </configuration>
    <configuration default="true" type="DartTestRunConfigurationType" factoryName="Dart Test">
      <method />
    </configuration>
    <configuration default="true" type="JavaScriptTestRunnerKarma" factoryName="Karma">
      <config-file value="" />
      <node-interpreter value="project" />
      <envs />
      <method />
    </configuration>
    <configuration default="true" type="JavascriptDebugType" factoryName="JavaScript Debug">
      <method />
    </configuration>
    <configuration default="true" type="NodeJSConfigurationType" factoryName="Node.js" path-to-node="project" working-dir="">
      <method />
    </configuration>
    <configuration default="true" type="cucumber.js" factoryName="Cucumber.js">
      <option name="cucumberJsArguments" value="" />
      <option name="executablePath" />
      <option name="filePath" />
      <method />
    </configuration>
    <configuration default="true" type="js.build_tools.gulp" factoryName="Gulp.js">
      <node-interpreter>project</node-interpreter>
      <node-options />
      <gulpfile />
      <tasks />
      <arguments />
      <envs />
      <method />
    </configuration>
    <configuration default="true" type="js.build_tools.npm" factoryName="npm">
      <command value="run-script" />
      <scripts />
      <node-interpreter value="project" />
      <envs />
      <method />
    </configuration>
    <configuration default="true" type="mocha-javascript-test-runner" factoryName="Mocha">
      <node-interpreter>project</node-interpreter>
      <node-options />
      <working-directory />
      <pass-parent-env>true</pass-parent-env>
      <envs />
      <ui>bdd</ui>
      <extra-mocha-options />
      <test-kind>DIRECTORY</test-kind>
      <test-directory />
      <recursive>false</recursive>
      <method />
    </configuration>
    <list size="1">
      <item index="0" class="java.lang.String" itemvalue="JavaScript Debug.footer.html" />
    </list>
    <recent_temporary>
      <list size="1">
        <item index="0" class="java.lang.String" itemvalue="JavaScript Debug.footer.html" />
      </list>
    </recent_temporary>
  </component>
  <component name="ShelveChangesManager" show_recycled="false">
    <option name="remove_strategy" value="false" />
  </component>
  <component name="SvnConfiguration">
    <configuration />
  </component>
  <component name="TaskManager">
    <task active="true" id="Default" summary="Default task">
      <changelist id="a118c54f-6693-4e4d-ab44-c9ac74223ffc" name="Default" comment="" />
      <created>1468910690091</created>
      <option name="number" value="Default" />
      <option name="presentableId" value="Default" />
      <updated>1468910690091</updated>
      <workItem from="1468910692495" duration="1702000" />
      <workItem from="1469007392146" duration="26737000" />
      <workItem from="1469076061193" duration="19309000" />
      <workItem from="1469856614516" duration="5325000" />
      <workItem from="1470365505205" duration="8050000" />
      <workItem from="1471401732196" duration="918000" />
      <workItem from="1472385978566" duration="210000" />
      <workItem from="1474873415422" duration="707000" />
      <workItem from="1475076941242" duration="634000" />
      <workItem from="1481109340834" duration="979000" />
    </task>
    <servers />
  </component>
  <component name="TimeTrackingManager">
    <option name="totallyTimeSpent" value="74843000" />
  </component>
  <component name="ToolWindowManager">
    <frame x="4" y="22" width="1916" height="1058" extended-state="6" />
    <editor active="true" />
    <layout>
      <window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.30636743" sideWeight="0.5" order="0" side_tool="false" content_ui="combo" />
      <window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
      <window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="7" side_tool="true" content_ui="tabs" />
      <window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="9" side_tool="false" content_ui="tabs" />
      <window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
      <window_info id="Terminal" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="8" side_tool="false" content_ui="tabs" />
      <window_info id="Favorites" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="true" content_ui="tabs" />
      <window_info id="Cvs" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" />
      <window_info id="Message" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
      <window_info id="Commander" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
      <window_info id="Inspection" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" />
      <window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
      <window_info id="Hierarchy" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="2" side_tool="false" content_ui="combo" />
      <window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
      <window_info id="Ant Build" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
      <window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
    </layout>
    <layout-to-restore>
      <window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
      <window_info id="Cvs" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" />
      <window_info id="Message" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
      <window_info id="Commander" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
      <window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="7" side_tool="true" content_ui="tabs" />
      <window_info id="Inspection" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" />
      <window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="9" side_tool="false" content_ui="tabs" />
      <window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
      <window_info id="Terminal" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="8" side_tool="false" content_ui="tabs" />
      <window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.14583333" sideWeight="0.5" order="0" side_tool="false" content_ui="combo" />
      <window_info id="Hierarchy" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="2" side_tool="false" content_ui="combo" />
      <window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
      <window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
      <window_info id="Ant Build" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
      <window_info id="Favorites" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="true" content_ui="tabs" />
      <window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
    </layout-to-restore>
  </component>
  <component name="Vcs.Log.UiProperties">
    <option name="RECENTLY_FILTERED_USER_GROUPS">
      <collection />
    </option>
    <option name="RECENTLY_FILTERED_BRANCH_GROUPS">
      <collection />
    </option>
  </component>
  <component name="VcsContentAnnotationSettings">
    <option name="myLimit" value="2678400000" />
  </component>
  <component name="XDebuggerManager">
    <breakpoint-manager />
    <watches-manager />
  </component>
  <component name="editorHistoryManager">
    <entry file="file://$PROJECT_DIR$/_posts/2015-07-09-js-module-7day.markdown">
      <provider editor-type-id="MarkdownFxPreviewEditor">
        <state />
      </provider>
      <provider selected="true" editor-type-id="split-provider[text-editor;MarkdownPreviewEditor]">
        <state split_layout="FIRST">
          <first_editor relative-caret-position="0">
            <caret line="15" column="0" selection-start-line="15" selection-start-column="0" selection-end-line="15" selection-end-column="0" />
          </first_editor>
          <second_editor />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/js/test.js">
      <provider selected="true" editor-type-id="text-editor">
        <state relative-caret-position="357">
          <caret line="23" column="15" selection-start-line="23" selection-start-column="15" selection-end-line="23" selection-end-column="15" />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/_posts/2015-05-25-js-module-loader.markdown">
      <provider editor-type-id="MarkdownFxPreviewEditor">
        <state />
      </provider>
      <provider selected="true" editor-type-id="split-provider[text-editor;MarkdownPreviewEditor]">
        <state split_layout="FIRST">
          <first_editor relative-caret-position="204">
            <caret line="12" column="0" selection-start-line="12" selection-start-column="0" selection-end-line="12" selection-end-column="0" />
          </first_editor>
          <second_editor />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/_posts/2016-07-18-JavaScript小谈.markdown">
      <provider editor-type-id="MarkdownFxPreviewEditor">
        <state />
      </provider>
      <provider selected="true" editor-type-id="split-provider[text-editor;MarkdownPreviewEditor]">
        <state split_layout="FIRST">
          <first_editor relative-caret-position="663">
            <caret line="39" column="38" selection-start-line="39" selection-start-column="38" selection-end-line="39" selection-end-column="38" />
          </first_editor>
          <second_editor />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/css/_site/pygments.css">
      <provider selected="true" editor-type-id="text-editor">
        <state relative-caret-position="0">
          <caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/css/bootstrap.css">
      <provider selected="true" editor-type-id="text-editor">
        <state relative-caret-position="0">
          <caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/css/hux-blog.css">
      <provider selected="true" editor-type-id="text-editor">
        <state relative-caret-position="0">
          <caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/css/hux-blog.min.css">
      <provider selected="true" editor-type-id="text-editor">
        <state relative-caret-position="0">
          <caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/_posts/2016-07-18-helloWorld.markdown">
      <provider editor-type-id="MarkdownFxPreviewEditor">
        <state />
      </provider>
      <provider selected="true" editor-type-id="split-provider[text-editor;MarkdownPreviewEditor]">
        <state split_layout="FIRST">
          <first_editor relative-caret-position="-520">
            <caret line="3" column="22" selection-start-line="3" selection-start-column="0" selection-end-line="4" selection-end-column="0" />
          </first_editor>
          <second_editor />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/css/pygments.css">
      <provider selected="true" editor-type-id="text-editor">
        <state relative-caret-position="0">
          <caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/js/jsmath.js">
      <provider selected="true" editor-type-id="text-editor">
        <state relative-caret-position="17">
          <caret line="3" column="1" selection-start-line="3" selection-start-column="1" selection-end-line="3" selection-end-column="1" />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/_posts/2015-09-22-js-version.markdown">
      <provider editor-type-id="MarkdownFxPreviewEditor">
        <state />
      </provider>
      <provider selected="true" editor-type-id="split-provider[text-editor;MarkdownPreviewEditor]">
        <state split_layout="FIRST">
          <first_editor relative-caret-position="102">
            <caret line="6" column="5" selection-start-line="6" selection-start-column="0" selection-end-line="7" selection-end-column="0" />
          </first_editor>
          <second_editor />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/_posts/2016-07-18-全排列算法JavaScript实现.markdown">
      <provider editor-type-id="MarkdownFxPreviewEditor">
        <state />
      </provider>
      <provider selected="true" editor-type-id="split-provider[text-editor;MarkdownPreviewEditor]">
        <state split_layout="FIRST">
          <first_editor relative-caret-position="45">
            <caret line="3" column="5" selection-start-line="3" selection-start-column="5" selection-end-line="3" selection-end-column="5" />
          </first_editor>
          <second_editor />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/img/post-bg-unix-linux.jpg">
      <provider selected="true" editor-type-id="images">
        <state />
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/_includes/head.html">
      <provider selected="true" editor-type-id="text-editor">
        <state relative-caret-position="404">
          <caret line="41" column="0" selection-start-line="41" selection-start-column="0" selection-end-line="41" selection-end-column="0" />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/_includes/nav.html">
      <provider selected="true" editor-type-id="text-editor">
        <state relative-caret-position="-650">
          <caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/_includes/footer.html">
      <provider selected="true" editor-type-id="text-editor">
        <state relative-caret-position="183">
          <caret line="74" column="0" selection-start-line="74" selection-start-column="0" selection-end-line="74" selection-end-column="0" />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/about.html">
      <provider selected="true" editor-type-id="text-editor">
        <state relative-caret-position="51">
          <caret line="3" column="0" selection-start-line="3" selection-start-column="0" selection-end-line="3" selection-end-column="0" />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/img/about-bg.jpg">
      <provider selected="true" editor-type-id="images">
        <state />
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/img/avatar-hux.jpg" />
    <entry file="file://$PROJECT_DIR$/img/avatar.jpg">
      <provider selected="true" editor-type-id="images">
        <state />
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/img/favicon.ico">
      <provider selected="true" editor-type-id="images">
        <state />
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/img/home-bg.jpg">
      <provider selected="true" editor-type-id="images">
        <state />
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/img/home-bg-o.jpg">
      <provider selected="true" editor-type-id="images">
        <state />
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/img/icon_wechat.png">
      <provider selected="true" editor-type-id="images">
        <state />
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/img/post-bg-2015.jpg">
      <provider selected="true" editor-type-id="images">
        <state />
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/img/contact-bg.jpg">
      <provider selected="true" editor-type-id="images">
        <state />
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/less/variables.less">
      <provider selected="true" editor-type-id="text-editor">
        <state relative-caret-position="0">
          <caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/school.jpg" />
    <entry file="file://$PROJECT_DIR$/_posts/2016-07-20-JavaScript Functional Programming.md">
      <provider editor-type-id="MarkdownFxPreviewEditor">
        <state />
      </provider>
      <provider selected="true" editor-type-id="split-provider[text-editor;MarkdownPreviewEditor]">
        <state split_layout="FIRST">
          <first_editor relative-caret-position="5474">
            <caret line="322" column="9" selection-start-line="322" selection-start-column="9" selection-end-line="322" selection-end-column="9" />
          </first_editor>
          <second_editor />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/_posts/2016-07-20-Pick Peaks.md">
      <provider editor-type-id="MarkdownFxPreviewEditor">
        <state />
      </provider>
      <provider selected="true" editor-type-id="split-provider[text-editor;MarkdownPreviewEditor]">
        <state split_layout="FIRST">
          <first_editor relative-caret-position="187">
            <caret line="11" column="3" selection-start-line="11" selection-start-column="3" selection-end-line="11" selection-end-column="3" />
          </first_editor>
          <second_editor />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/_posts/2016-07-20-JavaScript Functional Programming II.md">
      <provider editor-type-id="MarkdownFxPreviewEditor">
        <state />
      </provider>
      <provider selected="true" editor-type-id="split-provider[text-editor;MarkdownPreviewEditor]">
        <state split_layout="FIRST">
          <first_editor relative-caret-position="7939">
            <caret line="467" column="18" selection-start-line="467" selection-start-column="18" selection-end-line="467" selection-end-column="18" />
          </first_editor>
          <second_editor />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/_posts/2016-07-22-JavaScript_Functional_Programming_III.md">
      <provider editor-type-id="MarkdownFxPreviewEditor">
        <state />
      </provider>
      <provider selected="true" editor-type-id="split-provider[text-editor;MarkdownPreviewEditor]">
        <state split_layout="FIRST">
          <first_editor relative-caret-position="0">
            <caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="9" selection-end-column="3" />
          </first_editor>
          <second_editor />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/img/2016-07/catmap copy.png">
      <provider selected="true" editor-type-id="images">
        <state />
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/img/2016-07/cat_theory.png">
      <provider selected="true" editor-type-id="images">
        <state />
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/img/2016-07/cat_comp2.png">
      <provider selected="true" editor-type-id="images">
        <state />
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/_posts/2016-07-21-中国大学的住宿环境到底怎么样.md">
      <provider editor-type-id="MarkdownFxPreviewEditor">
        <state />
      </provider>
      <provider selected="true" editor-type-id="split-provider[text-editor;MarkdownPreviewEditor]">
        <state split_layout="FIRST">
          <first_editor relative-caret-position="153">
            <caret line="9" column="4" selection-start-line="9" selection-start-column="4" selection-end-line="9" selection-end-column="4" />
          </first_editor>
          <second_editor />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/README.md">
      <provider editor-type-id="MarkdownFxPreviewEditor">
        <state />
      </provider>
      <provider selected="true" editor-type-id="split-provider[text-editor;MarkdownPreviewEditor]">
        <state split_layout="FIRST">
          <first_editor relative-caret-position="0">
            <caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
            <folding />
          </first_editor>
          <second_editor />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/README.zh.md">
      <provider editor-type-id="MarkdownFxPreviewEditor">
        <state />
      </provider>
      <provider selected="true" editor-type-id="split-provider[text-editor;MarkdownPreviewEditor]">
        <state split_layout="FIRST">
          <first_editor relative-caret-position="0">
            <caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
            <folding />
          </first_editor>
          <second_editor />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/_layouts/default.html">
      <provider selected="true" editor-type-id="text-editor">
        <state relative-caret-position="102">
          <caret line="6" column="0" selection-start-line="6" selection-start-column="0" selection-end-line="6" selection-end-column="0" />
          <folding />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/_layouts/keynote.html">
      <provider selected="true" editor-type-id="text-editor">
        <state relative-caret-position="204">
          <caret line="12" column="16" selection-start-line="12" selection-start-column="16" selection-end-line="12" selection-end-column="16" />
          <folding />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/_layouts/page.html">
      <provider selected="true" editor-type-id="text-editor">
        <state relative-caret-position="238">
          <caret line="14" column="45" selection-start-line="14" selection-start-column="45" selection-end-line="14" selection-end-column="45" />
          <folding />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/_layouts/post.html">
      <provider selected="true" editor-type-id="text-editor">
        <state relative-caret-position="691">
          <caret line="124" column="0" selection-start-line="124" selection-start-column="0" selection-end-line="124" selection-end-column="0" />
          <folding />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/_config.yml">
      <provider selected="true" editor-type-id="text-editor">
        <state relative-caret-position="697">
          <caret line="41" column="4" selection-start-line="41" selection-start-column="4" selection-end-line="41" selection-end-column="4" />
          <folding />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/index.html">
      <provider selected="true" editor-type-id="text-editor">
        <state relative-caret-position="595">
          <caret line="35" column="21" selection-start-line="35" selection-start-column="21" selection-end-line="35" selection-end-column="21" />
          <folding />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/_posts/2015-04-14-unix-linux-note.markdown">
      <provider editor-type-id="MarkdownFxPreviewEditor">
        <state />
      </provider>
      <provider selected="true" editor-type-id="split-provider[text-editor;MarkdownPreviewEditor]">
        <state split_layout="FIRST">
          <first_editor relative-caret-position="0">
            <caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="11" selection-end-column="3" />
            <folding />
          </first_editor>
          <second_editor />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/_posts/2016-07-31-FullStack.md">
      <provider editor-type-id="MarkdownFxPreviewEditor">
        <state />
      </provider>
      <provider selected="true" editor-type-id="split-provider[text-editor;MarkdownPreviewEditor]">
        <state split_layout="FIRST">
          <first_editor relative-caret-position="17">
            <caret line="1" column="0" selection-start-line="1" selection-start-column="0" selection-end-line="7" selection-end-column="16" />
            <folding />
          </first_editor>
          <second_editor />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/_posts/2016-07-21-精致的爱国.md">
      <provider editor-type-id="MarkdownFxPreviewEditor">
        <state />
      </provider>
      <provider selected="true" editor-type-id="split-provider[text-editor;MarkdownPreviewEditor]">
        <state split_layout="FIRST">
          <first_editor relative-caret-position="561">
            <caret line="33" column="10" selection-start-line="33" selection-start-column="10" selection-end-line="33" selection-end-column="10" />
            <folding />
          </first_editor>
          <second_editor />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/_posts/2016-07-30-iOS 弹出半透明ViewController.md">
      <provider editor-type-id="MarkdownFxPreviewEditor">
        <state />
      </provider>
      <provider selected="true" editor-type-id="split-provider[text-editor;MarkdownPreviewEditor]">
        <state split_layout="FIRST">
          <first_editor relative-caret-position="459">
            <caret line="27" column="3" selection-start-line="27" selection-start-column="3" selection-end-line="27" selection-end-column="3" />
            <folding />
          </first_editor>
          <second_editor />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/_posts/2016-08-05-常用正则表达式.md">
      <provider editor-type-id="MarkdownFxPreviewEditor">
        <state />
      </provider>
      <provider selected="true" editor-type-id="split-provider[text-editor;MarkdownPreviewEditor]">
        <state split_layout="FIRST">
          <first_editor relative-caret-position="872">
            <caret line="183" column="0" selection-start-line="183" selection-start-column="0" selection-end-line="183" selection-end-column="0" />
            <folding />
          </first_editor>
          <second_editor />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/_posts/2016-12-07-正方教学评价脚本.md">
      <provider editor-type-id="MarkdownFxPreviewEditor">
        <state />
      </provider>
      <provider selected="true" editor-type-id="split-provider[text-editor;MarkdownPreviewEditor]">
        <state split_layout="FIRST">
          <first_editor relative-caret-position="289">
            <caret line="17" column="3" selection-start-line="17" selection-start-column="3" selection-end-line="17" selection-end-column="3" />
            <folding />
          </first_editor>
          <second_editor />
        </state>
      </provider>
    </entry>
  </component>
</project>


text:
(function() {
	"use strict";

	var module = angular.module( "ng-i18n-node", [] );

	module.factory( "httpInterceptor", ["$log", "$q", function( $log, $q ) {
		var httpInterceptor = {
			request       : function( config ) {
				if( config.url.match( /^\/i18n\// ) ) {
					$log.debug( "Intercepting /i18n/ request..." );
					config.i18nRequest = true;

					var isRequestForLiteral = config.url.match( /^\/i18n\/\w+\/\w+/ );

					if( isRequestForLiteral ) {
						var literalMatch = /^\/i18n\/\w+\/([^\/]+)/.exec( config.url );
						var requestedLiteral = literalMatch[ 1 ];
						var readableLiteral = decodeURIComponent( requestedLiteral );
						config.i18nLiteral = readableLiteral;
						return $q.reject( config );

					} else {
						var localeMatch = /^\/i18n\/([^\/]+)/.exec( config.url );
						var locale = localeMatch[ 1 ];
						config.url = "i18n/" + locale + ".json";
					}

					config.config = config;
					return config;
				}
				return config;
			},
			responseError : function( rejection ) {
				if( rejection.i18nRequest ) {
					$log.debug( "Handling rejected /i18n/ interception..." );

					var dataToReturn = "";
					var isRequestForLiteral = rejection.url.match( /^\/i18n\/\w+\/\w+/ );
					if( isRequestForLiteral ) {
						var literalMatch = /^\/i18n\/\w+\/([^\/]+)/.exec( rejection.url );
						var requestedLiteral = literalMatch[ 1 ];
						var readableLiteral = decodeURIComponent( requestedLiteral );

						dataToReturn = readableLiteral;

						httpInterceptor.untranslated = httpInterceptor.untranslated || {};
						httpInterceptor.untranslated[ readableLiteral ] = readableLiteral;
						httpInterceptor.flushUntranslated();
						$log.warn( "UNTRANSLATED LITERAL", readableLiteral );

					} else {
						// Requests for locale packages should have been handled by "request" interceptor.
						dataToReturn = {};
					}

					return {
						data       : dataToReturn,
						status     : 200,
						headers    : null,
						config     : rejection.config,
						statusText : "OK"
					};
				}
				// We MUST use $q.reject here, otherwise the intercepted response will later be treated as successful.
				// This affects ALL requests made through $http!
				return $q.reject( rejection );
			},

			flushUntranslated : function(){
				$log.info( JSON.stringify( httpInterceptor.untranslated ) );
			}
		};

		return httpInterceptor;
	}] );

	module.config( ["$httpProvider", function( $httpProvider ) {
		$httpProvider.interceptors.push( "httpInterceptor" );
	}] );
}());