text:
package org.apache.cassandra.db.commitlog;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.apache.cassandra.net.MessagingService;

public class CommitLogDescriptor
{
    private static final String SEPARATOR = "-";
    private static final String FILENAME_PREFIX = "CommitLog" + SEPARATOR;
    private static final String FILENAME_EXTENSION = ".log";
    // match both legacy and new version of commitlogs Ex: CommitLog-12345.log and CommitLog-4-12345.log.
    private static final Pattern COMMIT_LOG_FILE_PATTERN = Pattern.compile(FILENAME_PREFIX + "((\\d+)(" + SEPARATOR + "\\d+)?)" + FILENAME_EXTENSION);

    public static final int LEGACY_VERSION = 1;
    public static final int VERSION_12 = 2;
    /**
     * Increment this number if there is a changes in the commit log disc layout or MessagingVersion changes.
     * Note: make sure to handle {@link #getMessagingVersion()}
     */
    public static final int current_version = VERSION_12;

    private final int version;
    public final long id;

    public CommitLogDescriptor(int version, long id)
    {
        this.version = version;
        this.id = id;
    }

    public CommitLogDescriptor(long id)
    {
        this(current_version, id);
    }

    public static CommitLogDescriptor fromFileName(String name)
    {
        Matcher matcher;
        if (!(matcher = COMMIT_LOG_FILE_PATTERN.matcher(name)).matches())
            throw new RuntimeException("Cannot parse the version of the file: " + name);

        if (matcher.group(3) != null)
        {
            long id = Long.parseLong(matcher.group(3).split(SEPARATOR)[1]);
            return new CommitLogDescriptor(Integer.parseInt(matcher.group(2)), id);
        }
        else
        {
            long id = Long.parseLong(matcher.group(1));
            return new CommitLogDescriptor(LEGACY_VERSION, id);
        }
    }

    public int getMessagingVersion()
    {
        assert MessagingService.current_version == MessagingService.VERSION_12;
        switch (version)
        {
            case LEGACY_VERSION:
                return MessagingService.VERSION_11;
            case VERSION_12:
                return MessagingService.VERSION_12;
            default:
                throw new IllegalStateException("Unknown commitlog version " + version);
        }
    }

    public String fileName()
    {
        return FILENAME_PREFIX + version + SEPARATOR + id + FILENAME_EXTENSION;
    }

    /**
     * @param   filename  the filename to check
     * @return true if filename could be a commit log based on it's filename
     */
    public static boolean isValid(String filename)
    {
        return COMMIT_LOG_FILE_PATTERN.matcher(filename).matches();
    }
}


text:
import {Action} from "../entities/redux";
import {UNDO, REDO, HISTORY_ADD_GROUP} from "./actions";
import {HISTORY_RENAME_GROUP} from "./actions";

export function undo(): Action {
    return {
        type: UNDO
    };
}

export function redo(): Action {
    return {
        type: REDO
    };
}

export function addGroup(): Action {
    return {
        type: HISTORY_ADD_GROUP
    };
}

export function changeGroup(id: number, name: string, description: string): Action {
    return {
        type: HISTORY_RENAME_GROUP,
        payload: {
            id,
            name,
            description
        }
    };
}

redpajama_set_name: RedPajamaGithub


text:
from __future__ import unicode_literals

from django.db import models, migrations

class Migration(migrations.Migration):

    dependencies = [
        ('cbh_datastore_model', '0014_auto_20150819_1503'),
    ]

    operations = [
        migrations.AddField(
            model_name='datapointclassification',
            name='parent',
            field=models.ForeignKey(related_name='children', default=None,
                                    to='cbh_datastore_model.DataPointClassification', null=True),
            preserve_default=True,
        ),
    ]


text:
#include "fw_dunit.hpp"
#include <ace/OS.h>
#include <ace/High_Res_Timer.h>
#include <string>

#define ROOT_NAME "ThinClientSSLAuthUntrusted"
#define ROOT_SCOPE DISTRIBUTED_ACK

#include "CacheHelper.hpp"

using namespace apache::geode::client;
using namespace test;

CacheHelper* cacheHelper = nullptr;
bool isLocalServer = false;

static bool isLocator = false;
const char* locatorsG =
    CacheHelper::getLocatorHostPort(isLocator, isLocalServer, 1);

#define CLIENT1 s1p1
#define SERVER1 s2p1

void initClient(const bool isthinClient) {
  if (cacheHelper == nullptr) {
    auto props = Properties::create();
    props->insert("ssl-enabled", "true");
    std::string keystore = std::string(ACE_OS::getenv("TESTSRC")) + "/keystore";
    std::string pubkey = keystore + "/client_truststore.pem";
    std::string privkey = keystore + "/client_keystore_untrusted.pem";
    props->insert("ssl-keystore", privkey.c_str());
    props->insert("ssl-keystore-password", "secret");
    props->insert("ssl-truststore", pubkey.c_str());
    cacheHelper = new CacheHelper(isthinClient, props);
  }
  ASSERT(cacheHelper, "Failed to create a CacheHelper client instance.");
}
void cleanProc() {
  if (cacheHelper != nullptr) {
    delete cacheHelper;
    cacheHelper = nullptr;
  }
}

CacheHelper* getHelper() {
  ASSERT(cacheHelper != nullptr, "No cacheHelper initialized.");
  return cacheHelper;
}

void createPooledRegion(const char* name, bool ackMode, const char* locators,
                        const char* poolname,
                        bool clientNotificationEnabled = false,
                        bool cachingEnable = true) {
  LOG("createRegion_Pool() entered.");
  fprintf(stdout, "Creating region --  %s  ackMode is %d\n", name, ackMode);
  fflush(stdout);
  auto regPtr =
      getHelper()->createPooledRegion(name, ackMode, locators, poolname,
                                      cachingEnable, clientNotificationEnabled);
  ASSERT(regPtr != nullptr, "Failed to create region.");
  LOG("Pooled Region created.");
}

void createEntry(const char* name, const char* key, const char* value) {
  LOG("createEntry() entered.");
  fprintf(stdout, "Creating entry -- key: %s  value: %s in region %s\n", key,
          value, name);
  fflush(stdout);
  // Create entry, verify entry is correct
  auto keyPtr = createKey(key);
  auto valPtr = CacheableString::create(value);

  auto regPtr = getHelper()->getRegion(name);
  ASSERT(regPtr != nullptr, "Region not found.");

  ASSERT(!regPtr->containsKey(keyPtr),
         "Key should not have been found in region.");
  ASSERT(!regPtr->containsValueForKey(keyPtr),
         "Value should not have been found in region.");

  // regPtr->create( keyPtr, valPtr );
  regPtr->put(keyPtr, valPtr);
  LOG("Created entry.");

  // verifyEntry(name, key, value);
  LOG("Entry created.");
}

const char* keys[] = {"Key-1", "Key-2", "Key-3", "Key-4"};
const char* vals[] = {"Value-1", "Value-2", "Value-3", "Value-4"};
const char* nvals[] = {"New Value-1", "New Value-2", "New Value-3",
                       "New Value-4"};

const char* regionNames[] = {"DistRegionAck", "DistRegionNoAck"};

const bool USE_ACK = true;
const bool NO_ACK = false;

DUNIT_TASK_DEFINITION(SERVER1, CreateLocator1_With_SSL_untrustedCert)
  {
    // starting locator
    if (isLocator) CacheHelper::initLocator(1, true, false, -1, 0, false);
    LOG("Locator1 started with SSL");
  }
END_TASK_DEFINITION

DUNIT_TASK_DEFINITION(SERVER1, CreateServer1_With_Locator_And_SSL_untrustedCert)
  {
    // starting servers
    if (isLocalServer)
      CacheHelper::initServer(1, nullptr, locatorsG, nullptr, true, true, false,
                              false, false);
  }
END_TASK_DEFINITION

DUNIT_TASK_DEFINITION(CLIENT1, CreateClient1)
  { initClient(true); }
END_TASK_DEFINITION

DUNIT_TASK_DEFINITION(CLIENT1, CreateRegions1_PoolLocators)
  {
    createPooledRegion(regionNames[0], USE_ACK, locatorsG, "__TESTPOOL1_",
                       true);
    createPooledRegion(regionNames[1], NO_ACK, locatorsG, "__TESTPOOL1_", true);
    auto regPtr = getHelper()->getRegion(regionNames[0]);
    try {
      regPtr->registerAllKeys(false, false, false);
      FAIL("Should have got NotConnectedException during registerAllKeys");
    } catch (NotConnectedException exp) {
      LOG("Connection Failed as expected via NotConnectedException");
    }
    LOG("CreateRegions1_PoolLocators complete.");
  }
END_TASK_DEFINITION

DUNIT_TASK_DEFINITION(CLIENT1, CloseCache1)
  { cleanProc(); }
END_TASK_DEFINITION

DUNIT_TASK_DEFINITION(SERVER1, CloseServer1)
  {
    if (isLocalServer) {
      CacheHelper::closeServer(1);
      LOG("SERVER1 stopped");
    }
  }
END_TASK_DEFINITION

DUNIT_TASK_DEFINITION(SERVER1, CloseLocator_With_SSL)
  {
    // stop locator
    if (isLocator) {
      CacheHelper::closeLocator(1, true);
      LOG("Locator1 stopped");
    }
  }
END_TASK_DEFINITION

DUNIT_MAIN
  {
    CALL_TASK(CreateLocator1_With_SSL_untrustedCert);
    CALL_TASK(CreateServer1_With_Locator_And_SSL_untrustedCert)

    CALL_TASK(CreateClient1);

    CALL_TASK(CreateRegions1_PoolLocators);

    CALL_TASK(CloseCache1);
    CALL_TASK(CloseServer1);

    CALL_TASK(CloseLocator_With_SSL);
  }
END_MAIN


text:
"define metadata";
({
    "dependencies": {
        "settings": "0.0.0"
    }
});
"end";

var util = require('bespin:util/util');
var console = require('bespin:console').console;
var catalog = require("bespin:plugins").catalog;
var settings = require('settings').settings;

/**
 * The environment plays a similar role to the environment under unix.
 * Bespin does not currently have a concept of variables, (i.e. things the user
 * directly changes, however it does have a number of pre-defined things that
 * are changed by the system.
 *
The role of the Environment is likely to be expanded over time.
 */
exports.Environment = function() {
    // The current command line pushes this value into here
    this.commandLine = null;

    // Fire the sizeChanged event when the window is resized.
    window.addEventListener('resize', this.dimensionsChanged.bind(this), false);
};

Object.defineProperties(exports.Environment.prototype, {

    /**
     * Provides a get() and set() function to set and get settings.
     */
    settings: {
        value: {
            set: function(key, value) {
                if (util.none(key)) {
                    throw new Error('setSetting(): key must be supplied');
                }
                if (util.none(value)) {
                    throw new Error('setSetting(): value must be supplied');
                }

                settings.set(key, value);
            },

            get: function(key) {
                if (util.none(key)) {
                    throw new Error('getSetting(): key must be supplied');
                }
                return settings.get(key);
            }
        }
    },

    dimensionsChanged: {
        value: function() {
            catalog.publish(this, 'dimensionsChanged');
        }
    },

    /**
     * Retrieves the EditSession
     */
    session: {
        get: function() {
            return catalog.getObject('session');
        }
    },

    /**
     * Gets the currentView from the session.
     */
    view: {
        get: function() {
            if (!this.session) {
                // This can happen if the session is being reloaded.
                return null;
            }
            return this.session.currentView;
        }
    },

    /**
     * Gets the currentEditor from the session.
     */
    editor: {
        get: function() {
            if (!this.session) {
                // This can happen if the session is being reloaded.
                return null;
            }
            return this.session.currentView.editor;
        }
    },

    /**
     * Returns the currently-active syntax contexts.
     */
    contexts: {
        get: function() {
            // when editorapp is being refreshed, the textView is not available.
            if (!this.view) {
                return [];
            }

            var syntaxManager = this.view.editor.layoutManager.syntaxManager;
            var pos = this.view.getSelectedRange().start;
            return syntaxManager.contextsAtPosition(pos);
        }
    },

    /**
     * The current Buffer from the session
     */
    buffer: {
        get: function() {
            if (!this.session) {
                console.error("command attempted to get buffer but there's no session");
                return undefined;
            }
            return this.view.editor.buffer;
        }
    },

    /**
     * The current editor model might not always be easy to find so you should
     * use instruction.model to access the view where
     * possible.
     */
    model: {
        get: function() {
            if (!this.buffer) {
                console.error('Session has no current buffer');
                return undefined;
            }
            return this.view.editor.layoutManager.textStorage;
        }
    },

    /**
     * gets the current file from the session
     */
    file: {
        get: function() {
            if (!this.buffer) {
                console.error('Session has no current buffer');
                return undefined;
            }
            return this.buffer.file;
        }
    },

    /**
     * If files are available, this will get them. Perhaps we need some other
     * mechanism for populating these things from the catalog?
     */
    files: {
        get: function() {
            return catalog.getObject('files');
        }
    }
});

/**
 * The global environment used throughout this Bespin instance.
 */
exports.env = new exports.Environment();


text:
<pp-notice-container></pp-notice-container>

    <pp-header-logo></pp-header-logo>

        <pp-data-load-indicator-for-filtered-map-container></pp-data-load-indicator-for-filtered-map-container>

    <pp-state-button-for-filtered-map-container></pp-state-button-for-filtered-map-container>
    <pp-command-group-container></pp-command-group-container>

            <router-outlet></router-outlet>

    <router-outlet name="sidebar"></router-outlet>


text:
layout: post
title: Powershell Finally Weirdness
desc: "Strange issue with Powershell finally code blocks not executing"
keywords: "powershell,finally,not executing,console"
---

As a developer, I run most of my local development environment from a console and I use Powershell scripts to start up that environment. Not so recently I ran into an issue with how my scripts were setup and it took forever to figure out why something was happening. Well, maybe not why but sorta why.

Jumping right in, if you have this script below and execute it with the *nofinal* flag, then cntl+c to terminate the script, the finally block will not execute. If you start it without the *nofinal* flag and terminate with cntl+c, the finally block will execute.

```posh
param([switch]$nofinal)

Try{
    Write-Output "Trying stuff!"
    Write-Output "Press any key to continue ..."

    $x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyUp")
}
Catch{
    Write-Output $_.Exception.Message
}
Finally{
    if($nofinal){
        Write-Output "Finally executed using write output"
    }
    Write-Host "Finally executed using write host."
}
```

The only difference is the use of the **Write-Output** when you include the *nofinal* flag to the start-up of the script.  Now I know the difference between **Write-Output** and **Write-Host** is that the first one writes to the pipeline so it can be piped into another command and the second one writes to the console itself.  I think that has to have something to do with this but I do not know the specifics.

I would love any input anyone has into this if you just happen to come across this article.


text:
class IBSerialPort;

class Prop : public QObject
{
	Q_OBJECT
public:
	explicit Prop(const QString name, uint baud, QObject *parent = 0);
	~Prop();

	IBSerialPort *port() const { return m_port; }
	QString device() const;
	QString portName() const;
	uint baud() const;

signals:
	void byteRxd(char c);
	void deviceChanged(const QString deviceBaud) const;

public slots:
	void setDevice(const QString device, uint baud) const;
	void send(const QByteArray ba);
	void upload(const QByteArray ba);
	void resetProp();
private slots:
	void readyRead();
	void timerTick();
protected:
private:
	IBSerialPort *m_port;
	bool m_lastWasSpace;
	QByteArray m_uploadData;
	int m_uploadIdx;
	QTimer *m_timer;
};

#endif // PROP_H


text:
#pragma once

#include <string>
#include <map>
#include <iostream>
#include <vector>
#include "jml/arch/exception.h"

namespace Datacratic {

/*****************************************************************************/
/* REST PARAMS                                                               */
/*****************************************************************************/

struct RestParams
    : public std::vector<std::pair<std::string, std::string> > {
    RestParams()
    {
    }

    RestParams(std::initializer_list<std::pair<std::string, std::string> > l)
        : std::vector<std::pair<std::string, std::string> >(l.begin(), l.end())
    {
    }

    bool hasValue(const std::string & key) const;

    /** Return the value of the given key.  Throws an exception if it's not
        found.
    */
    std::string getValue(const std::string & key) const;

    std::string uriEscaped() const;

    static RestParams fromBinary(const std::string & binary);
    std::string toBinary() const;
};

/*****************************************************************************/
/* HTTP HEADER                                                               */
/*****************************************************************************/

/** Header for an HTTP request.  Just a place to dump the data. */

struct HttpHeader {
    HttpHeader()
        : contentLength(-1), isChunked(false)
    {
    }

    void swap(HttpHeader & other);

    void parse(const std::string & headerAndData, bool checkBodyLength = true);

    std::string verb;       // GET, PUT, etc
    std::string resource;   // after the get
    std::string version;    // after the get

    int responseCode() const;  // for responses; parses it out of the "version" field

    RestParams queryParams; // Query parameters pulled out of the URL

    // These headers are automatically pulled out
    std::string contentType;
    int64_t contentLength;
    bool isChunked;

    // The rest of the headers are here
    std::map<std::string, std::string> headers;

    std::string getHeader(const std::string & key) const
    {
        auto it = headers.find(key);
        if (it == headers.end())
            throw ML::Exception("couldn't find header " + key);
        return it->second;
    }

    std::string tryGetHeader(const std::string & key) const
    {
        auto it = headers.find(key);
        if (it == headers.end())
            return "";
        return it->second;
    }

    // If some portion of the data is known, it's put in here
    std::string knownData;
};

std::ostream & operator << (std::ostream & stream, const HttpHeader & header);

/** Returns the reason phrase for the given code.
    See http://www.w3.org/Protocols/rfc2616/rfc2616-sec6.html
*/
std::string getResponseReasonPhrase(int code);

} // namespace Datacratic


text:
'use strict';

define(['angular', 'require'], function(angular, require) {
  return angular.module('portal.settings.directives', [])

  .directive('settingOption', function() {
    return {
        restrict: 'E',
        templateUrl: require.toUrl('./partials/setting-option.html'),
    };
  });
});


text:
/**
 * Application
 */
class Application {
	constructor() {
	}

	returnOne(): number {
		return 1;
	}
}


text:
require 'spec_helper'
module Gisele::Language
  describe Grammar, 'event' do

    it 'parses correct events' do
      parse('Task:start', :event).should eq('Task:start')
      parse('Task:end',   :event).should eq('Task:end')
      parse('an_event',   :event).should eq('an_event')
    end

    it 'raises on invalid event names' do
      lambda{
        parse('Task', :event)
      }.should raise_error(Citrus::ParseError)
    end

  end
end


text:
<?php # -*- coding: utf-8 -*-

namespace Inpsyde\Wonolog\Processor;

/**
 * @package wonolog
 * @license http://opensource.org/licenses/MIT MIT
 */
class ProcessorsRegistry implements \Countable {

	const ACTION_REGISTER = 'wonolog.register-processors';
	const DEFAULT_NAME = 'wonolog.default-processor';

	/**
	 * @var callable[]
	 */
	private $processors = [];

	/**
	 * @var bool
	 */
	private $initialized = FALSE;

	/**
	 * @param callable $processor
	 *
	 * @param string   $name
	 *
	 * @return ProcessorsRegistry
	 */
	public function add_processor( callable $processor, $name = NULL ) {

		( $name === null ) and $name = $this->build_name( $processor );
		if ( ! is_string( $name ) || array_key_exists( $name, $this->processors ) ) {
			return $this;
		}

		$this->processors[ $name ] = $processor;

		return $this;
	}

	/**
	 * @param string $name
	 *
	 * @return bool
	 */
	public function has_processor( $name ) {

		if ( is_callable( $name ) && ! is_string( $name ) ) {
			$name = $this->build_name( $name );
		}

		return is_string( $name ) && array_key_exists( $name, $this->processors );
	}

	/**
	 * @param string $name
	 *
	 * @return callable|null
	 */
	public function find( $name ) {

		if ( ! $this->initialized ) {
			$this->initialized = TRUE;

			/**
			 * Fires right before the first processor is to be registered.
			 *
			 * @param ProcessorsRegistry $processors_registry
			 */
			do_action( self::ACTION_REGISTER, $this );
		}

		if ( is_callable( $name ) && ! is_string( $name ) ) {
			$name = $this->build_name( $name );
		}

		return $this->has_processor( $name ) ? $this->processors[ $name ] : NULL;
	}

	/**
	 * @return int
	 */
	public function count() {

		return count( $this->processors );
	}

	/**
	 * @param callable $callable
	 *
	 * @return string
	 */
	private function build_name( callable $callable ) {

		if ( is_string( $callable ) ) {
			return $callable;
		}

		if ( is_object( $callable ) ) {
			/** @var object $callable */
			return spl_object_hash( $callable );
		}

		$class = $callable[ 0 ];
		if ( is_object( $class ) ) {
			return spl_object_hash( $class ) . $callable[ 1 ];
		}

		return "{$class}::{$callable[1]}";
	}
}


text:
<?php defined('SYSPATH') OR die('No direct script access.');

class Deta_Model_Field_Relation_One extends Deta_Core_Model_Field_Relation_One {}


text:
require 'pxp-agent/test_helper.rb'

test_name 'C93065 - Run puppet and expect puppet agent disabled' do

  tag 'audit:high',      # module validation: no other venue exists to test
      'audit:acceptance'

  teardown do
    on agents, puppet('agent --enable')
  end

  step 'Ensure each agent host has pxp-agent running and associated' do
    agents.each do |agent|
      on agent, puppet('resource service pxp-agent ensure=stopped')
      create_remote_file(agent, pxp_agent_config_file(agent), pxp_config_hocon_using_puppet_certs(master, agent))
      on agent, puppet('resource service pxp-agent ensure=running')

      assert(is_associated?(master, "pcp://#{agent}/agent"),
             "At the start of the test, #{agent} (with PCP identity pcp://#{agent}/agent ) should be associated with pcp-broker")
    end
  end

  step 'Set puppet agent on agent hosts to disabled' do
    on agents, puppet('agent --disable')
  end

  step "Send an rpc_blocking_request to all agents" do
    target_identities = []
    agents.each do |agent|
      target_identities << "pcp://#{agent}/agent"
    end
    responses = nil # Declare here so not local to begin/rescue below
    begin
      responses = rpc_blocking_request(master, target_identities,
                                      'pxp-module-puppet', 'run',
                                      {:env => [], :flags => []}
                                      )
    rescue => exception
      fail("Exception occurred when trying to run Puppet on all agents: #{exception.message}")
    end
    agents.each_with_index do |agent|
      step "Check Run Puppet response for #{agent}" do
        identity = "pcp://#{agent}/agent"
        action_result = responses[identity][:data]["results"]
        assert(action_result.has_key?('error_type'), 'Results from pxp-module-puppet should contain an \'error_type\' entry')
        assert_equal('agent_disabled', action_result['error_type'],
                     'error_type of pxp-module-puppet response should be \'agent_disabled\'')
        assert(action_result.has_key?('error'), 'Results from pxp-module-puppet should contain an \'error\' entry')
        assert_equal('Puppet agent is disabled', action_result['error'],
                     'error of pxp-module-puppet response should be \'Puppet agent is disabled\'')
      end
    end
  end
end


text:
@implementation NPPhoto

@synthesize displayIndex, tnUrl = _tnUrl, photoUrl = _photoUrl, uploadImage = _uploadImage;

- (id)init
{
    self = [super init];
    if (self) {
        self.folder.moduleId = PHOTO_MODULE;
        self.templateId = photo;
        return self;
    }

    return self;
}

- (id)copyWithZone:(NSZone*)zone
{
    NPPhoto *photo = [[NPPhoto alloc] init];
    [photo copyBasic:self];
    photo.tnUrl = self.tnUrl;
    photo.photoUrl = self.photoUrl;
    photo.uploadImage = [self.uploadImage copy];

    return photo;
}

- (NSDictionary*)buildParamMap
{
    NSMutableDictionary *params = [NSMutableDictionary dictionaryWithDictionary:[super buildParamMap]];

    if (self.templateId == photo) {
        [params setValue:[NSNumber numberWithInt:photo] forKey:TEMPLATE_ID];
    } else if (self.templateId == album) {
        [params setValue:[NSNumber numberWithInt:album] forKey:TEMPLATE_ID];
    }

    return params;
}

+ (NPPhoto*)photoFromEntry:(NPEntry*)entry
{
    if ([entry isKindOfClass:[NPPhoto class]]) {
        return (NPPhoto*)entry;
    }

    NPPhoto *photo = [[NPPhoto alloc] initWithNPEntry:entry];

    // This is for getting the TN information for individual photos in photo list
    if ([entry.featureValuesDict objectForKey:PHOTO_TN_URL] != nil && [entry.featureValuesDict objectForKey:PHOTO_URL] != nil) {
        if ([entry.featureValuesDict objectForKeyNotNull:PHOTO_TN_URL]) {
            photo.tnUrl = [entry.featureValuesDict valueForKey:PHOTO_TN_URL];
        }

        if ([entry.featureValuesDict objectForKeyNotNull:PHOTO_URL]) {
            photo.photoUrl = [entry.featureValuesDict valueForKey:PHOTO_URL];
        }

        photo.uploadImage = [[NPUpload alloc] init];
        photo.uploadImage.tnUrl = [photo.tnUrl copy];
        photo.uploadImage.url = [photo.photoUrl copy];
        photo.uploadImage.parentEntryModule = PHOTO_MODULE;
        photo.uploadImage.parentEntryFolder = photo.folder.folderId;
        photo.uploadImage.parentEntryId = [photo.entryId copy];

        // AccessEntitlement gets trickled down
        photo.uploadImage.accessInfo = photo.accessInfo;
    }

    return photo;
}

@end


text:
/* $Id$ */

package org.apache.xmlgraphics.image.loader.impl;

import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

import org.apache.commons.io.IOUtils;

import org.apache.xmlgraphics.image.loader.ImageFlavor;
import org.apache.xmlgraphics.image.loader.ImageInfo;
import org.apache.xmlgraphics.image.loader.MimeEnabledImageFlavor;

/**
 * This class is an implementation of the Image interface exposing an InputStream for loading the
 * raw/undecoded image.
 */
public class ImageRawStream extends AbstractImage {

    private ImageFlavor flavor;
    private InputStreamFactory streamFactory;

    /**
     * Main constructor.
     * @param info the image info object
     * @param flavor the image flavor for the raw image
     * @param streamFactory the InputStreamFactory that is used to create InputStream instances
     */
    public ImageRawStream(ImageInfo info, ImageFlavor flavor, InputStreamFactory streamFactory) {
        super(info);
        this.flavor = flavor;
        setInputStreamFactory(streamFactory);
    }

    /**
     * Constructor for a simple InputStream as parameter.
     * @param info the image info object
     * @param flavor the image flavor for the raw image
     * @param in the InputStream with the raw content
     */
    public ImageRawStream(ImageInfo info, ImageFlavor flavor, InputStream in) {
        this(info, flavor, new SingleStreamFactory(in));
    }

    /** {@inheritDoc} */
    public ImageFlavor getFlavor() {
        return this.flavor;
    }

    /**
     * Returns the MIME type of the stream data.
     * @return the MIME type
     */
    public String getMimeType() {
        if (getFlavor() instanceof MimeEnabledImageFlavor) {
            return getFlavor().getMimeType();
        } else {
            //Undetermined
            return "application/octet-stream";
        }
    }

    /** {@inheritDoc} */
    public boolean isCacheable() {
        return !this.streamFactory.isUsedOnceOnly();
    }

    /**
     * Sets the InputStreamFactory to be used by this image. This method allows to replace the
     * original factory.
     * @param factory the new InputStreamFactory
     */
    public void setInputStreamFactory(InputStreamFactory factory) {
        if (this.streamFactory != null) {
            this.streamFactory.close();
        }
        this.streamFactory = factory;
    }

    /**
     * Returns a new InputStream to access the raw image.
     * @return the InputStream
     */
    public InputStream createInputStream() {
        return this.streamFactory.createInputStream();
    }

    /**
     * Writes the content of the image to an OutputStream. The OutputStream in NOT closed at the
     * end.
     * @param out the OutputStream
     * @throws IOException if an I/O error occurs
     */
    public void writeTo(OutputStream out) throws IOException {
        InputStream in = createInputStream();
        try {
            IOUtils.copy(in, out);
        } finally {
            IOUtils.closeQuietly(in);
        }
    }

    /**
     * Represents a factory for InputStream objects. Make sure the class is thread-safe!
     */
    public interface InputStreamFactory {

        /**
         * Indicates whether this factory is only usable once or many times.
         * @return true if the factory can only be used once
         */
        boolean isUsedOnceOnly();

        /**
         * Creates and returns a new InputStream.
         * @return the new InputStream
         */
        InputStream createInputStream();

        /**
         * Closes the factory and releases any resources held open during the lifetime of this
         * object.
         */
        void close();

    }

    /**
     * InputStream factory that can return a pre-constructed InputStream exactly once.
     */
    private static class SingleStreamFactory implements InputStreamFactory {

        private InputStream in;

        public SingleStreamFactory(InputStream in) {
            this.in = in;
        }

        public synchronized InputStream createInputStream() {
            if (this.in != null) {
                InputStream tempin = this.in;
                this.in = null; //Don't close, just remove the reference
                return tempin;
            } else {
                throw new IllegalStateException("Can only create an InputStream once!");
            }
        }

        public synchronized void close() {
            IOUtils.closeQuietly(this.in);
            this.in = null;
        }

        public boolean isUsedOnceOnly() {
            return true;
        }

        /** {@inheritDoc} */
        protected void finalize() {
            close();
        }

    }

    /**
     * InputStream factory that wraps a byte array.
     */
    public static class ByteArrayStreamFactory implements InputStreamFactory {

        private byte[] data;

        /**
         * Main constructor.
         * @param data the byte array
         */
        public ByteArrayStreamFactory(byte[] data) {
            this.data = data;
        }

        /** {@inheritDoc} */
        public InputStream createInputStream() {
            return new ByteArrayInputStream(data);
        }

        /** {@inheritDoc} */
        public void close() {
            //nop
        }

        /** {@inheritDoc} */
        public boolean isUsedOnceOnly() {
            return false;
        }

    }

}


text:
from django.test import TestCase

class FailLoginTest(TestCase):
    pass


text:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">

<TITLE>Menü Protokolle</TITLE>
<META HTTP-EQUIV="Content-Type" Content="text/html; charset=Windows-1252">
<link rel="stylesheet" type="text/css" href="CrypTool_Help.css">

<OBJECT type="application/x-oleobject" classid="clsid:1e2a7bd0-dab9-11d0-b93a-00c04fc99f9e" VIEWASTEXT ID="Object1">
	<PARAM NAME="Keyword" VALUE="Protokolle">
	<PARAM NAME="Keyword" VALUE="Menü (Übersicht aller Menüs)">
	<PARAM NAME="Keyword" VALUE="Kryptographie">
	<PARAM NAME="Keyword" VALUE="Kryptoanalyse">
	<PARAM NAME="Keyword" VALUE="Kryptologie">
</OBJECT>

<OBJECT type="application/x-oleobject" classid="clsid:1e2a7bd0-dab9-11d0-b93a-00c04fc99f9e" VIEWASTEXT>
	<PARAM NAME="ALink Name" VALUE="Einzelverfahren_Protokolle">
</OBJECT>

Menü Protokolle (Menü Einzelverfahren)

Das Menü Protokolle enthält folgende Befehle:

Diffie-Hellman-Demo
Visualisierung des Diffie-Hellman-Schlüsselaustauschverfahrens.

Authentisierungsverfahren im Netz
Visualisierung verschiedener Authentisierungsverfahren und möglicher Angriffe.

Sichere E-Mail mit S/MIME
Visualisierung des S/MIME-Protokolls.

Kryptographische Protokolle aggregieren kryptographische Basisfunktionen (sog. Primitive) und werden zwischen mehreren Beteiligten angewendet. Dafür definieren sie Regeln für das Format, den Inhalt, die Bedeutung und die Reihenfolge ausgetauschter Nachrichten.


text:
<!DOCTYPE html>

  <link href="http://gmpg.org/xfn/11" rel="profile">
  <meta http-equiv="content-type" content="text/html; charset=utf-8">

  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1">

  <title>

      Nate Winn · Still learning

  </title>

  <link rel="stylesheet" href="/public/css/poole.css">
  <link rel="stylesheet" href="/public/css/syntax.css">
  <link rel="stylesheet" href="/public/css/lanyon.css">
  <link rel="stylesheet" href="http://fonts.googleapis.com/css?family=PT+Serif:400,400italic,700|PT+Sans:400">

  <link rel="apple-touch-icon-precomposed" sizes="144x144" href="/public/apple-touch-icon-144-precomposed.png">
  <link rel="shortcut icon" href="/public/favicon.ico">

  <link rel="alternate" type="application/rss+xml" title="RSS" href="/atom.xml">

<input type="checkbox" class="sidebar-checkbox" id="sidebar-checkbox">

My thoughts on coding, technology, design and the like. Written by @natewinn.

    Home

          Colophon

    GitHub
    Twitter

            Nate Winn
            Still learning

        Making a List, Checking It Twice

    14 Apr 2014

In 2007, Atul Gawande, general surgeon at Brigham and Women's Hospital in Boston, Massachusetts and associate professor at the Harvard School of Public Health, wrote an article for the New Yorker entitled The Checklist. This article later developed into a New York Times Bestseller, The Checklist Manifesto. The book's main point is simple: no matter how expert you may be, well-designed checklists can improve outcomes. In fact, Jack Dorsey, co-founder of Twitter and founder of Square, gives a copy of this book to everyone hired at Square.

Box Given to New Hires at Square

I read the book several years ago but was reminded of it as we dug into Sinatra this week. Sinatra is a Ruby framework similar to RubyOnRails, but more lightweight. To be quite honest, I did horribly on the assignment the first day we covered into Sinatra. I struggled to keep up in class which made the assignment tremendously difficult to complete. In fact, I didn't finish it. Our assignment was to create a web app that met the following requirements . . .

List of favorite things

Be able to match input against certain criteria

Create at 3 pages (error page, index page, and form)

Checklist . . . Check

Day two of Sinatra, I created a checklist. A simple list that outlined every step I needed to take to get a basic Sinatra CRUD app up and running. The checklist helped me immensely! With as fast as we are moving, I realized there is no possible way I'm going to remember every step. If a world-class surgeon can rely on a checklist to ensure his procedure goes according to plan, I'm pretty sure a newbie coder could use one too.

If you're learning a new skill or technique, I would encourage you to create a checklist to act as a guide. Practice doesn't make perfect; practice makes permanent. Don't view a checklist as a crutch, especially when you're first starting out. View it as a tool to ensure you are learning a new skill correctly.

        Pixel for Pixel

    13 Apr 2014

This Wednesday we dove head first into HTML and CSS with our Teaching Assistant, Katy. Working as a designer in the past, I've mocked up quite a few website to be coded. Though I've learned best practices to pass off mockups to a developer, I regretably never took the time to learn how to properly code the designs myself.

On Wednesday, we were challenged to code an intricate mockup. A similar design to what I may have designed in the past. Our cohort was challenged to replicated the site pixel for pixel using HTML and CSS. By the end of the first day, I was able to wrap my head around the syntax and grid system. From there, I was off to the races...

Learn and Apply

Though parts were painfully slow and frustrating. I was kicking myself the entire time for not forcing myself to learn this sooner! The challenge had always been daunting, too difficult to begin. But here, you are expected to make things happen—to learn and apply the skills very quickly.

I've always had a critical eye regarding design, especially my own. Tirelessly working with developers to ensure the final layout would match what I created in Photoshop. It has definitely been a challenge to be on the other side of the table. Spending hours adjusting seemingly insignificant objects to ensure the final design was pixel for pixel definitely gave me a new appreciation for coding. Take a look at the final page.

        One Year's Time

    09 Apr 2014

Exactly one year ago today, I created an account at Dev Bootcamp and began filling out an application in hopes of joining an upcoming cohort. But that very same night, I began to reason with myself why I would never be able to attend.

Excuses, Excuses

Of course, I had plenty of excuses. In just three months, my wife and I were expecting our first child, I had no where near the money I needed for entry, and then there was the small detail of supporting my family without any income for three months! My aspirations of attending a coding bootcamp became a distant memory. I was twenty-nine years-old and accepted the fact that my time to do work that truly excited me had past. I came to accept it.

Shortly after the first of the year, I was casually browsing through Twitter and noticed John Saddington, whom I have been following for years, mention The Iron Yard.

I quickly googled "The Iron Yard," and my curiosity was instantly peaked. I immediately emailed John, and it just so happened that he was going to be in San Francisco (only a 30 minute drive from my home) the very next day to speak at a conference.

My Year

While grabbing sushi together that next evening, John told me just a handful of the amazing stories of people in my similar situation that had attended The Iron Yard. In just a 3-month period of time, people were completely changing the course of their lives. Just before I hopped into my car to drive home from the city that evening, John tweeted this...

Make this the year. Don't let it go to waste.
— John Saddington (@saddington) January 29, 2014

That night, I decided this was going to be my year! Today, exactly one year from the day I registered at Dev Bootcamp, I'm writing this post from inside Atlanta Tech Village. Though only one week into the Rails dev cohort, I've already been challenged, stretched, and pushed more in this short period than I ever have in my entire life!

        How to Win the Internet

    08 Apr 2014

Today, John Saddington, partner at The Iron Yard, stopped by to chat with the Ruby and iOS cohorts about Winning the Internet. His challenge to us was simple. Be in control of our brand online. Each of us have the power to curate what people find when Googling our name.

Still Learning

Because competition has become so fierce in the marketplace, you must show others why you are different, what sets you a part from the pack. The goal is not to show others that you are an expert, but to show others your constant pursuit in becoming an expert. This is precisely the reason I entitled this blog, "Still Learning." The more I learn, the more I realize how much more I have to learn.

There are people that do and there are people that dream.

To Win the Internet, John challenged us with four practical thoughts about how we can make ourselves stand out in a crowd.

Capture a thought and tell others.

Take one specific thing and show people that you understand it. Then, take that a step further. Prove you are able to take what you've learned and help others understand it. It is easy to comprehend a topic for yourself, but to be able to transfer that knowledge in a clear, relatable message to someone else is invaluable.

Don't be afraid to be unique.

Being unique is what sets you apart from the pack. Having an opinion and telling others how you really feel is important! Apple has become an industry leader with Think Different. Their entire company culture is built around challenging the status quo. Companies are looking for people who *care, and having an opinion proves you are passionate about whatever you undertake.

Talk about how your are improving.

Show others that you are a lifelong learner. When put in the proper perspective, every experience has the opportunity to be a teachable moment. This shows others that you are not interested in just existing, but consistently striving to improve yourself and others around you.

Everyone that you meet knows something you don't.

No one likes working with a know it all! And by telling others what you are attempting to learn, you prove to others you have not arrived.

Prove you can be an ambassador

Effective communication is arguably the most valued asset to a company. By having a message online, you are effectively an ambassador for yourself. By communicating the value of your own personal brand, you are proving ahead of time that you can transfer that to whatever company you work for.

I was challenged to tailor the images and content that returned when people search for me online. I want people to be wowed when googling "Nate Winn." How are you winning the internet?

        On Your Mark, Get Set, Go

    30 Mar 2014

Day one of The Iron Yard has come to an end. After some preliminary announcements and a quick tour of the awesome Atlanta Tech Village, we hit the ground running. Actually, it was more like sprinting.

Rolling with Ruby

We quickly got our MacBooks on the same page using InstallRails.com. I found this site when I completed One Month Rails before coming to The Iron Yard. InstallRails will quickly guide you through the process of installing all the tools you need to get RubyOnRails up and running on a Mac, PC, or Linux install. I would highly recommend it if you're not quite sure what you need to get Rails up and running. We spent the remaining class time covering arrays and I was pretty much lost...

Guess Who?

Our first assignment was to create a guessing game in Ruby that runs in the terminal with the following requirements:

Array of options

Randomly select option for user to guess

Give hints to user

Do not define your own methods or classes

Finally!

It's just after 12:00am, and I just got my app to work! Check out the gist on GitHub. To be completely honest, I'm not quite sure how in the world I got this to work. If this is what every day will be like, I'm in for a wild ride.

    Older

      Newer


text:
import * as Behaviors from '../behaviors/_all';
import Attacks from '../attacks/_all';
import { Entities as Glyphs } from '../../constants/glyphs';
import { Entities as GlyphColors } from '../../constants/glyphColors';

export const waterElemental = { difficulty: 10, spawnPattern: '1d2 + 1', frequency: 1, init: () =>
  ({ glyph: { key: Glyphs.Elemental, fg: GlyphColors.Elements.Water },
  attributes: { ac: -8, speed: 50, level: 8, killXp: '13d10', spawnHp: '7d7' },
  stats: { name: 'water elemental', race: 'Elemental',
    behaviors: [Behaviors.SeeksTargetViaHearing(), Behaviors.SeeksTargetInSight(), Behaviors.Attacks()],
    attacks: [Attacks.Claw({ roll: '5d6' })]
  } }) };


text:
using NSubstitute;
using NUnit.Framework;
using System;

namespace BoringDotNet.Random
{
    [TestFixture]
    // ReSharper disable InconsistentNaming
    public class IRandomSourceExtensionsTests
    // ReSharper restore InconsistentNaming
    {
        [Test]
        public void NextInt_WithZeroRange_ReturnsZero()
        {
            var source = Substitute.For<IRandomSource>();
            Assert.AreEqual(0, source.NextInt(0, 0));
        }

        [Test]
        public void NextInt_WithOneRangeAndAlmostOne_ReturnsZero()
        {
            var source = Substitute.For<IRandomSource>();
            source.Next().Returns(0.99999);
            Assert.AreEqual(0, source.NextInt(0, 1));
        }

        [Test]
        public void NextInt_WithTwoRangeAndAlmostOne_ReturnsOne()
        {
            var source = Substitute.For<IRandomSource>();
            source.Next().Returns(0.99999);
            Assert.AreEqual(1, source.NextInt(0, 2));
        }

        [Test]
        public void NextInt_WithMinThree_ReturnsThree()
        {
            var source = Substitute.For<IRandomSource>();
            source.Next().Returns(0.0);
            Assert.AreEqual(3, source.NextInt(3, 20));
        }

        [Test]
        [ExpectedException(typeof(ArgumentNullException))]
        public void Generate_WithNullValidChars_ThrowsException()
        {
            var randomSource = Substitute.For<IRandomSource>();
            randomSource.NextString(null, 1);
        }

        [Test]
        [ExpectedException(typeof(ArgumentException))]
        public void Generate_WithEmptyValidChars_ThrowsException()
        {
            var randomSource = Substitute.For<IRandomSource>();
            randomSource.NextString("", 1);
        }

        [Test]
        [ExpectedException(typeof(ArgumentOutOfRangeException))]
        public void Generate_WithNegativeLength_ThrowsException()
        {
            var randomSource = Substitute.For<IRandomSource>();
            randomSource.NextString("a", -1);
        }

        [Test]
        public void Generate_WithFirstChar_ReturnsFirstChar()
        {
            var randomSource = Substitute.For<IRandomSource>();
            randomSource.Next().Returns(0.0);
            var actual = randomSource.NextString("abc", 1);
            Assert.AreEqual("a", actual);
        }

        [Test]
        public void Generate_WithLastChar_ReturnsLastChar()
        {
            var randomSource = Substitute.For<IRandomSource>();
            randomSource.Next().Returns(0.999999999);
            var actual = randomSource.NextString("abc", 1);
            Assert.AreEqual("c", actual);
        }

        [Test]
        public void Generate_WithThreeChars_ReturnsThreeChars()
        {
            var randomSource = Substitute.For<IRandomSource>();
            randomSource.Next().Returns(0.0, 0.5, 0.999999999);
            var actual = randomSource.NextString("abc", 3);
            Assert.AreEqual("abc", actual);
        }
    }
}


text:
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <Dbghelp.h>

namespace ouro {

const char* as_string(const module::type::value& _Type)
{
	switch (_Type)
	{
		case module::type::unknown: return "unknown";
		case module::type::app: return "application";
		case module::type::dll: return "dll";
		case module::type::lib: return "library";
		case module::type::font_unknown: return "unknown font";
		case module::type::font_raster: return "raster font";
		case module::type::font_truetype: return "truetype font";
		case module::type::font_vector: return "vector font";
		case module::type::virtual_device: return "virtual device";
		case module::type::drv_unknown: return "unknown driver";
		case module::type::drv_comm: return "comm driver";
		case module::type::drv_display: return "display driver";
		case module::type::drv_installable: return "installable driver";
		case module::type::drv_keyboard: return "keyboard driver";
		case module::type::drv_language: return "language driver";
		case module::type::drv_mouse: return "mouse driver";
		case module::type::drv_network: return "network driver";
		case module::type::drv_printer: return "printer driver";
		case module::type::drv_sound: return "sound driver";
		case module::type::drv_system: return "system driver";
		default: break;
	}
	return "?";
}

	namespace module {

id open(const path& _Path)
{
	id mid;
	*(HMODULE*)&mid = LoadLibrary(_Path);
	return mid;
}

void close(id _ModuleID)
{
	if (_ModuleID)
		FreeLibrary(*(HMODULE*)&_ModuleID);
}

void* sym(id _ModuleID, const char* _SymbolName)
{
	return GetProcAddress(*(HMODULE*)&_ModuleID, _SymbolName);
}

void link(id _ModuleID, const char** _pInterfaceFunctionNames, void** _ppInterfaces, size_t _CountofInterfaces)
{
	memset(_ppInterfaces, 0, sizeof(void*) * _CountofInterfaces);
	for (size_t i = 0; i < _CountofInterfaces; i++)
	{
		_ppInterfaces[i] = sym(_ModuleID, _pInterfaceFunctionNames[i]);
		if (!_ppInterfaces[i])
			oTHROW(function_not_supported, "'%s' not found in '%s'", _pInterfaceFunctionNames[i], get_path(_ModuleID).c_str());
	}
}

id get_id(const void* _Symbol)
{
	id mid;
	oVB(GetModuleHandleExA(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS|GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, (LPCTSTR)_Symbol, (HMODULE*)&mid));
	return mid;
}

path get_path(id _ModuleID)
{
	static const char sLocalSymbol = 0;

	if (!_ModuleID)
		_ModuleID = get_id(&sLocalSymbol);

	path_string p;
	size_t len = static_cast<size_t>(GetModuleFileNameA(*(HMODULE*)&_ModuleID
		, p
		, static_cast<UINT>(p.capacity())));

	if (len+1 == p.capacity() && GetLastError())
		oTHROW0(no_buffer_space);

	return path(p);
}

static version get_version(DWORD _VersionMS, DWORD _VersionLS)
{
	return version(HIWORD(_VersionMS), LOWORD(_VersionMS), HIWORD(_VersionLS), LOWORD(_VersionLS));
}

static type::value get_type(const VS_FIXEDFILEINFO& _FFI)
{
	switch (_FFI.dwFileType)
	{
		case VFT_UNKNOWN: return type::unknown;
		case VFT_APP: return type::app;
		case VFT_DLL: return type::dll;
		case VFT_STATIC_LIB: return type::lib;
		case VFT_VXD: return type::virtual_device;
		case VFT_FONT:
		{
			switch (_FFI.dwFileSubtype)
			{
				case VFT2_FONT_RASTER: return type::font_raster;
				case VFT2_FONT_VECTOR: return type::font_vector;
				case VFT2_FONT_TRUETYPE: return type::font_truetype;
				case VFT2_UNKNOWN:
				default: break;
			}
			return type::font_unknown;
		}

		case VFT_DRV:
		{
			switch (_FFI.dwFileSubtype)
			{
				case VFT2_DRV_KEYBOARD: return type::drv_keyboard;
				case VFT2_DRV_LANGUAGE: return type::drv_language;
				case VFT2_DRV_DISPLAY: return type::drv_display;
				case VFT2_DRV_MOUSE: return type::drv_mouse;
				case VFT2_DRV_NETWORK: return type::drv_network;
				case VFT2_DRV_SYSTEM: return type::drv_system;
				case VFT2_DRV_INSTALLABLE: return type::drv_installable;
				case VFT2_DRV_SOUND: return type::drv_sound;
				case VFT2_DRV_COMM: return type::drv_comm;
				//case VFT2_DRV_INPUTMETHOD: return type::DRV_?;
				case VFT2_DRV_PRINTER:
				case VFT2_DRV_VERSIONED_PRINTER: return type::drv_printer;
				case VFT2_UNKNOWN:
				default: break;
			}
			return type::drv_unknown;
		}
	}
	return type::unknown;
}

#if 0 // not needed yet
static void get_type(const module::type::value _Type, DWORD* _pType, DWORD* _pSubtype)
{
	*_pType = VFT_UNKNOWN;
	*_pSubtype = VFT2_UNKNOWN;

	switch (_Type)
	{
		case module::type::app: *_pType = VFT_APP; break;
		case module::type::dll: *_pType = VFT_DLL; break;
		case module::type::lib: *_pType = VFT_STATIC_LIB; break;
		case module::type::font_unknown: *_pType = VFT_FONT; break;
		case module::type::font_raster: *_pType = VFT_FONT; *_pSubtype = VFT2_FONT_RASTER; break;
		case module::type::font_truetype: *_pType = VFT_FONT; *_pSubtype = VFT2_FONT_TRUETYPE; break;
		case module::type::font_vector: *_pType = VFT_FONT; *_pSubtype = VFT2_FONT_VECTOR; break;
		case module::type::virtual_device: *_pType = VFT_VXD; break;
		case module::type::drv_unknown: *_pType = VFT_DRV; break;
		case module::type::drv_comm: *_pType = VFT_DRV; *_pSubtype = VFT2_DRV_COMM; break;
		case module::type::drv_display: *_pType = VFT_DRV; *_pSubtype = VFT2_DRV_DISPLAY; break;
		case module::type::drv_installable: *_pType = VFT_DRV; *_pSubtype = VFT2_DRV_INSTALLABLE; break;
		case module::type::drv_keyboard: *_pType = VFT_DRV; *_pSubtype = VFT2_DRV_KEYBOARD; break;
		case module::type::drv_language: *_pType = VFT_DRV; *_pSubtype = VFT2_DRV_LANGUAGE; break;
		case module::type::drv_mouse: *_pType = VFT_DRV; *_pSubtype = VFT2_DRV_MOUSE; break;
		case module::type::drv_network: *_pType = VFT_DRV; *_pSubtype = VFT2_DRV_NETWORK; break;
		case module::type::drv_printer: *_pType = VFT_DRV; *_pSubtype = VFT2_DRV_PRINTER; break;
		case module::type::drv_sound: *_pType = VFT_DRV; *_pSubtype = VFT2_DRV_SOUND; break;
		case module::type::drv_system: *_pType = VFT_DRV; *_pSubtype = VFT2_DRV_SYSTEM; break;
		default: break;
	}
}
#endif

static bool is_64bit()
{
	if (sizeof(void*) != 4) // If ptr size is larger than 32-bit we must be on 64-bit windows
		return true;

	// If ptr size is 4 bytes then we're a 32-bit process so check if we're running under
	// wow64 which would indicate that we're on a 64-bit system
	BOOL bWow64 = FALSE;
	IsWow64Process(GetCurrentProcess(), &bWow64);
	return !bWow64;
}

static bool is_64bit(const path& _Path)
{
	bool result = false;

	HMODULE hModule = LoadLibrary(_Path);
	finally Close([&] { FreeLibrary(hModule); });

	// can't map the 'this' module for access, so use another method
	if (GetModuleHandle(nullptr) == hModule)
		return is_64bit();

	unsigned long long size = filesystem::file_size(_Path);

	void* mapped = filesystem::map(_Path, filesystem::map_option::binary_read, 0, size);
	if (mapped)
	{
		IMAGE_NT_HEADERS* pHeader = ImageNtHeader(mapped);
		result = pHeader->FileHeader.Machine == IMAGE_FILE_MACHINE_AMD64;
		filesystem::unmap(mapped);
	}

	return result;
}

info get_info(const path& _Path)
{
	DWORD hFVI = 0;
	DWORD FVISize = GetFileVersionInfoSizeA(_Path, &hFVI);
	if (!FVISize)
		throw windows::error();

	std::vector<char> buf;
	buf.resize(FVISize);
	void* pData = data(buf);

	oVB(GetFileVersionInfoA(_Path, hFVI, FVISize, pData));

	// http://msdn.microsoft.com/en-us/library/ms647003(VS.85).aspx
	// Based on a comment that questions the reliablility of the return value
	if (GetLastError() != S_OK)
		throw windows::error();

	// _____________________________________________________________________________
	// Get the basics from VS_FIXEDFILEINFO

	VS_FIXEDFILEINFO* pFFI = nullptr;
	UINT FFISize = 0;
	oVB(VerQueryValueA(pData, "\\", (LPVOID*)&pFFI, &FFISize));

	info i;
	i.version = get_version(pFFI->dwFileVersionMS, pFFI->dwFileVersionLS);
	i.type = get_type(*pFFI);
	i.is_debug = (pFFI->dwFileFlags & VS_FF_DEBUG) == VS_FF_DEBUG;
	i.is_prerelease = (pFFI->dwFileFlags & VS_FF_PRERELEASE) == VS_FF_PRERELEASE;
	i.is_patched = (pFFI->dwFileFlags & VS_FF_PATCHED) == VS_FF_PATCHED;
	i.is_private = (pFFI->dwFileFlags & VS_FF_PRIVATEBUILD) == VS_FF_PRIVATEBUILD;
	i.is_special = (pFFI->dwFileFlags & VS_FF_SPECIALBUILD) == VS_FF_SPECIALBUILD;
	i.is_64bit_binary = is_64bit(_Path);

	// _____________________________________________________________________________
	// Now do some of the more complicated ones

	struct LANGANDCODEPAGE
	{
		WORD wLanguage;
		WORD wCodePage;
	};

	LANGANDCODEPAGE* pLCP = nullptr;
	UINT LCPSize = 0;
	oVB(VerQueryValueA(pData, "\\VarFileInfo\\Translation", (LPVOID*)&pLCP, &LCPSize));

	UINT nLanguages = LCPSize / sizeof(LANGANDCODEPAGE);

	if (nLanguages != 1)
		oTHROW(protocol_error, "There are %u languages in the file. Currently we assume 1: English", nLanguages);

	struct MAPPING
	{
		const char* Key;
		mstring* Dest;
		bool Required;
	};

	MAPPING s_mapping[] =
	{
		{ "CompanyName", &i.company, true },
		{ "FileDescription", &i.description, true },
		{ "ProductName", &i.product_name, true },
		{ "LegalCopyright", &i.copyright, true },
		{ "OriginalFilename", &i.original_filename, true },
		{ "Comments", &i.comments, false },
		{ "PrivateBuild", &i.private_message, false },
		{ "SpecialBuild", &i.special_message, false },
	};

	for (const auto& m : s_mapping)
	{
		mstring Key;
		snprintf(Key, "\\StringFileInfo\\%04x%04x\\%s", pLCP[0].wLanguage, pLCP[0].wCodePage, m.Key);
		mwstring WKey(Key);
		wchar_t* pVal = nullptr;
		UINT ValLen = 0;
		*m.Dest = "";
		// VerQueryValueA version seems bugged... it returns one char short of the
		// proper size.
		if (!VerQueryValueW(pData, WKey, (LPVOID*)&pVal, &ValLen) && m.Required)
			throw windows::error();
		*m.Dest = pVal;
	}

	return i;
}

info get_info(id _ModuleID)
{
	return get_info(get_path(_ModuleID));
}

	} // namespace module

	namespace this_module {

path get_path()
{
	return module::get_path(module::id());
}

module::info get_info()
{
	return module::get_info(module::id());
}

module::id get_id()
{
	// static is unique per module, so copies and thus unique addresses live in
	// each module.
	static module::id CurrentId;
	if (!CurrentId)
		CurrentId = module::get_id(&CurrentId);
	return CurrentId;
}

	} // namespace this_module
}


text:
<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string name="menu_cart_refresh">Ανανέωση</string>
    <string name="menu_cart_empty">Άδειασμα Καλαθιού</string>

    <string name="menu_cart_item_qty">Αλλαγή Ποσότητας</string>
    <string name="menu_cart_item_remove">Αφαίρεση</string>

    <string name="menu_cart_name">Καλάθι</string>
    <string name="menu_share_name">Κοινοποίηση</string>
    <string name="menu_search_name">Αναζήτηση</string>
    <string name="menu_settings_name">Ρυθμίσεις</string>

    <string name="menu_compare_name">ΣΥΓΚΡΙΝΕ</string>

</resources>


text:
package sdl2

// #cgo LDFLAGS: -lSDL2
// #include <SDL2/SDL_scancode.h>
// #include <SDL2/SDL_keyboard.h>
import "C"
import "unsafe"

type Scancode int

func NewScancodeFromName(name string) Scancode {
	cstr := C.CString(name)
	defer C.free(unsafe.Pointer(cstr))
	return Scancode(C.SDL_GetScancodeFromName(cstr))
}

func (sc Scancode) Key() Keycode {
	return Keycode(C.SDL_GetKeyFromScancode(C.SDL_Scancode(sc)))
}

func (sc Scancode) String() string {
	return C.GoString(C.SDL_GetScancodeName(C.SDL_Scancode(sc)))
}

// Scan codes from SDL_scancode, some comments reformatted
// to match standard Go comments.
const (
	ScanUnknown Scancode = C.SDL_SCANCODE_UNKNOWN
	ScanA       Scancode = C.SDL_SCANCODE_A
	ScanB       Scancode = C.SDL_SCANCODE_B
	ScanC       Scancode = C.SDL_SCANCODE_C
	ScanD       Scancode = C.SDL_SCANCODE_D
	ScanE       Scancode = C.SDL_SCANCODE_E
	ScanF       Scancode = C.SDL_SCANCODE_F
	ScanG       Scancode = C.SDL_SCANCODE_G
	ScanH       Scancode = C.SDL_SCANCODE_H
	ScanI       Scancode = C.SDL_SCANCODE_I
	ScanJ       Scancode = C.SDL_SCANCODE_J
	ScanK       Scancode = C.SDL_SCANCODE_K
	ScanL       Scancode = C.SDL_SCANCODE_L
	ScanM       Scancode = C.SDL_SCANCODE_M
	ScanN       Scancode = C.SDL_SCANCODE_N
	ScanO       Scancode = C.SDL_SCANCODE_O
	ScanP       Scancode = C.SDL_SCANCODE_P
	ScanQ       Scancode = C.SDL_SCANCODE_Q
	ScanR       Scancode = C.SDL_SCANCODE_R
	ScanS       Scancode = C.SDL_SCANCODE_S
	ScanT       Scancode = C.SDL_SCANCODE_T
	ScanU       Scancode = C.SDL_SCANCODE_U
	ScanV       Scancode = C.SDL_SCANCODE_V
	ScanW       Scancode = C.SDL_SCANCODE_W
	ScanX       Scancode = C.SDL_SCANCODE_X
	ScanY       Scancode = C.SDL_SCANCODE_Y
	ScanZ       Scancode = C.SDL_SCANCODE_Z

	Scan1 Scancode = C.SDL_SCANCODE_1
	Scan2 Scancode = C.SDL_SCANCODE_2
	Scan3 Scancode = C.SDL_SCANCODE_3
	Scan4 Scancode = C.SDL_SCANCODE_4
	Scan5 Scancode = C.SDL_SCANCODE_5
	Scan6 Scancode = C.SDL_SCANCODE_6
	Scan7 Scancode = C.SDL_SCANCODE_7
	Scan8 Scancode = C.SDL_SCANCODE_8
	Scan9 Scancode = C.SDL_SCANCODE_9
	Scan0 Scancode = C.SDL_SCANCODE_0

	ScanReturn    Scancode = C.SDL_SCANCODE_RETURN
	ScanEscape    Scancode = C.SDL_SCANCODE_ESCAPE
	ScanBackspace Scancode = C.SDL_SCANCODE_BACKSPACE
	ScanTab       Scancode = C.SDL_SCANCODE_TAB
	ScanSpace     Scancode = C.SDL_SCANCODE_SPACE

	ScanMinus        Scancode = C.SDL_SCANCODE_MINUS
	ScanEquals       Scancode = C.SDL_SCANCODE_EQUALS
	ScanLeftBracket  Scancode = C.SDL_SCANCODE_LEFTBRACKET
	ScanRightBracket Scancode = C.SDL_SCANCODE_RIGHTBRACKET

	/*
	   Located at the lower left of the return
	   key on ISO keyboards and at the right end
	   of the QWERTY row on ANSI keyboards.
	   Produces REVERSE SOLIDUS (backslash) and
	   VERTICAL LINE in a US layout, REVERSE
	   SOLIDUS and VERTICAL LINE in a UK Mac
	   layout, NUMBER SIGN and TILDE in a UK
	   Windows layout, DOLLAR SIGN and POUND SIGN
	   in a Swiss German layout, NUMBER SIGN and
	   APOSTROPHE in a German layout, GRAVE
	   ACCENT and POUND SIGN in a French Mac
	   layout, and ASTERISK and MICRO SIGN in a
	   French Windows layout.
	*/
	ScanBackslash Scancode = C.SDL_SCANCODE_BACKSLASH
	/*
	   ISO USB keyboards actually use this code
	   instead of 49 for the same key, but all
	   OSes I've seen treat the two codes
	   identically. So, as an implementor, unless
	   your keyboard generates both of those
	   codes and your OS treats them differently,
	   you should generate C.SDL_SCANCODE_BACKSLASH
	   instead of this code. As a user, you
	   should not rely on this code because SDL
	   will never generate it with most (all?)
	   keyboards.
	*/
	ScanNonUSHash  Scancode = C.SDL_SCANCODE_NONUSHASH
	ScanSemicolon  Scancode = C.SDL_SCANCODE_SEMICOLON
	ScanApostrophe Scancode = C.SDL_SCANCODE_APOSTROPHE
	/*
	   Located in the top left corner (on both ANSI
	   and ISO keyboards). Produces GRAVE ACCENT and
	   TILDE in a US Windows layout and in US and UK
	   Mac layouts on ANSI keyboards, GRAVE ACCENT
	   and NOT SIGN in a UK Windows layout, SECTION
	   SIGN and PLUS-MINUS SIGN in US and UK Mac
	   layouts on ISO keyboards, SECTION SIGN and
	   DEGREE SIGN in a Swiss German layout (Mac:
	   only on ISO keyboards), CIRCUMFLEX ACCENT and
	   DEGREE SIGN in a German layout (Mac: only on
	   ISO keyboards), SUPERSCRIPT TWO and TILDE in a
	   French Windows layout, COMMERCIAL AT and
	   NUMBER SIGN in a French Mac layout on ISO
	   keyboards, and LESS-THAN SIGN and GREATER-THAN
	   SIGN in a Swiss German, German, or French Mac
	   layout on ANSI keyboards.
	*/
	ScanGrave  Scancode = C.SDL_SCANCODE_GRAVE
	ScanComma  Scancode = C.SDL_SCANCODE_COMMA
	ScanPeriod Scancode = C.SDL_SCANCODE_PERIOD
	ScanSlash  Scancode = C.SDL_SCANCODE_SLASH

	ScanCapsLock Scancode = C.SDL_SCANCODE_CAPSLOCK

	ScanF1  Scancode = C.SDL_SCANCODE_F1
	ScanF2  Scancode = C.SDL_SCANCODE_F2
	ScanF3  Scancode = C.SDL_SCANCODE_F3
	ScanF4  Scancode = C.SDL_SCANCODE_F4
	ScanF5  Scancode = C.SDL_SCANCODE_F5
	ScanF6  Scancode = C.SDL_SCANCODE_F6
	ScanF7  Scancode = C.SDL_SCANCODE_F7
	ScanF8  Scancode = C.SDL_SCANCODE_F8
	ScanF9  Scancode = C.SDL_SCANCODE_F9
	ScanF10 Scancode = C.SDL_SCANCODE_F10
	ScanF11 Scancode = C.SDL_SCANCODE_F11
	ScanF12 Scancode = C.SDL_SCANCODE_F12

	ScanPrintScreen Scancode = C.SDL_SCANCODE_PRINTSCREEN
	ScanScrollLock  Scancode = C.SDL_SCANCODE_SCROLLLOCK
	ScanPause       Scancode = C.SDL_SCANCODE_PAUSE
	// insert on PC, help on some Mac keyboards (but does send code 73, not 117)
	ScanInsert   Scancode = C.SDL_SCANCODE_INSERT
	ScanHome     Scancode = C.SDL_SCANCODE_HOME
	ScanPageUp   Scancode = C.SDL_SCANCODE_PAGEUP
	ScanDelete   Scancode = C.SDL_SCANCODE_DELETE
	ScanEnd      Scancode = C.SDL_SCANCODE_END
	ScanPageDown Scancode = C.SDL_SCANCODE_PAGEDOWN
	ScanRight    Scancode = C.SDL_SCANCODE_RIGHT
	ScanLeft     Scancode = C.SDL_SCANCODE_LEFT
	ScanDown     Scancode = C.SDL_SCANCODE_DOWN
	ScanUp       Scancode = C.SDL_SCANCODE_UP

	// num lock on PC, clear on Mac keyboards
	ScanNumLockClear Scancode = C.SDL_SCANCODE_NUMLOCKCLEAR
	ScanNumDivide    Scancode = C.SDL_SCANCODE_KP_DIVIDE
	ScanNumMultiply  Scancode = C.SDL_SCANCODE_KP_MULTIPLY
	ScanNumMinus     Scancode = C.SDL_SCANCODE_KP_MINUS
	ScanNumPlus      Scancode = C.SDL_SCANCODE_KP_PLUS
	ScanNumEnter     Scancode = C.SDL_SCANCODE_KP_ENTER
	ScanNum1         Scancode = C.SDL_SCANCODE_KP_1
	ScanNum2         Scancode = C.SDL_SCANCODE_KP_2
	ScanNum3         Scancode = C.SDL_SCANCODE_KP_3
	ScanNum4         Scancode = C.SDL_SCANCODE_KP_4
	ScanNum5         Scancode = C.SDL_SCANCODE_KP_5
	ScanNum6         Scancode = C.SDL_SCANCODE_KP_6
	ScanNum7         Scancode = C.SDL_SCANCODE_KP_7
	ScanNum8         Scancode = C.SDL_SCANCODE_KP_8
	ScanNum9         Scancode = C.SDL_SCANCODE_KP_9
	ScanNum0         Scancode = C.SDL_SCANCODE_KP_0
	ScanNumPeriod    Scancode = C.SDL_SCANCODE_KP_PERIOD

	/*
	   This is the additional key that ISO
	   keyboards have over ANSI ones,
	   located between left shift and Y.
	   Produces GRAVE ACCENT and TILDE in a
	   US or UK Mac layout, REVERSE SOLIDUS
	   (backslash) and VERTICAL LINE in a
	   US or UK Windows layout, and
	   LESS-THAN SIGN and GREATER-THAN SIGN
	   in a Swiss German, German, or French
	   layout.
	*/
	ScanNonUSBackSlash Scancode = C.SDL_SCANCODE_NONUSBACKSLASH
	// windows contextual menu, compose
	ScanApplication Scancode = C.SDL_SCANCODE_APPLICATION
	/*
	   The USB document says this is a status flag,
	   not a physical key - but some Mac keyboards
	   do have a power key.
	*/
	ScanPower       Scancode = C.SDL_SCANCODE_POWER
	ScanNumEquals   Scancode = C.SDL_SCANCODE_KP_EQUALS
	ScanF13         Scancode = C.SDL_SCANCODE_F13
	ScanF14         Scancode = C.SDL_SCANCODE_F14
	ScanF15         Scancode = C.SDL_SCANCODE_F15
	ScanF16         Scancode = C.SDL_SCANCODE_F16
	ScanF17         Scancode = C.SDL_SCANCODE_F17
	ScanF18         Scancode = C.SDL_SCANCODE_F18
	ScanF19         Scancode = C.SDL_SCANCODE_F19
	ScanF20         Scancode = C.SDL_SCANCODE_F20
	ScanF21         Scancode = C.SDL_SCANCODE_F21
	ScanF22         Scancode = C.SDL_SCANCODE_F22
	ScanF23         Scancode = C.SDL_SCANCODE_F23
	ScanF24         Scancode = C.SDL_SCANCODE_F24
	ScanExecute     Scancode = C.SDL_SCANCODE_EXECUTE
	ScanHelp        Scancode = C.SDL_SCANCODE_HELP
	ScanMenu        Scancode = C.SDL_SCANCODE_MENU
	ScanSelect      Scancode = C.SDL_SCANCODE_SELECT
	ScanStop        Scancode = C.SDL_SCANCODE_STOP
	ScanAgain       Scancode = C.SDL_SCANCODE_AGAIN
	ScanUndo        Scancode = C.SDL_SCANCODE_UNDO
	ScanCut         Scancode = C.SDL_SCANCODE_CUT
	ScanCopy        Scancode = C.SDL_SCANCODE_COPY
	ScanPaste       Scancode = C.SDL_SCANCODE_PASTE
	ScanFind        Scancode = C.SDL_SCANCODE_FIND
	ScanMute        Scancode = C.SDL_SCANCODE_MUTE
	ScanVolumeUp    Scancode = C.SDL_SCANCODE_VOLUMEUP
	ScanVolumeDown  Scancode = C.SDL_SCANCODE_VOLUMEDOWN
	ScanNumComma    Scancode = C.SDL_SCANCODE_KP_COMMA
	ScanEqualsAS400 Scancode = C.SDL_SCANCODE_KP_EQUALSAS400

	// used on Asian keyboards, see footnotes in USB doc
	ScanInternational1 Scancode = C.SDL_SCANCODE_INTERNATIONAL1
	ScanInternational2 Scancode = C.SDL_SCANCODE_INTERNATIONAL2
	// Yen
	ScanInternational3 Scancode = C.SDL_SCANCODE_INTERNATIONAL3
	ScanInternational4 Scancode = C.SDL_SCANCODE_INTERNATIONAL4
	ScanInternational5 Scancode = C.SDL_SCANCODE_INTERNATIONAL5
	ScanInternational6 Scancode = C.SDL_SCANCODE_INTERNATIONAL6
	ScanInternational7 Scancode = C.SDL_SCANCODE_INTERNATIONAL7
	ScanInternational8 Scancode = C.SDL_SCANCODE_INTERNATIONAL8
	ScanInternational9 Scancode = C.SDL_SCANCODE_INTERNATIONAL9
	// Hangul/English toggle
	ScanLang1 Scancode = C.SDL_SCANCODE_LANG1
	// Hanja conversion
	ScanLang2 Scancode = C.SDL_SCANCODE_LANG2
	// Katakana
	ScanLang3 Scancode = C.SDL_SCANCODE_LANG3
	// Hiragana
	ScanLang4 Scancode = C.SDL_SCANCODE_LANG4
	// Zenkaku/Hankaku
	ScanLang5 Scancode = C.SDL_SCANCODE_LANG5
	// Erase-Eaze
	ScanAlterase   Scancode = C.SDL_SCANCODE_ALTERASE
	ScanSysreq     Scancode = C.SDL_SCANCODE_SYSREQ
	ScanCancel     Scancode = C.SDL_SCANCODE_CANCEL
	ScanClear      Scancode = C.SDL_SCANCODE_CLEAR
	ScanPrior      Scancode = C.SDL_SCANCODE_PRIOR
	ScanReturn2    Scancode = C.SDL_SCANCODE_RETURN2
	ScanSeparator  Scancode = C.SDL_SCANCODE_SEPARATOR
	ScanOut        Scancode = C.SDL_SCANCODE_OUT
	ScanOper       Scancode = C.SDL_SCANCODE_OPER
	ScanClearAgain Scancode = C.SDL_SCANCODE_CLEARAGAIN
	ScanCrsel      Scancode = C.SDL_SCANCODE_CRSEL
	ScanExsel      Scancode = C.SDL_SCANCODE_EXSEL

	Scan00                 Scancode = C.SDL_SCANCODE_KP_00
	Scan000                Scancode = C.SDL_SCANCODE_KP_000
	ScanThousandsSeparator Scancode = C.SDL_SCANCODE_THOUSANDSSEPARATOR
	ScanDecimalSeparator   Scancode = C.SDL_SCANCODE_DECIMALSEPARATOR
	ScanCurrencyUnit       Scancode = C.SDL_SCANCODE_CURRENCYUNIT
	ScanCurrencySubunit    Scancode = C.SDL_SCANCODE_CURRENCYSUBUNIT
	ScanLeftParen          Scancode = C.SDL_SCANCODE_KP_LEFTPAREN
	ScanRightParen         Scancode = C.SDL_SCANCODE_KP_RIGHTPAREN
	ScanLeftBrace          Scancode = C.SDL_SCANCODE_KP_LEFTBRACE
	ScanRightBrace         Scancode = C.SDL_SCANCODE_KP_RIGHTBRACE
	ScanNumTab             Scancode = C.SDL_SCANCODE_KP_TAB
	ScanNumBackspace       Scancode = C.SDL_SCANCODE_KP_BACKSPACE
	ScanNumA               Scancode = C.SDL_SCANCODE_KP_A
	ScanNumB               Scancode = C.SDL_SCANCODE_KP_B
	ScanNumC               Scancode = C.SDL_SCANCODE_KP_C
	ScanNumD               Scancode = C.SDL_SCANCODE_KP_D
	ScanNumE               Scancode = C.SDL_SCANCODE_KP_E
	ScanNumF               Scancode = C.SDL_SCANCODE_KP_F
	ScanXor                Scancode = C.SDL_SCANCODE_KP_XOR
	ScanNumPower           Scancode = C.SDL_SCANCODE_KP_POWER
	ScanPercent            Scancode = C.SDL_SCANCODE_KP_PERCENT
	ScanLess               Scancode = C.SDL_SCANCODE_KP_LESS
	ScanGreater            Scancode = C.SDL_SCANCODE_KP_GREATER
	ScanAmpersand          Scancode = C.SDL_SCANCODE_KP_AMPERSAND
	ScanDblAmpersand       Scancode = C.SDL_SCANCODE_KP_DBLAMPERSAND
	ScanVerticalBar        Scancode = C.SDL_SCANCODE_KP_VERTICALBAR
	ScanDblVerticalBar     Scancode = C.SDL_SCANCODE_KP_DBLVERTICALBAR
	ScanColon              Scancode = C.SDL_SCANCODE_KP_COLON
	ScanHash               Scancode = C.SDL_SCANCODE_KP_HASH
	ScanNumSpace           Scancode = C.SDL_SCANCODE_KP_SPACE
	ScanAt                 Scancode = C.SDL_SCANCODE_KP_AT
	ScanExclam             Scancode = C.SDL_SCANCODE_KP_EXCLAM
	ScanMemStore           Scancode = C.SDL_SCANCODE_KP_MEMSTORE
	ScanMemRecall          Scancode = C.SDL_SCANCODE_KP_MEMRECALL
	ScanMemClear           Scancode = C.SDL_SCANCODE_KP_MEMCLEAR
	ScanMemAdd             Scancode = C.SDL_SCANCODE_KP_MEMADD
	ScanMemSubtract        Scancode = C.SDL_SCANCODE_KP_MEMSUBTRACT
	ScanMemMultiply        Scancode = C.SDL_SCANCODE_KP_MEMMULTIPLY
	ScanMemDivide          Scancode = C.SDL_SCANCODE_KP_MEMDIVIDE
	ScanPlusMinus          Scancode = C.SDL_SCANCODE_KP_PLUSMINUS
	ScanNumClear           Scancode = C.SDL_SCANCODE_KP_CLEAR
	ScanClearEntry         Scancode = C.SDL_SCANCODE_KP_CLEARENTRY
	ScanBinary             Scancode = C.SDL_SCANCODE_KP_BINARY
	ScanOctal              Scancode = C.SDL_SCANCODE_KP_OCTAL
	ScanDecimal            Scancode = C.SDL_SCANCODE_KP_DECIMAL
	ScanHexadecimal        Scancode = C.SDL_SCANCODE_KP_HEXADECIMAL

	ScanLCtrl  Scancode = C.SDL_SCANCODE_LCTRL
	ScanLShift Scancode = C.SDL_SCANCODE_LSHIFT
	ScanLAlt   Scancode = C.SDL_SCANCODE_LALT
	ScanLGui   Scancode = C.SDL_SCANCODE_LGUI
	ScanRCtrl  Scancode = C.SDL_SCANCODE_RCTRL
	ScanRShift Scancode = C.SDL_SCANCODE_RSHIFT
	ScanRAlt   Scancode = C.SDL_SCANCODE_RALT
	ScanRGui   Scancode = C.SDL_SCANCODE_RGUI

	// These values are mapped from usage page 0x0C (USB consumer page).
	ScanAudioNext   Scancode = C.SDL_SCANCODE_AUDIONEXT
	ScanAudioPrev   Scancode = C.SDL_SCANCODE_AUDIOPREV
	ScanAudioStop   Scancode = C.SDL_SCANCODE_AUDIOSTOP
	ScanAudioPlay   Scancode = C.SDL_SCANCODE_AUDIOPLAY
	ScanAudioMute   Scancode = C.SDL_SCANCODE_AUDIOMUTE
	ScanMediaSelect Scancode = C.SDL_SCANCODE_MEDIASELECT
	ScanWww         Scancode = C.SDL_SCANCODE_WWW
	ScanMail        Scancode = C.SDL_SCANCODE_MAIL
	ScanCalculator  Scancode = C.SDL_SCANCODE_CALCULATOR
	ScanComputer    Scancode = C.SDL_SCANCODE_COMPUTER
	ScanSearch      Scancode = C.SDL_SCANCODE_AC_SEARCH
	ScanACHome      Scancode = C.SDL_SCANCODE_AC_HOME
	ScanBack        Scancode = C.SDL_SCANCODE_AC_BACK
	ScanForward     Scancode = C.SDL_SCANCODE_AC_FORWARD
	ScanACStop      Scancode = C.SDL_SCANCODE_AC_STOP
	ScanRefresh     Scancode = C.SDL_SCANCODE_AC_REFRESH
	ScanBookmarks   Scancode = C.SDL_SCANCODE_AC_BOOKMARKS

	// These are values that Christian Walther added (for mac keyboard?).
	ScanBrightnessDown Scancode = C.SDL_SCANCODE_BRIGHTNESSDOWN
	ScanBrightnessUp   Scancode = C.SDL_SCANCODE_BRIGHTNESSUP
	// display mirroring/dual display switch, video mode switch
	ScanDisplaySwitch Scancode = C.SDL_SCANCODE_DISPLAYSWITCH
	ScanKbIllumToggle Scancode = C.SDL_SCANCODE_KBDILLUMTOGGLE
	ScanKbIllumDown   Scancode = C.SDL_SCANCODE_KBDILLUMDOWN
	ScanKbIllumUp     Scancode = C.SDL_SCANCODE_KBDILLUMUP
	ScanEject         Scancode = C.SDL_SCANCODE_EJECT
	ScanSleep         Scancode = C.SDL_SCANCODE_SLEEP

	ScanApp1 Scancode = C.SDL_SCANCODE_APP1
	ScanApp2 Scancode = C.SDL_SCANCODE_APP2
)


text:
module Administrate
  module Field
    class MultipleAttachment
      def self.decorate(klass)
        Class.new(klass) do
          def multiple?
            true
          end
        end
      end
    end
  end
end


text:
layout: global
displayTitle: Contributing to SystemML
title: Contributing to SystemML
description: Contributing to SystemML
---
<!--
{% comment %}
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements.  See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to you 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.
{% endcomment %}
-->

There are many ways to become involved with SystemML:

* This will become a table of contents (this text will be scraped).
{:toc}

## Mailing Lists

### Development Mailing List

Perhaps the easiest way to obtain help and contribute to SystemML is to join the SystemML Development
mailing list (dev@systemml.apache.org). You can subscribe to this list by sending an email to
[dev-subscribe@systemml.apache.org](mailto:dev-subscribe@systemml.apache.org).
You can unsubscribe from this list by sending an email to [dev-unsubscribe@systemml.apache.org](mailto:dev-unsubscribe@systemml.apache.org). The dev mailing list archive can be found
[here](http://mail-archives.apache.org/mod_mbox/systemml-dev/).

### Issues Mailing List

The issues mailing list archive can be found
[here](http://mail-archives.apache.org/mod_mbox/systemml-issues/).
To subscribe to the issues list, send an email to
[issues-subscribe@systemml.apache.org](mailto:issues-subscribe@systemml.apache.org).
To unsubscribe from the issues list, send an email to
[issues-unsubscribe@systemml.apache.org](mailto:issues-unsubscribe@systemml.apache.org).

### Commits Mailing List

The commits mailing list archive can be found
[here](http://mail-archives.apache.org/mod_mbox/systemml-commits/).
To subscribe to the issues list, send an email to
[commits-subscribe@systemml.apache.org](mailto:commits-subscribe@systemml.apache.org).
To unsubscribe from the issues list, send an email to
[commits-unsubscribe@systemml.apache.org](mailto:commits-unsubscribe@systemml.apache.org).

## Issue Tracker

Have you found a bug in SystemML? Have you thought of a way to improve SystemML? Are
you interested in working on SystemML itself? If so, the SystemML
[JIRA Issue Tracker](https://issues.apache.org/jira/browse/SYSTEMML) is the place to go.

## SystemML on GitHub

Have you found an issue on the SystemML [JIRA Issue Tracker](https://issues.apache.org/jira/browse/SYSTEMML)
that you are interested in working on?
If so, add a comment to the issue asking to be assigned the issue. If you don't hear back in a timely
fashion, please contact us on the dev mailing list and we will be happy to help you.

Once you have an issue to work on, how do you go about doing your work? The first thing you need is a GitHub
account. Once you have a GitHub account, go to the Apache SystemML GitHub site at
[https://github.com/apache/incubator-systemml](https://github.com/apache/incubator-systemml) and
click the Fork button to fork a personal remote copy of the SystemML repository to your GitHub account.

The next step is to clone your SystemML fork to your local machine.

	$ git clone https://github.com/YOUR_GITHUB_NAME/incubator-systemml.git

Following this, it's a good idea to set your git user name and email address. In addition, you may want
to set the `push.default` property to `simple`. You only need to execute these commands once.

	$ git config --global user.name "Your Name"
	$ git config --global user.email "yourname@yourhost.com"
	$ git config --global push.default simple

Next, reference the main SystemML repository as a remote repository. By convention, you can
call this `upstream`. You only need to add the remote `upstream` repository once.

	$ git remote add upstream https://github.com/apache/incubator-systemml.git

After this, you should have an `origin` repository, which references your personal forked SystemML
repository on GitHub, and the `upstream` repository, which references the main SystemML repository
on GitHub.

	$ git remote -v
	origin   https://github.com/YOUR_GITHUB_NAME/incubator-systemml.git (fetch)
	origin   https://github.com/YOUR_GITHUB_NAME/incubator-systemml.git (push)
	upstream https://github.com/apache/incubator-systemml.git (fetch)
	upstream https://github.com/apache/incubator-systemml.git (push)

The main code branch by convention is the `master` branch. You can check out the `master` branch
using the `checkout` command:

	git checkout master

To update this branch with the latest official code, you can `pull` from the `upstream` `master`
branch. A `pull` essentially does a `fetch` (retrieves code) and a `merge` (merges latest remote
changes into your local branch):

	git pull upstream master

It's recommended that you create a new, separate branch for your work based on the current `master`
branch. Give this branch a descriptive name. For example, if you were assigned the issue `SYSTEMML-101`,
you could use the `checkout -b` command to create a new branch based on the `master` branch and
check out this branch:

	git checkout -b SYSTEMML-101-my_cool_new_feature

At this point, you are ready to do your work on this branch.

If you updates involve code, you should run the complete test suite to verify that your
updates have not had unexpected side-effects in the project. You can do this via
the Maven `verify` command:

	mvn clean verify

Your commit messages should follow standard git formatting conventions. If your
commit is in regards to a particular JIRA issue, please
include a reference to the JIRA issue, such as in the following:

	git commit -m "[SYSTEMML-101] My cool new feature"

When ready, push your changes on this branch to your remote GitHub fork:

	$ git push
	fatal: The current branch SYSTEMML-101-my_cool_new_feature has no upstream branch.
	To push the current branch and set the remote as upstream, use

	    git push --set-upstream origin SYSTEMML-101-my_cool_new_feature

	$ git push --set-upstream origin SYSTEMML-101-my_cool_new_feature

At this stage, you can go to your GitHub web page and file a Pull Request for the work
that you did on this branch. A Pull Request is a request for project committers (who have
write access to Apache SystemML) to review your code and integrate your code into the project.
Typically, you will see a green button to allow you to file a Pull Request.

Once your Pull Request is opened at [SystemML Pull Requests](https://github.com/apache/incubator-systemml/pulls),
typically Jenkins will automatically build the project to see
if all tests pass when run for your particular branch. These automatic builds
can be seen [here](https://sparktc.ibmcloud.com/jenkins/job/SystemML-PullRequestBuilder/).

A conversation typically will proceed with regards to your Pull Request. Project committers and
potentially others will give you useful feedback and potentially request that some changes be made
to your code. In response, you can make the requested updates or explain why you feel that they make
sense as they are. If you make additional updates, you can commit the changes and then push
the changes to your remote branch. These updates will automatically appear in the pull request.

When your changes are accepted (a committer will write "Looks good to me", "LGTM", or something
similar), a committer will attempt to incorporate your changes into the
SystemML project. Typically this is done by squashing all of your commits into a single commit
and then rebasing your changes into the master branch. Rebasing gives a linear commit history
to the project.

If the merge in complicated, it is possible that a committer may ask you to resolve any merge
conflicts in your pull request. If any difficulties are experienced, a project committer will be
more than happy to assist in the integration of your work into the project.

After the Pull Request is closed, a comment can be added to the original JIRA issue referencing
the Pull Request, and the issue can be resolved and closed.

## Documentation

Documentation is one useful way to become involved with SystemML. SystemML online documentation
is generated from markdown using Jekyll. For more information, please see GitHub's
[Using Jekyll with Pages](https://help.github.com/articles/using-jekyll-with-pages/).

After installing Jekyll, Jekyll can be run from the `docs` folder via:

	bundle exec jekyll serve

This allows you to work on the documentation locally at http://127.0.0.1:4000.

You can allow others to preview your documentation updates on GitHub by pushing the
`docs` subtree of your branch to your remote `gh-pages` branch.

	git subtree push --prefix docs origin gh-pages

For instance, if you have filed a Pull Request for a documentation update on a regular branch,
you could additionally push the `docs` subtree to the remote `gh-pages` branch. In the Pull Request
conversation, you could include a link to the documentation that was automatically generated
when you pushed to `gh-pages`. The URL is http://<YOUR_NAME>.github.io/incubator-systemml/.

If you experience issues pushing the `docs` subtree to the `gh-pages` branch because you've
previously pushed from a different branch, one simple solution is to delete the remote `gh-pages`
branch and perform the `subtree` command again.

	git push origin --delete gh-pages

## Code Format

### Java Code Format

Java in SystemML should be formatted using a standard format. The "SystemML Format" at
`dev/code-style/systemml-style-eclipse.xml` can be imported into Eclipse and
`dev/code-style/systemml-style-intellij.xml` can be imported into IntelliJ
for this purpose.

No trailing whitespace is preferred. IDEs such as Eclipse and IntelliJ can be configured
for this option.

### DML Code Format

DML in SystemML should be formatted according to a standard format. Indentation in DML
files should be two spaces.


text:
package eldis.mdl.examples.ex2

import eldis.react.{ FunctionalComponent, React, ReactDOMElement }
import eldis.react.mdl.components.{ Dialog, DialogActions, Label, RaisedButton }
import eldis.react.vdom.prefix_<^.<
import eldis.redux.Dispatcher
import eldis.redux.react.eldis.connect

sealed trait DialogType
object DialogType {
  case object SimpleDialog extends DialogType
  case object SecondDialog extends DialogType
  case object DialogWithCancel extends DialogType
}

object TestDialog {
  private case class Props(
    dlgType: Option[DialogType],
    onCloseDialog: () => Unit
  )

  private val component = FunctionalComponent[Props]("UserForm") { props =>
    {
      props.dlgType match {
        case Some(DialogType.SimpleDialog) =>
          Dialog(Some("Simple"), true, className = "width-30-em" :: Nil,
            Seq(
              RaisedButton("Some Button"),
              RaisedButton("CLOSE", onClick = Some(props.onCloseDialog))
            ))(Label("Simple Dialog"))

        case Some(DialogType.SecondDialog) =>
          Dialog(Some("fullWidth Buttons"), true, "width-30-em" :: Nil,
            Seq(
              RaisedButton("Some Button"),
              RaisedButton("CLOSE", onClick = Some(props.onCloseDialog))
            ),
            actionsProps = DialogActions.Props(fullWidth = Some(true)))(Label("Dialog with fullWidth Buttons"))

        case Some(DialogType.DialogWithCancel) =>
          Dialog(Some("With Cancel"), true, "width-30-em" :: Nil,
            Seq(
              RaisedButton("Some Button"),
              RaisedButton("CLOSE", onClick = Some(props.onCloseDialog))
            ),
            Some(props.onCloseDialog))(Label("Dialog with cancel action"))
        case _ => <.div()()
      }
    }
  }

  private val connectedComponent: FunctionalComponent[Unit] = connect(
    (dispatch: Dispatcher[Action]) => {
      val onDlgClose = () => dispatch(CloseDlg)
      (s: State) => Props(s.testForm.dlgType, onDlgClose)
    },
    component
  )

  def apply(): ReactDOMElement = React.createElement(connectedComponent, ())
}


text:
class UNIX_RemoveFileActionFixture :
	public CIMFixtureBase
{
public:
	UNIX_RemoveFileActionFixture();
	~UNIX_RemoveFileActionFixture();
	virtual void Run();

};