text:
// ImageListView - A listview control for image files
// Copyright (C) 2009 Ozgur Ozcitak
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Ozgur Ozcitak (ozcitak@yahoo.com)

#if DEBUG
using System;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;

namespace Manina.Windows.Forms
{
    /// <summary>
    /// Represents a renderer meant to be used for debugging purposes.
    /// Included in the debug build only.
    /// </summary>
    public class DebugRenderer : ImageListView.ImageListViewRenderer
    {
        private long baseMem;

        /// <summary>
        /// Initializes a new instance of the DebugRenderer class.
        /// </summary>
        public DebugRenderer()
        {
            Process p = Process.GetCurrentProcess();
            p.Refresh();
            baseMem = p.PrivateMemorySize64;
        }
        /// <summary>
        /// Draws the specified item on the given graphics.
        /// </summary>
        /// <param name="g">The System.Drawing.Graphics to draw on.</param>
        /// <param name="item">The ImageListViewItem to draw.</param>
        /// <param name="state">The current view state of item.</param>
        /// <param name="bounds">The bounding rectangle of item in client coordinates.</param>
        public override void DrawItem(Graphics g, ImageListViewItem item, ItemState state, Rectangle bounds)
        {
            if (item.Index == mImageListView.layoutManager.FirstPartiallyVisible ||
                item.Index == mImageListView.layoutManager.LastPartiallyVisible)
            {
                using (Brush b = new HatchBrush(HatchStyle.BackwardDiagonal, Color.Green, Color.Transparent))
                {
                    g.FillRectangle(b, bounds);
                }
            }
            if (item.Index == mImageListView.layoutManager.FirstVisible ||
                item.Index == mImageListView.layoutManager.LastVisible)
            {
                using (Brush b = new HatchBrush(HatchStyle.ForwardDiagonal, Color.Red, Color.Transparent))
                {
                    g.FillRectangle(b, bounds);
                }
            }

            base.DrawItem(g, item, state, bounds);
        }
        /// <summary>
        /// Draws an overlay image over the client area.
        /// </summary>
        /// <param name="g">The System.Drawing.Graphics to draw on.</param>
        /// <param name="bounds">The bounding rectangle of the client area.</param>
        public override void DrawOverlay(Graphics g, Rectangle bounds)
        {
            // Refresh process info
            Process p = Process.GetCurrentProcess();
            p.Refresh();
            long mem = Math.Max(0, p.PrivateMemorySize64 - baseMem);

            // Display memory stats
            string s = string.Format("Total: {0}\r\nCache: {1}\r\nCache*: {2}", Utility.FormatSize(baseMem), Utility.FormatSize(mem), Utility.FormatSize(mImageListView.cacheManager.MemoryUsed));
            SizeF sz = g.MeasureString(s, ImageListView.Font);
            Rectangle r = new Rectangle(ItemAreaBounds.Right - 120, ItemAreaBounds.Top + 5, 115, (int)sz.Height);
            using (Brush b = new SolidBrush(Color.FromArgb(220, Color.LightGray)))
            {
                g.FillRectangle(b, r);
            }
            using (Pen pen = new Pen(Color.FromArgb(128, Color.Gray)))
            {
                g.DrawRectangle(pen, r);
            }
            g.DrawString(s, ImageListView.Font, Brushes.Black, r.Location);

            // Display navigation parameters
            r = new Rectangle(ItemAreaBounds.Right - 120, ItemAreaBounds.Top + 5 + (int)sz.Height + 10, 115, 125);
            using (Brush b = new SolidBrush(Color.FromArgb(220, Color.LightGray)))
            {
                g.FillRectangle(b, r);
            }
            using (Pen pen = new Pen(Color.FromArgb(128, Color.Gray)))
            {
                g.DrawRectangle(pen, r);
            }

            // Is left button down?
            r = new Rectangle(r.Left + 5, r.Top + 5, 15, 15);
            if (mImageListView.navigationManager.LeftButton)
            {
                g.FillRectangle(Brushes.DarkGray, r);
            }
            g.DrawRectangle(Pens.Black, r);
            r.Offset(15, 0);
            r.Offset(15, 0);

            // Is right button down?
            if (mImageListView.navigationManager.RightButton)
            {
                g.FillRectangle(Brushes.DarkGray, r);
            }
            g.DrawRectangle(Pens.Black, r);
            r.Offset(-30, 22);

            // Is shift key down?
            Color tColor = Color.Gray;
            if (mImageListView.navigationManager.ShiftKey)
                tColor = Color.Black;
            using (Brush b = new SolidBrush(tColor))
            {
                g.DrawString("Shift", mImageListView.Font, b, r.Location);
            }
            r.Offset(0, 12);

            // Is control key down?
            tColor = Color.Gray;
            if (mImageListView.navigationManager.ControlKey)
                tColor = Color.Black;
            using (Brush b = new SolidBrush(tColor))
            {
                g.DrawString("Control", mImageListView.Font, b, r.Location);
            }
            r.Offset(0, 20);

            // Display hit test details for item area
            ImageListView.HitInfo h = null;
            mImageListView.HitTest(mImageListView.PointToClient(Control.MousePosition), out h);

            tColor = Color.Gray;
            if (h.InItemArea)
                tColor = Color.Black;
            using (Brush b = new SolidBrush(tColor))
            {
                g.DrawString("InItemArea (" + h.ItemIndex.ToString() + ")", mImageListView.Font, b, r.Location);
            }
            r.Offset(0, 12);

            // Display hit test details for column header area
            tColor = Color.Gray;
            if (h.InHeaderArea)
                tColor = Color.Black;
            using (Brush b = new SolidBrush(tColor))
            {
                g.DrawString("InHeaderArea (" + h.ColumnIndex.ToString() + ")", mImageListView.Font, b, r.Location);
            }
            r.Offset(0, 12);

            // Display hit test details for pane area
            tColor = Color.Gray;
            if (h.InPaneArea)
                tColor = Color.Black;
            using (Brush b = new SolidBrush(tColor))
            {
                g.DrawString("InPaneArea " + (h.PaneBorder ? " (Border)" : ""), mImageListView.Font, b, r.Location);
            }
            r.Offset(0, 12);
        }
    }
}
#endif


text:
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using Fluent.Zip;
using Orchard;
using Orchard.Environment.Extensions;
using Vandelay.Industries.Models;
using Path = Fluent.IO.Path;

namespace Vandelay.Industries.Services {
    public interface ILocalizationManagementService : IDependency {
        void InstallTranslation(byte[] zippedTranslation, string sitePath);
        byte[] PackageTranslations(string cultureCode, string sitePath);
        byte[] PackageTranslations(string cultureCode, string sitePath, IEnumerable<string> extensionNames);
        byte[] ExtractDefaultTranslation(string sitePath);
        byte[] ExtractDefaultTranslation(string sitePath, IEnumerable<string> extensionNames);
        void SyncTranslation(string sitePath, string cultureCode);
    }

    [OrchardFeature("Vandelay.TranslationManager")]
    public class LocalizationManagementService : ILocalizationManagementService {
        private static readonly Regex NamespaceExpression =
            new Regex(
                @"namespace ([^\s]*)\s*{",
                RegexOptions.Multiline | RegexOptions.Compiled);

        private static readonly Regex ClassExpression =
            new Regex(
                @"\s?class ([^\s]*)\s",
                RegexOptions.Multiline | RegexOptions.Compiled);

        public void InstallTranslation(byte[] zippedTranslation, string sitePath) {
            var siteRoot = Path.Get(sitePath);
            ZipExtensions.Unzip(zippedTranslation,
                (path, contents) => {
                    if (path.Extension == ".po") {
                        var tokens = path.Tokens;
                        var destPath = siteRoot.Combine(tokens);
                        // If a translation file is for a module or a theme, only install it
                        // if said module or theme exists already. Otherwise, skip.
                        if ((!tokens[0].Equals("modules", StringComparison.OrdinalIgnoreCase) &&
                             !tokens[0].Equals("themes", StringComparison.OrdinalIgnoreCase)) ||
                              siteRoot.Combine(tokens[0], tokens[1]).IsDirectory) {
                            destPath.Write(contents);
                        }
                    }
                });
        }

        public byte[] PackageTranslations(string cultureCode, string sitePath) {
            var site = Path.Get(sitePath);
            var translationFiles = site
                .Files("orchard.*.po", true)
                .Where(p => p.Parent().FileName.Equals(cultureCode, StringComparison.OrdinalIgnoreCase))
                .MakeRelativeTo(site);
            return ZipExtensions.Zip(
                translationFiles,
                p => site.Combine(p).ReadBytes());
        }

        public byte[] PackageTranslations(string cultureCode, string sitePath, IEnumerable<string> extensionNames) {
            var site = Path.Get(sitePath);
            var translationFiles = site
                .Files("orchard.*.po", true)
                .Where(p =>
                       extensionNames != null &&
                       (p.Parent().FileName.Equals(cultureCode, StringComparison.OrdinalIgnoreCase) &&
                        (extensionNames.Contains(p.MakeRelativeTo(site.Combine("Modules")).Tokens[0], StringComparer.OrdinalIgnoreCase) ||
                         extensionNames.Contains(p.MakeRelativeTo(site.Combine("Themes")).Tokens[0], StringComparer.OrdinalIgnoreCase))))
                .MakeRelativeTo(site);
            return ZipExtensions.Zip(
                translationFiles,
                p => site.Combine(p).ReadBytes());
        }

        public byte[] ExtractDefaultTranslation(string sitePath, IEnumerable<string> extensionNames) {
            if (extensionNames == null || extensionNames.Count() == 0) {
                return ExtractDefaultTranslation(sitePath);
            }
            var site = Path.Get(sitePath);
            var zipFiles = new Dictionary<Path, StringBuilder>();
            // Extract resources for module manifests
            site.Files("module.txt", true)
                .Where(p => extensionNames.Contains(p.Parent().FileName, StringComparer.OrdinalIgnoreCase))
                .Read((content, path) => {
                    var moduleName = path.Parent().FileName;
                    var poPath = GetModuleLocalizationPath(site, moduleName);
                    ExtractPoFromManifest(zipFiles, poPath, content, path, site);
                });
            // Extract resources for theme manifests
            site.Files("theme.txt", true)
                .Where(p => extensionNames.Contains(p.Parent().FileName, StringComparer.OrdinalIgnoreCase))
                .Read((content, path) => {
                    var themeName = path.Parent().FileName;
                    var poPath = GetThemeLocalizationPath(site, themeName);
                    ExtractPoFromManifest(zipFiles, poPath, content, path, site);
                });
            // Extract resources from views and cs files
            site.Files("*", true)
                .WhereExtensionIs(".cshtml", ".aspx", ".ascx", ".cs")
                .Where(p => {
                           var tokens = p.MakeRelativeTo(site).Tokens;
                           return new[] {"themes", "modules"}.Contains(tokens[0], StringComparer.OrdinalIgnoreCase) &&
                                  extensionNames.Contains(tokens[1], StringComparer.OrdinalIgnoreCase);
                       })
                .Read((contents, path) => ExtractResourcesFromCode(contents, null, null, site, path, zipFiles));
            return ZipExtensions.Zip(
                new Path(zipFiles.Keys.Select(p => p.MakeRelativeTo(site))),
                p => Encoding.UTF8.GetBytes(zipFiles[site.Combine(p)].ToString()));
        }

        private void ExtractResourcesFromCode(string contents, Path corePoPath, Path rootPoPath, Path site, Path path, Dictionary<Path, StringBuilder> zipFiles) {
            foreach (var str in FindLocalizedStrings(contents)) {
                DispatchResourceString(zipFiles, corePoPath, rootPoPath, site, path, site, contents, '"' + str + '"');
            }
            foreach (var str in FindLocalizedStrings(contents, "T.Plural(", true)) {
                DispatchResourceString(zipFiles, corePoPath, rootPoPath, site, path, site, contents, '"' + str + '"');
            }
        }

        public byte[] ExtractDefaultTranslation(string sitePath) {
            var site = Path.Get(sitePath);
            var corePoPath = site.Combine(
                "Core", "App_Data",
                "Localization", "en-US",
                "orchard.core.po");
            var rootPoPath = site.Combine(
                "App_Data", "Localization", "en-US",
                "orchard.root.po");
            var zipFiles = new Dictionary<Path, StringBuilder>();
            // Extract resources for module manifests
            site.Files("module.txt", true)
                .Read((content, path) => {
                    var moduleName = path.Parent().FileName;
                    var poPath =
                        path.MakeRelativeTo(sitePath).Tokens[0].Equals("core", StringComparison.OrdinalIgnoreCase) ?
                             corePoPath : GetModuleLocalizationPath(site, moduleName);
                    ExtractPoFromManifest(zipFiles, poPath, content, path, site);
                });
            // Extract resources for theme manifests
            site.Files("theme.txt", true)
                .Read((content, path) => {
                    var themeName = path.Parent().FileName;
                    var poPath = GetThemeLocalizationPath(site, themeName);
                    ExtractPoFromManifest(zipFiles, poPath, content, path, site);
                });
            // Extract resources from views and cs files, for the web site
            // as well as for the framework and Azure projects.
            site/*.Add(site.Parent().Combine("Orchard"))
                .Add(site.Parent().Combine("Orchard.Azure"))*/
                .ForEach(p =>
                         p.Files("*", true)
                             .WhereExtensionIs(".cshtml", ".aspx", ".ascx", ".cs")
                             .Read((contents, path) => ExtractResourcesFromCode(contents, corePoPath, rootPoPath, site, path, zipFiles)));
            return ZipExtensions.Zip(
                new Path(zipFiles.Keys.Select(p => p.MakeRelativeTo(site))),
                p => Encoding.UTF8.GetBytes(zipFiles[site.Combine(p)].ToString()));
        }

        public void SyncTranslation(string sitePath, string cultureCode) {
            Path.Get(sitePath)
                .Files("orchard.*.po", true)
                .Where(p => p.Parent().FileName.Equals("en-US", StringComparison.OrdinalIgnoreCase))
                .ForEach(baselinePath => {
                             var path = baselinePath.Parent().Parent().Combine(cultureCode, baselinePath.FileName);
                             var translations = new List<StringEntry>();
                             if (path.Exists) {
                                 path.Open(inStream => ReadTranslations(inStream, translations), FileMode.Open, FileAccess.Read, FileShare.Read);
                             }
                             path.Parent().CreateDirectory();
                             path.Open(outStream => {
                                           var englishTranslations = new List<StringEntry>();
                                           baselinePath.Open(baselineStream => ReadTranslations(baselineStream, englishTranslations), FileMode.Open, FileAccess.Read, FileShare.Read);
                                           using (var writer = new StreamWriter(outStream)) {
                                               foreach (var englishTranslation in englishTranslations) {
                                                   var entry = englishTranslation;
                                                   var translation = translations.Where(
                                                       t => t.Context == entry.Context &&
                                                            t.Key == entry.Key).FirstOrDefault();
                                                   if (translation == default(StringEntry) ||
                                                       translation.Translation == null ||
                                                       translation.Translation.Equals(@"msgstr """"")) {

                                                       writer.WriteLine("# Untranslated string");
                                                   }
                                                   writer.WriteLine(entry.Context);
                                                   writer.WriteLine(entry.Key);
                                                   writer.WriteLine(entry.English);
                                                   if (translation != null) {
                                                       translation.Used = true;
                                                       writer.WriteLine(translation.Translation);
                                                   }
                                                   else {
                                                       writer.WriteLine("msgstr \"\"");
                                                   }
                                                   writer.WriteLine();
                                               }
                                               foreach (var translation in translations.Where(t => !t.Used)) {
                                                   writer.WriteLine("# Obsolete translation");
                                                   writer.WriteLine(translation.Context);
                                                   writer.WriteLine(translation.Key);
                                                   writer.WriteLine(translation.English);
                                                   writer.WriteLine(translation.Translation);
                                                   writer.WriteLine();
                                               }
                                           }
                                       }, FileMode.Create, FileAccess.Write, FileShare.None);
                         });
        }

        private static void ReadTranslations(FileStream inStream, List<StringEntry> translations) {
            var translation = new StringEntry();
            var comparer = new StringEntryEqualityComparer();
            using (var reader = new StreamReader(inStream)) {
                while (!reader.EndOfStream) {
                    var line = reader.ReadLine();
                    if (line != null) {
                        if (line.StartsWith("#: ")) {
                            translation.Context = line;
                        }
                        if (line.StartsWith("msgctxt ")) {
                            translation.Context = line;
                        }
                        else if (line.StartsWith("#| msgid ")) {
                            translation.Key = line;
                        }
                        else if (line.StartsWith("msgid ")) {
                            translation.English = line;
                        }
                        else if (line.StartsWith("msgstr ")) {
                            translation.Translation = line;
                            if (!translations.Contains(translation, comparer)) {
                                translations.Add(translation);
                            }
                            translation = new StringEntry();
                        }
                    }
                }
            }
        }

        private static StringBuilder GetBuilder(IDictionary<Path, StringBuilder> fileCatalog, Path path) {
            StringBuilder entry;
            if (!fileCatalog.ContainsKey(path)) {
                entry = new StringBuilder();
                fileCatalog.Add(path, entry);
            }
            else {
                entry = fileCatalog[path];
            }
            return entry;
        }

        private static void DispatchResourceString(
            IDictionary<Path, StringBuilder> fileCatalog,
            Path corePoPath,
            Path rootPoPath,
            Path sitePath,
            Path path,
            Path currentInputPath,
            string contents, string str) {

            var current = "~/" + path.MakeRelativeTo(currentInputPath).ToString().Replace('\\', '/');
            var context = current;
            if (path.Extension == ".cs") {
                var ns = NamespaceExpression.Match(contents).Groups[1].ToString();
                var type = ClassExpression.Match(contents).Groups[1].ToString();
                context = ns + "." + type;
            }
            Path targetPath;
            if (current.StartsWith("~/core/", StringComparison.OrdinalIgnoreCase)) {
                targetPath = corePoPath;
            }
            else if (current.StartsWith("~/themes/", StringComparison.OrdinalIgnoreCase)) {
                targetPath = GetThemeLocalizationPath(sitePath, current.Substring(9, current.IndexOf('/', 9) - 9));
            }
            else if (current.StartsWith("~/modules/", StringComparison.OrdinalIgnoreCase)) {
                targetPath = GetModuleLocalizationPath(sitePath, current.Substring(10, current.IndexOf('/', 10) - 10));
            }
            else {
                targetPath = rootPoPath;
            }
            WriteResourceString(GetBuilder(fileCatalog, targetPath), context, str);
        }

        private static readonly Regex FeatureNameExpression = new Regex(@"^\s+([^\s:]+):\s*$");

        private static void ExtractPoFromManifest(
            IDictionary<Path, StringBuilder> fileCatalog,
            Path poPath,
            string manifest,
            Path manifestPath,
            Path rootPath) {

            var context = "~/" + manifestPath.MakeRelativeTo(rootPath).ToString()
                                     .Replace('\\', '/');
            var reader = new StringReader(manifest);
            var builder = GetBuilder(fileCatalog, poPath);
            string line;
            while ((line = reader.ReadLine()) != null) {
                var split = line.Split(new[] {':'}, 2, StringSplitOptions.RemoveEmptyEntries)
                    .Select(s => s.Trim()).ToArray();
                if (split.Length == 2) {
                    var key = split[0];
                    if (new[] {"Name", "Description", "Author", "Website", "Tags"}.Contains(key)) {
                        var value = split[1];
                        WriteResourceString(
                            builder,
                            context,
                            '"' + key + '"',
                            '"' + value + '"');
                    }
                }
                if (line.StartsWith("Features:")) {
                    var feature = "";
                    while ((line = reader.ReadLine()) != null) {
                        var match = FeatureNameExpression.Match(line);
                        if (match.Success) {
                            feature = match.Groups[1].Value;
                            continue;
                        }
                        split = line.Split(new[] { ':' }, 2, StringSplitOptions.RemoveEmptyEntries)
                            .Select(s => s.Trim()).ToArray();
                        if (split.Length != 2) continue;
                        var key = split[0];
                        if (new[] { "Name", "Description", "Category" }.Contains(key)) {
                            var value = split[1];
                            WriteResourceString(
                                builder,
                                context,
                                '"' + feature + '.' + key + "\"",
                                '"' + value + '"');
                        }
                    }
                }
            }
        }

        private static Path GetThemeLocalizationPath(Path siteRoot, string themeName) {
            return siteRoot.Combine(
                "Themes", themeName, "App_Data",
                "Localization", "en-US",
                "orchard.theme.po");
        }

        private static Path GetModuleLocalizationPath(Path siteRoot, string moduleName) {
            return siteRoot.Combine(
                "Modules", moduleName, "App_Data",
                "Localization", "en-US",
                "orchard.module.po");
        }

        private static void WriteResourceString(StringBuilder builder, string context, string value) {
             WriteResourceString(builder, context, value, value);
        }

        private static void WriteResourceString(StringBuilder builder, string context, string key, string value) {
            builder.AppendLine("#: " + context);
            builder.AppendLine("#| msgid " + key);
            builder.AppendLine("msgctxt " + context);
            builder.AppendLine("msgid " + value);
            builder.AppendLine("msgstr " + value);
            builder.AppendLine();
        }

        public static IEnumerable<string> FindLocalizedStrings(string csharp, string prefix = "T(", bool fetchTwoStrings = false) {
            // This will fail on some carefully crafted comments such as /* T("ha ha! */. Well, yeah.
            var current = 0;
            var gotOne = false;
            while (current >=0 && current < csharp.Length) {
                var nextT = current;
                if (!fetchTwoStrings || !gotOne) {
                    // Look for next prefix.
                    nextT = csharp.IndexOf(prefix, current);
                    if (nextT == -1) yield break; // prefix not found, we're done.
                    nextT += prefix.Length; // skip prefix.
                }
                var quote = csharp.IndexOf('"', nextT); // Where's the next quote?
                if (quote == -1) yield break; // None found, we're done.
                var between = csharp.Substring(nextT, quote - nextT).Replace(" ", "");
                if (between != "" && between != "@" && !(fetchTwoStrings && gotOne && (between == "," || between == ",@"))) {
                    // stuff found between prefix and string, skip this to next prefix.
                    current = nextT + 1;
                    continue;
                }
                nextT = quote;
                // We should be in position to find the string, and on the opening quote.
                if (csharp[nextT - 1] == '@'
                    && csharp.Length > nextT + 1) { // @"..." string.
                    var nextQuote = nextT + 1;
                    while (nextQuote >= 0 && nextQuote < csharp.Length) {
                        nextQuote = csharp.IndexOf('"', nextQuote);
                        if (nextQuote != -1
                            && csharp.Length > nextQuote + 1
                            && csharp[nextQuote + 1] == '"') { // This is a double-quote, don't stop here.
                            nextQuote += 2; // Skip that double-quote.
                            continue;
                        }
                        if (nextQuote != -1) { // Found the end of the string.
                            yield return csharp.Substring(nextT + 1, nextQuote - nextT - 1);
                            current = nextQuote + 1; // prepare to find next string.
                            gotOne = !gotOne; // If dealing with plural we need to prepare to find the second string, or switch back to finding the prefix.
                            break;
                        }
                        yield break;
                    }
                } else {
                    var nextQuote = nextT + 1;
                    while (nextQuote >= 0 && nextQuote < csharp.Length) {
                        nextQuote = csharp.IndexOf('"', nextQuote);
                        if (nextQuote != -1
                            && csharp[nextQuote - 1] == '\\') { // This is an escaped string, don't stop there.
                            nextQuote++;
                            continue;
                        }
                        if (nextQuote != -1) { // Found the end of the string.
                            yield return csharp.Substring(nextT + 1, nextQuote - nextT - 1);
                            current = nextQuote + 1; // prepare to find next string.
                            gotOne = !gotOne; // If dealing with plural we need to prepare to find the second string, or switch back to finding the prefix.
                            break;
                        }
                        yield break;
                    }
                }
                if (nextT == -1) yield break;
            }
        }
    }
}

redpajama_set_name: RedPajamaGithub


text:
'use strict';
require('es6-promise').polyfill();
/*
cd src/main/webapp/WEB-INF/views
npm install --save es6-promise \
gulp-csscomb gulp-uglify gulp-clean-css gulp-htmlclean gulp-group-css-media-queries gulp-concat gulp-autoprefixer gulp-rigger gulp-rename gulp-imagemin gulp-flatten
*/

var gulp = require('gulp'),
    csscomb = require('gulp-csscomb'),
    minifyJS = require('gulp-uglify'),
    minifyCSS = require('gulp-clean-css'),
    minifyHTML = require('gulp-htmlclean'),
    gcmq = require('gulp-group-css-media-queries'),
    concat = require('gulp-concat'),
    autoprefixer = require('gulp-autoprefixer'),
    rigger = require('gulp-rigger'),
    rename = require("gulp-rename"),
    imagemin = require('gulp-imagemin'),
    flatten = require('gulp-flatten');

gulp.task('style', function () {
    var files = [
        'bundles/common.css',
        'blocks/menu/menu.css',
        'blocks/*.css',
        'bundles/button.css',
        'bundles/**/*.css',
        'blocks/**/*.css'
    ];
    gulp.src(files)
        //.pipe(autoprefixer({browsers: ['last 20 versions']}))
        //.pipe(minifyCSS({compatibility: 'ie8'}))
        .pipe(concat('style.css'))
        .pipe(gcmq())
        .pipe(gulp.dest('../../builds'));
});

gulp.task('script', function () {
    var files = [
        'libjs/**',
        'bundles/common.js',
        'bundles/**/*.js',
        'blocks/**/*.js'
    ];
    gulp.src(files)
        //.pipe(minifyJS())
        .pipe(concat('script.js'))
        .pipe(gulp.dest('../../builds'));
});

gulp.task('images', function () {
    return gulp.src('blocks/**/*.{jpg,jpeg,png,gif}')
        .pipe(imagemin({
            optimizationLevel: 3,
            progessive: true,
            interlaced: true
        }))
        .pipe(flatten())
        .pipe(gulp.dest('../../images'));
});

gulp.task('default', ['style', 'script', 'images']);

gulp.task('watch', function () {
    gulp.watch([
        './bundles/**/*.css',
        './blocks/**/*.css',
        './bundles/**/*.js',
        './blocks/**/*.js',
        './bundles/**/*.html',
        './blocks/**/*.html'
    ], function (event) {
        gulp.run(['style', 'script']);
    });
});


text:
<Namespace Name="Banshee.Playlist">
  <Docs>
    <summary>To be added.</summary>
    <remarks>To be added.</remarks>
  </Docs>
</Namespace>


text:
ludum30_a_hole_new_world_binaries
=================================
Binaries for the game "A Hole New World"

Windows executable (full screen) https://github.com/jjhaggar/ludum30_a_hole_new_world_binaries/raw/master/A_Hole_New_World_(full_screen).exe

Windows executable (windowed) https://github.com/jjhaggar/ludum30_a_hole_new_world_binaries/raw/master/A_Hole_New_World_(windowed).exe

Jar executable - Multiplattform (Linux / Mac / Windows) https://github.com/jjhaggar/ludum30_a_hole_new_world_binaries/raw/master/A_Hole_New_World.jar

A Hole New World ia an Open Source Game (here are the sources https://github.com/jjhaggar/ludum30_a_hole_new_world) made with Java and libGDX (http://libgdx.badlogicgames.com/) for Ludum Dare 30 Jam http://www.ludumdare.com/compo/

Game made by DanPelGar (Daniel Pellicer), Virako (Victor Ramirez), Otaruk (Alvaro Fernandez), Xanday (Miguel Murat) y JJHaggar (Juan Jesus Ligero). Music and sounds by Estudio EverGreen (DanPelGar).

Windows binaries wrapped using Launch4j http://launch4j.sourceforge.net

License
-------

Code released under the [Apache License](LICENSE).

All sounds, music and graphics are licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.


text:
namespace crypto {

namespace {

std::string HexEncodeString(const std::string& binary_data) {
  return base::HexEncode(binary_data.c_str(), binary_data.size());
}

bool RunExchange(P224EncryptedKeyExchange* client,
                 P224EncryptedKeyExchange* server,
                 bool is_password_same) {
  for (;;) {
    std::string client_message, server_message;
    client_message = client->GetNextMessage();
    server_message = server->GetNextMessage();

    P224EncryptedKeyExchange::Result client_result, server_result;
    client_result = client->ProcessMessage(server_message);
    server_result = server->ProcessMessage(client_message);

    // Check that we never hit the case where only one succeeds.
    EXPECT_EQ(client_result == P224EncryptedKeyExchange::kResultSuccess,
              server_result == P224EncryptedKeyExchange::kResultSuccess);

    if (client_result == P224EncryptedKeyExchange::kResultFailed ||
        server_result == P224EncryptedKeyExchange::kResultFailed) {
      return false;
    }

    EXPECT_EQ(is_password_same,
              client->GetUnverifiedKey() == server->GetUnverifiedKey());

    if (client_result == P224EncryptedKeyExchange::kResultSuccess &&
        server_result == P224EncryptedKeyExchange::kResultSuccess) {
      return true;
    }

    EXPECT_EQ(P224EncryptedKeyExchange::kResultPending, client_result);
    EXPECT_EQ(P224EncryptedKeyExchange::kResultPending, server_result);
  }
}

const char kPassword[] = "foo";

}  // namespace

TEST(MutualAuth, CorrectAuth) {
  P224EncryptedKeyExchange client(
      P224EncryptedKeyExchange::kPeerTypeClient, kPassword);
  P224EncryptedKeyExchange server(
      P224EncryptedKeyExchange::kPeerTypeServer, kPassword);

  EXPECT_TRUE(RunExchange(&client, &server, true));
  EXPECT_EQ(client.GetKey(), server.GetKey());
}

TEST(MutualAuth, IncorrectPassword) {
  P224EncryptedKeyExchange client(
      P224EncryptedKeyExchange::kPeerTypeClient,
      kPassword);
  P224EncryptedKeyExchange server(
      P224EncryptedKeyExchange::kPeerTypeServer,
      "wrongpassword");

  EXPECT_FALSE(RunExchange(&client, &server, false));
}

TEST(MutualAuth, ExpectedValues) {
  P224EncryptedKeyExchange client(P224EncryptedKeyExchange::kPeerTypeClient,
                                  kPassword);
  client.SetXForTesting("Client x");
  P224EncryptedKeyExchange server(P224EncryptedKeyExchange::kPeerTypeServer,
                                  kPassword);
  server.SetXForTesting("Server x");

  std::string client_message = client.GetNextMessage();
  EXPECT_EQ(
      "3508EF7DECC8AB9F9C439FBB0154288BBECC0A82E8448F4CF29554EB"
      "BE9D486686226255EAD1D077C635B1A41F46AC91D7F7F32CED9EC3E0",
      HexEncodeString(client_message));

  std::string server_message = server.GetNextMessage();
  EXPECT_EQ(
      "A3088C18B75D2C2B107105661AEC85424777475EB29F1DDFB8C14AFB"
      "F1603D0DF38413A00F420ACF2059E7997C935F5A957A193D09A2B584",
      HexEncodeString(server_message));

  EXPECT_EQ(P224EncryptedKeyExchange::kResultPending,
            client.ProcessMessage(server_message));
  EXPECT_EQ(P224EncryptedKeyExchange::kResultPending,
            server.ProcessMessage(client_message));

  EXPECT_EQ(client.GetUnverifiedKey(), server.GetUnverifiedKey());
  // Must stay the same. External implementations should be able to pair with.
  EXPECT_EQ(
      "CE7CCFC435CDA4F01EC8826788B1F8B82EF7D550A34696B371096E64"
      "C487D4FE193F7D1A6FF6820BC7F807796BA3889E8F999BBDEFC32FFA",
      HexEncodeString(server.GetUnverifiedKey()));

  EXPECT_TRUE(RunExchange(&client, &server, true));
  EXPECT_EQ(client.GetKey(), server.GetKey());
}

TEST(MutualAuth, Fuzz) {
  static const unsigned kIterations = 40;

  for (unsigned i = 0; i < kIterations; i++) {
    P224EncryptedKeyExchange client(
        P224EncryptedKeyExchange::kPeerTypeClient, kPassword);
    P224EncryptedKeyExchange server(
        P224EncryptedKeyExchange::kPeerTypeServer, kPassword);

    // We'll only be testing small values of i, but we don't want that to bias
    // the test coverage. So we disperse the value of i by multiplying by the
    // FNV, 32-bit prime, producing a simplistic PRNG.
    const uint32_t rand = i * 16777619;

    for (unsigned round = 0;; round++) {
      std::string client_message, server_message;
      client_message = client.GetNextMessage();
      server_message = server.GetNextMessage();

      if ((rand & 1) == round) {
        const bool server_or_client = rand & 2;
        std::string* m = server_or_client ? &server_message : &client_message;
        if (rand & 4) {
          // Truncate
          *m = m->substr(0, (i >> 3) % m->size());
        } else {
          // Corrupt
          const size_t bits = m->size() * 8;
          const size_t bit_to_corrupt = (rand >> 3) % bits;
          const_cast<char*>(m->data())[bit_to_corrupt / 8] ^=
              1 << (bit_to_corrupt % 8);
        }
      }

      P224EncryptedKeyExchange::Result client_result, server_result;
      client_result = client.ProcessMessage(server_message);
      server_result = server.ProcessMessage(client_message);

      // If we have corrupted anything, we expect the authentication to fail,
      // although one side can succeed if we happen to corrupt the second round
      // message to the other.
      ASSERT_FALSE(
          client_result == P224EncryptedKeyExchange::kResultSuccess &&
          server_result == P224EncryptedKeyExchange::kResultSuccess);

      if (client_result == P224EncryptedKeyExchange::kResultFailed ||
          server_result == P224EncryptedKeyExchange::kResultFailed) {
        break;
      }

      ASSERT_EQ(P224EncryptedKeyExchange::kResultPending,
                client_result);
      ASSERT_EQ(P224EncryptedKeyExchange::kResultPending,
                server_result);
    }
  }
}

}  // namespace crypto


text:
// PerspectivePanel.cs, 07.11.2019
// Copyright (C) Dominic Beger 07.11.2019

using System.Windows.Forms;

namespace SharpMath._3DTest
{
    public class PerspectivePanel : Panel
    {
        public PerspectivePanel()
        {
            SetStyle(
                ControlStyles.AllPaintingInWmPaint | ControlStyles.OptimizedDoubleBuffer | ControlStyles.ResizeRedraw |
                ControlStyles.SupportsTransparentBackColor, true);
            UpdateStyles();
        }
    }
}