text:
package io.dropwizard.java8.validation.valuehandling;

import com.fasterxml.classmate.ResolvedType;
import com.fasterxml.classmate.TypeResolver;
import org.hibernate.validator.spi.valuehandling.ValidatedValueUnwrapper;

import java.lang.reflect.Type;
import java.util.Optional;

/**
 * A {@link ValidatedValueUnwrapper} for {@link Optional}.
 * <p>
 * Extracts the value contained by the {@link Optional} for validation, or produces {@code null}.
 */
public class OptionalValidatedValueUnwrapper extends ValidatedValueUnwrapper<Optional<?>> {

    private final TypeResolver resolver = new TypeResolver();

    @Override
    public Object handleValidatedValue(final Optional<?> optional) {
        return optional.orElse(null);
    }

    @Override
    public Type getValidatedValueType(final Type type) {
        ResolvedType resolvedType = resolver.resolve(type);
        return resolvedType.typeParametersFor(Optional.class).get(0).getErasedType();
    }
}

redpajama_set_name: RedPajamaGithub


text:
class Object
  # Define a new method and instance variable named as +object_name+ parameter.
  def self.inject(object_name)
    instance_eval do
      send(:define_method, object_name) do
        instance_variable_set("@#{object_name}", Syringe::Container.default[object_name])
      end
    end
  end
end


text:
package me.yoonjae.solar.kuiper.test;

import android.support.v7.app.AppCompatActivity;
import android.widget.Button;

import me.yoonjae.solar.kuiper.annotation.Inject;

@Inject(value = R.class, base = true)
public class BaseActivity extends AppCompatActivity {
    Button mButton; // R.id.button
}


text:
html {
  position: relative;
  min-height: 100%;
}

body {
  /* Margin bottom by footer height */
  margin-bottom: 70px;
  padding-top: 50px;
}
.starter-template {
  padding: 40px 15px;
  text-align: center;
}
#footer {
  position: absolute;
  bottom: 0;
  width: 100%;
  height: 70px;
  background-color: #f5f5f5;
}

.container-title {
	text-align: center;
}

/* Sign In Form */
.form-signin {
  max-width: 330px;
  padding: 15px;
  margin: 0 auto;
}
.form-signin .form-signin-heading,
.form-signin .checkbox {
  margin-bottom: 10px;
}
.form-signin .checkbox {
  font-weight: normal;
}
.form-signin .form-control {
  position: relative;
  height: auto;
  -webkit-box-sizing: border-box;
     -moz-box-sizing: border-box;
          box-sizing: border-box;
  padding: 10px;
  font-size: 16px;
}
.form-signin .form-control:focus {
  z-index: 2;
}
.form-signin input[type="email"] {
  margin-bottom: -1px;
  border-bottom-right-radius: 0;
  border-bottom-left-radius: 0;
}
.form-signin input[type="password"] {
  margin-bottom: 10px;
  border-top-left-radius: 0;
  border-top-right-radius: 0;
}

.submissionPanel {
  margin-top: 0.2em;
}

.commentSection {
  text-align: center;
  /* TODO: improve positioning */
}

.commentBoxContainer {
  margin-top: 1em;
  text-align: center;
  width: 40%;
  margin-left: auto;
  margin-right: auto;
}

.commentBox {
  width: 100%;
}

#mainContainer {
  margin-top: 1.5em;
}

#edit-button {
  float: right;
}

.submit-button {
  float: right;
}

td.submissionDetails {
  text-align: center;
}

.comments {
  padding-top: 1em;
}

.comment {
  width: 35%;
  margin-left: auto;
  margin-right: auto;
}


text:
from __future__ import unicode_literals

import unittest
import unicodedata

import epitran

class TestPortuguese(unittest.TestCase):
    def setUp(self):
        self.epi = epitran.Epitran('por-Latn')

    def test_brasil(self):
        tr = self.epi.transliterate('Brasil')
        self.assertEqual(tr, 'bɾɐzil')

    def test_boia(self):
        tr = self.epi.transliterate('bóia')
        self.assertEqual(tr, 'bɔjɐ')

    def test_orgao(self):
        tr = self.epi.transliterate('órgão')
        self.assertEqual(tr, 'ɔɾɡɐ̃w̃')

    def test_convem(self):
        tr = self.epi.transliterate('convêm')
        self.assertEqual(tr, unicodedata.normalize('NFC', 'konvẽ'))

    def test_guitarra(self):
        tr = self.epi.transliterate('guitarra')
        self.assertEqual(tr, 'ɡʷitɐʁɐ')


text:
package com.puzzletimer.gui;

import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Insets;
import java.awt.LayoutManager;

public class WrapLayout implements LayoutManager {
    private final int xGap;
    private final int yGap;

    public WrapLayout(int xGap, int yGap) {
        this.xGap = xGap;
        this.yGap = yGap;
    }

    @Override
    public void addLayoutComponent(String name, Component component) {
    }

    @Override
    public void removeLayoutComponent(Component component) {
    }

    @Override
    public Dimension minimumLayoutSize(Container target) {
        int minHeight = 0;

        Insets insets = target.getInsets();
        int maxWidth = target.getWidth();

        int nComponents = target.getComponentCount();
        int x = insets.left;
        int y = insets.top;

        for (int i = 0; i < nComponents; i++) {
            Component component = target.getComponent(i);
            int w = (int) component.getPreferredSize().getWidth();
            int h = (int) component.getPreferredSize().getHeight();

            minHeight = Math.max(minHeight, y + h);

            if (x + w + insets.right > maxWidth) {
                x = insets.left;
                y += h + this.yGap;
            }

            x += w + this.xGap;
        }

        return new Dimension(0, minHeight);
    }

    @Override
    public Dimension preferredLayoutSize(Container target) {
        return minimumLayoutSize(target);
    }

    @Override
    public void layoutContainer(Container target) {
        synchronized (target.getTreeLock()) {
            Insets insets = target.getInsets();
            int maxWidth = target.getWidth();

            int nComponents = target.getComponentCount();
            int firstComponent = 0;
            int x = insets.left;
            int y = insets.top;

            for (int i = 0; i < nComponents; i++) {
                Component component = target.getComponent(i);
                int w = (int) component.getPreferredSize().getWidth();
                int h = (int) component.getPreferredSize().getHeight();

                if (x + w + insets.right > maxWidth) {
                    int d = (maxWidth - (x - this.xGap) - insets.right) / 2;
                    for (int j = firstComponent; j < i; j++) {
                        Component c = target.getComponent(j);
                        c.setLocation(c.getX() + d, c.getY());
                    }

                    firstComponent = i;
                    x = insets.left;
                    y += h + this.yGap;
                }

                component.setBounds(x, y, w, h);

                x += w + this.xGap;
            }

            int d = (maxWidth - (x - this.xGap) - insets.right) / 2;
            for (int j = firstComponent; j < nComponents; j++) {
                Component c = target.getComponent(j);
                c.setLocation(c.getX() + d, c.getY());
            }
        }
    }
}


text:
#include "s2n_test.h"

#include <s2n.h>

#include "crypto/s2n_ecc_evp.h"
#include "stuffer/s2n_stuffer.h"
#include "testlib/s2n_testlib.h"
#include "utils/s2n_mem.h"

#define ECDHE_PARAMS_LEGACY_FORM 4

int main(int argc, char **argv) {
    BEGIN_TEST();
    {
        /* Test generate ephemeral keys for all supported curves */
        for (int i = 0; i < s2n_ecc_evp_supported_curves_list_len; i++) {
            struct s2n_ecc_evp_params evp_params = {0};
            /* Server generates a key */
            evp_params.negotiated_curve = s2n_ecc_evp_supported_curves_list[i];
            EXPECT_SUCCESS(s2n_ecc_evp_generate_ephemeral_key(&evp_params));
            EXPECT_SUCCESS(s2n_ecc_evp_params_free(&evp_params));
        }
    }
    {
        /* Test failure case for generate ephemeral key  when the negotiated curve is not set */
        for (int i = 0; i < s2n_ecc_evp_supported_curves_list_len; i++) {
            struct s2n_ecc_evp_params evp_params = {0};
            /* Server generates a key */
            evp_params.negotiated_curve = NULL;
            EXPECT_FAILURE(s2n_ecc_evp_generate_ephemeral_key(&evp_params));
            EXPECT_SUCCESS(s2n_ecc_evp_params_free(&evp_params));
        }
    }
    {
        /* Test generate ephemeral key and compute shared key for all supported curves */
        for (int i = 0; i < s2n_ecc_evp_supported_curves_list_len; i++) {
            struct s2n_ecc_evp_params server_params = {0};
            struct s2n_ecc_evp_params client_params = {0};
            struct s2n_blob server_shared = {0};
            struct s2n_blob client_shared = {0};

            /* Server generates a key */
            server_params.negotiated_curve = s2n_ecc_evp_supported_curves_list[i];
            EXPECT_SUCCESS(s2n_ecc_evp_generate_ephemeral_key(&server_params));

            /* Client generates a key */
            client_params.negotiated_curve = s2n_ecc_evp_supported_curves_list[i];
            EXPECT_SUCCESS(s2n_ecc_evp_generate_ephemeral_key(&client_params));

            /* Compute shared secret for server */
            EXPECT_SUCCESS(
                s2n_ecc_evp_compute_shared_secret_from_params(&server_params, &client_params, &server_shared));

            /* Compute shared secret for client */
            EXPECT_SUCCESS(
                s2n_ecc_evp_compute_shared_secret_from_params(&client_params, &server_params, &client_shared));

            /* Check if the shared secret computed is the same for the client
             * and the server */
            EXPECT_EQUAL(client_shared.size, server_shared.size);
            EXPECT_BYTEARRAY_EQUAL(client_shared.data, server_shared.data, client_shared.size);

            /* Clean up */
            EXPECT_SUCCESS(s2n_free(&server_shared));
            EXPECT_SUCCESS(s2n_free(&client_shared));
            EXPECT_SUCCESS(s2n_ecc_evp_params_free(&server_params));
            EXPECT_SUCCESS(s2n_ecc_evp_params_free(&client_params));
        }
    }
    {
        /* Test failure case for computing shared key for all supported curves when the server
        and client curves donot match */
        for (int i = 0; i < s2n_ecc_evp_supported_curves_list_len; i++) {
            for (int j = 0; j < s2n_ecc_evp_supported_curves_list_len; j++) {
                struct s2n_ecc_evp_params server_params = {0};
                struct s2n_ecc_evp_params client_params = {0};
                struct s2n_blob server_shared = {0};
                struct s2n_blob client_shared = {0};
                if (i == j) {
                    continue;
                }

                /* Server generates a key */
                server_params.negotiated_curve = s2n_ecc_evp_supported_curves_list[j];

                EXPECT_SUCCESS(s2n_ecc_evp_generate_ephemeral_key(&server_params));

                /* Client generates a key */
                client_params.negotiated_curve = s2n_ecc_evp_supported_curves_list[i];
                EXPECT_SUCCESS(s2n_ecc_evp_generate_ephemeral_key(&client_params));

                /* Compute shared secret for server */
                EXPECT_FAILURE(
                    s2n_ecc_evp_compute_shared_secret_from_params(&server_params, &client_params, &server_shared));

                /* Compute shared secret for client */
                EXPECT_FAILURE(
                    s2n_ecc_evp_compute_shared_secret_from_params(&client_params, &server_params, &client_shared));

                /* Clean up */
                EXPECT_SUCCESS(s2n_ecc_evp_params_free(&server_params));
                EXPECT_SUCCESS(s2n_ecc_evp_params_free(&client_params));
            }
        }
    }
    {
        /* Test s2n_ecc_evp_write_params_point for all supported curves */
        for (int i = 0; i < s2n_ecc_evp_supported_curves_list_len; i++) {
            struct s2n_ecc_evp_params test_params = {0};
            struct s2n_stuffer wire;
            uint8_t legacy_form;

            EXPECT_SUCCESS(s2n_stuffer_growable_alloc(&wire, 0));

            /* Server generates a key for a given curve */
            test_params.negotiated_curve = s2n_ecc_evp_supported_curves_list[i];
            EXPECT_SUCCESS(s2n_ecc_evp_generate_ephemeral_key(&test_params));
            EXPECT_SUCCESS(s2n_ecc_evp_write_params_point(&test_params, &wire));

            /* Verify output is of the right length */
            uint32_t avail = s2n_stuffer_data_available(&wire);
            EXPECT_EQUAL(avail, s2n_ecc_evp_supported_curves_list[i]->share_size);

            /* Verify output starts with the known legacy form for curves secp256r1
             * and secp384r1*/
            if (s2n_ecc_evp_supported_curves_list[i]->iana_id == TLS_EC_CURVE_SECP_256_R1 ||
                s2n_ecc_evp_supported_curves_list[i]->iana_id == TLS_EC_CURVE_SECP_384_R1) {
                EXPECT_SUCCESS(s2n_stuffer_read_uint8(&wire, &legacy_form));
                EXPECT_EQUAL(legacy_form, ECDHE_PARAMS_LEGACY_FORM);
            }

            /* Clean up */
            EXPECT_SUCCESS(s2n_ecc_evp_params_free(&test_params));
            EXPECT_SUCCESS(s2n_stuffer_free(&wire));
        }
    }
    {
        /* TEST s2n_ecc_evp_read_params_point for all supported curves */
        for (int i = 0; i < s2n_ecc_evp_supported_curves_list_len; i++) {
            struct s2n_ecc_evp_params write_params = {0};
            struct s2n_blob point_blob;
            struct s2n_stuffer wire;

            EXPECT_SUCCESS(s2n_stuffer_growable_alloc(&wire, 0));

            /* Server generates a key for a given curve */
            write_params.negotiated_curve = s2n_ecc_evp_supported_curves_list[i];
            EXPECT_SUCCESS(s2n_ecc_evp_generate_ephemeral_key(&write_params));
            EXPECT_SUCCESS(s2n_ecc_evp_write_params_point(&write_params, &wire));

            /* Read point back in */
            EXPECT_SUCCESS(
                s2n_ecc_evp_read_params_point(&wire, s2n_ecc_evp_supported_curves_list[i]->share_size, &point_blob));

            /* Check that the blob looks generally correct. */
            EXPECT_EQUAL(point_blob.size, s2n_ecc_evp_supported_curves_list[i]->share_size);
            EXPECT_NOT_NULL(point_blob.data);

            EXPECT_SUCCESS(s2n_ecc_evp_params_free(&write_params));
            EXPECT_SUCCESS(s2n_stuffer_free(&wire));
        }
    }
    {
        /* TEST s2n_ecc_evp_parse_params_point for all supported curves */
        for (int i = 0; i < s2n_ecc_evp_supported_curves_list_len; i++) {
            struct s2n_ecc_evp_params write_params = {0};
            struct s2n_ecc_evp_params read_params = {0};
            struct s2n_blob point_blob;
            struct s2n_stuffer wire;

            EXPECT_SUCCESS(s2n_stuffer_growable_alloc(&wire, 0));

            write_params.negotiated_curve = s2n_ecc_evp_supported_curves_list[i];
            read_params.negotiated_curve = s2n_ecc_evp_supported_curves_list[i];

            /* Server generates a key for a given curve */
            EXPECT_SUCCESS(s2n_ecc_evp_generate_ephemeral_key(&write_params));
            EXPECT_SUCCESS(s2n_ecc_evp_write_params_point(&write_params, &wire));

            /* Read point back in */
            EXPECT_SUCCESS(
                s2n_ecc_evp_read_params_point(&wire, s2n_ecc_evp_supported_curves_list[i]->share_size, &point_blob));
            EXPECT_SUCCESS(s2n_ecc_evp_parse_params_point(&point_blob, &read_params));
            /* Check that the point we read is the same we wrote */
            EXPECT_TRUE(EVP_PKEY_cmp(write_params.evp_pkey, read_params.evp_pkey));

            /* Clean up */
            EXPECT_SUCCESS(s2n_ecc_evp_params_free(&write_params));
            EXPECT_SUCCESS(s2n_ecc_evp_params_free(&read_params));
            EXPECT_SUCCESS(s2n_stuffer_free(&wire));
        }
    }
    {
        /* Test read/write/parse params for all supported curves */
        for (int i = 0; i < s2n_ecc_evp_supported_curves_list_len; i++) {
            struct s2n_ecc_evp_params write_params = {0};
            struct s2n_ecc_evp_params read_params = {0};
            struct s2n_stuffer wire;
            struct s2n_blob ecdh_params_sent, ecdh_params_received;

            EXPECT_SUCCESS(s2n_stuffer_growable_alloc(&wire, 1024));

            write_params.negotiated_curve = s2n_ecc_evp_supported_curves_list[i];
            read_params.negotiated_curve = s2n_ecc_evp_supported_curves_list[i];

            /* Server generates a key for a given curve */
            EXPECT_SUCCESS(s2n_ecc_evp_generate_ephemeral_key(&write_params));

             /* Write params points to wire */
            EXPECT_SUCCESS(s2n_ecc_evp_write_params(&write_params, &wire, &ecdh_params_sent));
            struct s2n_ecdhe_raw_server_params ecdhe_data = {0};

             /* Read params points from the wire */
            EXPECT_SUCCESS(s2n_ecc_evp_read_params(&wire, &ecdh_params_received, &ecdhe_data));
            EXPECT_SUCCESS(s2n_ecc_evp_parse_params(&ecdhe_data, &read_params));

            /* Check that the point we read is the same we wrote */
            EXPECT_TRUE(EVP_PKEY_cmp(write_params.evp_pkey, read_params.evp_pkey));

            /* Clean up */
            EXPECT_SUCCESS(s2n_stuffer_free(&wire));
            EXPECT_SUCCESS(s2n_ecc_evp_params_free(&write_params));
            EXPECT_SUCCESS(s2n_ecc_evp_params_free(&read_params));
        }
    }
    {
        /* Test generate/read/write/parse and compute shared secrets for all supported curves */
        for (int i = 0; i < s2n_ecc_evp_supported_curves_list_len; i++) {
            struct s2n_ecc_evp_params server_params = {0};
            struct s2n_ecc_evp_params read_params = {0};
            struct s2n_ecc_evp_params client_params = {0};
            struct s2n_stuffer wire;
            struct s2n_blob ecdh_params_sent, ecdh_params_received;
            struct s2n_blob server_shared_secret, client_shared_secret;

            EXPECT_SUCCESS(s2n_stuffer_growable_alloc(&wire, 1024));

            server_params.negotiated_curve = s2n_ecc_evp_supported_curves_list[i];
            read_params.negotiated_curve = s2n_ecc_evp_supported_curves_list[i];

            /* Server generates a key for a given curve */
            EXPECT_SUCCESS(s2n_ecc_evp_generate_ephemeral_key(&server_params));

            /* Server sends the public */
            EXPECT_SUCCESS(s2n_ecc_evp_write_params(&server_params, &wire, &ecdh_params_sent));

            /* Client reads the public */
            struct s2n_ecdhe_raw_server_params ecdhe_data = {0};
            EXPECT_SUCCESS(s2n_ecc_evp_read_params(&wire, &ecdh_params_received, &ecdhe_data));
            EXPECT_SUCCESS(s2n_ecc_evp_parse_params(&ecdhe_data, &read_params));

            /* Verify if the client correctly read the server public */
            EXPECT_TRUE(EVP_PKEY_cmp(server_params.evp_pkey, read_params.evp_pkey));

             /* Client generates its key for the given curve */
            client_params.negotiated_curve =s2n_ecc_evp_supported_curves_list[i];
            EXPECT_SUCCESS(s2n_ecc_evp_generate_ephemeral_key(&client_params));

            /* Compute shared secret for the server */
            EXPECT_SUCCESS(
                s2n_ecc_evp_compute_shared_secret_from_params(&server_params, &client_params, &server_shared_secret));

            /* Compute shared secret for the client */
            EXPECT_SUCCESS(
                s2n_ecc_evp_compute_shared_secret_from_params(&client_params, &read_params, &client_shared_secret));

             /* Verify that shared is the same for the client and the server */
            EXPECT_EQUAL(client_shared_secret.size, server_shared_secret.size);
            EXPECT_BYTEARRAY_EQUAL(client_shared_secret.data, server_shared_secret.data, client_shared_secret.size);

            /* Clean up */
            EXPECT_SUCCESS(s2n_stuffer_free(&wire));
            EXPECT_SUCCESS(s2n_free(&server_shared_secret));
            EXPECT_SUCCESS(s2n_free(&client_shared_secret));
            EXPECT_SUCCESS(s2n_ecc_evp_params_free(&server_params));
            EXPECT_SUCCESS(s2n_ecc_evp_params_free(&read_params));
            EXPECT_SUCCESS(s2n_ecc_evp_params_free(&client_params));
        }
    }
    {
        /* Test generate->write->read->compute_shared with all supported curves */
    for (int i = 0; i < s2n_ecc_evp_supported_curves_list_len; i++) {
            struct s2n_ecc_evp_params server_params = {0}, client_params = {0};
            struct s2n_stuffer wire;
            struct s2n_blob server_shared, client_shared, ecdh_params_sent, ecdh_params_received;

            EXPECT_SUCCESS(s2n_stuffer_growable_alloc(&wire, 1024));

            /* Server generates a key for a given curve */
            server_params.negotiated_curve = s2n_ecc_evp_supported_curves_list[i];
            EXPECT_SUCCESS(s2n_ecc_evp_generate_ephemeral_key(&server_params));
            /* Server sends the public */
            EXPECT_SUCCESS(s2n_ecc_evp_write_params(&server_params, &wire, &ecdh_params_sent));
            /* Client reads the public */
            struct s2n_ecdhe_raw_server_params ecdhe_data = {0};
            EXPECT_SUCCESS(s2n_ecc_evp_read_params(&wire, &ecdh_params_received, &ecdhe_data));
            EXPECT_SUCCESS(s2n_ecc_evp_parse_params(&ecdhe_data, &client_params));

            /* The client got the curve */
            EXPECT_EQUAL(client_params.negotiated_curve, server_params.negotiated_curve);

            /* Client sends its public */
            EXPECT_SUCCESS(s2n_ecc_evp_compute_shared_secret_as_client(&client_params, &wire, &client_shared));
            /* Server receives it */
            EXPECT_SUCCESS(s2n_ecc_evp_compute_shared_secret_as_server(&server_params, &wire, &server_shared));
            /* Shared is the same for the client and the server */
            EXPECT_EQUAL(client_shared.size, server_shared.size);
            EXPECT_BYTEARRAY_EQUAL(client_shared.data, server_shared.data, client_shared.size);

            /* Clean up */
            EXPECT_SUCCESS(s2n_stuffer_free(&wire));
            EXPECT_SUCCESS(s2n_free(&server_shared));
            EXPECT_SUCCESS(s2n_free(&client_shared));
            EXPECT_SUCCESS(s2n_ecc_evp_params_free(&server_params));
            EXPECT_SUCCESS(s2n_ecc_evp_params_free(&client_params));
        }
    }

    END_TEST();
}


text:
/**
 * Annotation based mapping loader.
 */
package org.beanio.internal.config.annotation;


text:
package storage // import "miniflux.app/storage"

import (
	"database/sql"
	"fmt"

	"golang.org/x/crypto/bcrypt"
	"miniflux.app/model"
)

// HasDuplicateFeverUsername checks if another user have the same Fever username.
func (s *Storage) HasDuplicateFeverUsername(userID int64, feverUsername string) bool {
	query := `SELECT true FROM integrations WHERE user_id != $1 AND fever_username=$2`
	var result bool
	s.db.QueryRow(query, userID, feverUsername).Scan(&result)
	return result
}

// HasDuplicateGoogleReaderUsername checks if another user have the same Google Reader username.
func (s *Storage) HasDuplicateGoogleReaderUsername(userID int64, googleReaderUsername string) bool {
	query := `SELECT true FROM integrations WHERE user_id != $1 AND googlereader_username=$2`
	var result bool
	s.db.QueryRow(query, userID, googleReaderUsername).Scan(&result)
	return result
}

// UserByFeverToken returns a user by using the Fever API token.
func (s *Storage) UserByFeverToken(token string) (*model.User, error) {
	query := `
		SELECT
			users.id, users.is_admin, users.timezone
		FROM
			users
		LEFT JOIN
			integrations ON integrations.user_id=users.id
		WHERE
			integrations.fever_enabled='t' AND lower(integrations.fever_token)=lower($1)
	`

	var user model.User
	err := s.db.QueryRow(query, token).Scan(&user.ID, &user.IsAdmin, &user.Timezone)
	switch {
	case err == sql.ErrNoRows:
		return nil, nil
	case err != nil:
		return nil, fmt.Errorf("store: unable to fetch user: %v", err)
	default:
		return &user, nil
	}
}

// GoogleReaderUserCheckPassword validates the Google Reader hashed password.
func (s *Storage) GoogleReaderUserCheckPassword(username, password string) error {
	var hash string

	query := `
		SELECT
			googlereader_password
		FROM
			integrations
		WHERE
			integrations.googlereader_enabled='t' AND integrations.googlereader_username=$1
	`

	err := s.db.QueryRow(query, username).Scan(&hash)
	if err == sql.ErrNoRows {
		return fmt.Errorf(`store: unable to find this user: %s`, username)
	} else if err != nil {
		return fmt.Errorf(`store: unable to fetch user: %v`, err)
	}

	if err := bcrypt.CompareHashAndPassword([]byte(hash), []byte(password)); err != nil {
		return fmt.Errorf(`store: invalid password for "%s" (%v)`, username, err)
	}

	return nil
}

// GoogleReaderUserGetIntegration returns part of the Google Reader parts of the integration struct.
func (s *Storage) GoogleReaderUserGetIntegration(username string) (*model.Integration, error) {
	var integration model.Integration

	query := `
		SELECT
			user_id,
			googlereader_enabled,
			googlereader_username,
			googlereader_password
		FROM
			integrations
		WHERE
			integrations.googlereader_enabled='t' AND integrations.googlereader_username=$1
	`

	err := s.db.QueryRow(query, username).Scan(&integration.UserID, &integration.GoogleReaderEnabled, &integration.GoogleReaderUsername, &integration.GoogleReaderPassword)
	if err == sql.ErrNoRows {
		return &integration, fmt.Errorf(`store: unable to find this user: %s`, username)
	} else if err != nil {
		return &integration, fmt.Errorf(`store: unable to fetch user: %v`, err)
	}

	return &integration, nil
}

// Integration returns user integration settings.
func (s *Storage) Integration(userID int64) (*model.Integration, error) {
	query := `
		SELECT
			user_id,
			pinboard_enabled,
			pinboard_token,
			pinboard_tags,
			pinboard_mark_as_unread,
			instapaper_enabled,
			instapaper_username,
			instapaper_password,
			fever_enabled,
			fever_username,
			fever_token,
			googlereader_enabled,
			googlereader_username,
			googlereader_password,
			wallabag_enabled,
			wallabag_url,
			wallabag_client_id,
			wallabag_client_secret,
			wallabag_username,
			wallabag_password,
			nunux_keeper_enabled,
			nunux_keeper_url,
			nunux_keeper_api_key,
			pocket_enabled,
			pocket_access_token,
			pocket_consumer_key,
			telegram_bot_enabled,
			telegram_bot_token,
			telegram_bot_chat_id
		FROM
			integrations
		WHERE
			user_id=$1
	`
	var integration model.Integration
	err := s.db.QueryRow(query, userID).Scan(
		&integration.UserID,
		&integration.PinboardEnabled,
		&integration.PinboardToken,
		&integration.PinboardTags,
		&integration.PinboardMarkAsUnread,
		&integration.InstapaperEnabled,
		&integration.InstapaperUsername,
		&integration.InstapaperPassword,
		&integration.FeverEnabled,
		&integration.FeverUsername,
		&integration.FeverToken,
		&integration.GoogleReaderEnabled,
		&integration.GoogleReaderUsername,
		&integration.GoogleReaderPassword,
		&integration.WallabagEnabled,
		&integration.WallabagURL,
		&integration.WallabagClientID,
		&integration.WallabagClientSecret,
		&integration.WallabagUsername,
		&integration.WallabagPassword,
		&integration.NunuxKeeperEnabled,
		&integration.NunuxKeeperURL,
		&integration.NunuxKeeperAPIKey,
		&integration.PocketEnabled,
		&integration.PocketAccessToken,
		&integration.PocketConsumerKey,
		&integration.TelegramBotEnabled,
		&integration.TelegramBotToken,
		&integration.TelegramBotChatID,
	)
	switch {
	case err == sql.ErrNoRows:
		return &integration, nil
	case err != nil:
		return &integration, fmt.Errorf(`store: unable to fetch integration row: %v`, err)
	default:
		return &integration, nil
	}
}

// UpdateIntegration saves user integration settings.
func (s *Storage) UpdateIntegration(integration *model.Integration) error {
	var err error
	if integration.GoogleReaderPassword != "" {
		integration.GoogleReaderPassword, err = hashPassword(integration.GoogleReaderPassword)
		if err != nil {
			return err
		}
		query := `
		UPDATE
			integrations
		SET
			pinboard_enabled=$1,
			pinboard_token=$2,
			pinboard_tags=$3,
			pinboard_mark_as_unread=$4,
			instapaper_enabled=$5,
			instapaper_username=$6,
			instapaper_password=$7,
			fever_enabled=$8,
			fever_username=$9,
			fever_token=$10,
			wallabag_enabled=$11,
			wallabag_url=$12,
			wallabag_client_id=$13,
			wallabag_client_secret=$14,
			wallabag_username=$15,
			wallabag_password=$16,
			nunux_keeper_enabled=$17,
			nunux_keeper_url=$18,
			nunux_keeper_api_key=$19,
			pocket_enabled=$20,
			pocket_access_token=$21,
			pocket_consumer_key=$22,
			googlereader_enabled=$23,
			googlereader_username=$24,
			googlereader_password=$25,
			telegram_bot_enabled=$26,
			telegram_bot_token=$27,
			telegram_bot_chat_id=$28
		WHERE
			user_id=$29
	`
		_, err = s.db.Exec(
			query,
			integration.PinboardEnabled,
			integration.PinboardToken,
			integration.PinboardTags,
			integration.PinboardMarkAsUnread,
			integration.InstapaperEnabled,
			integration.InstapaperUsername,
			integration.InstapaperPassword,
			integration.FeverEnabled,
			integration.FeverUsername,
			integration.FeverToken,
			integration.WallabagEnabled,
			integration.WallabagURL,
			integration.WallabagClientID,
			integration.WallabagClientSecret,
			integration.WallabagUsername,
			integration.WallabagPassword,
			integration.NunuxKeeperEnabled,
			integration.NunuxKeeperURL,
			integration.NunuxKeeperAPIKey,
			integration.PocketEnabled,
			integration.PocketAccessToken,
			integration.PocketConsumerKey,
			integration.GoogleReaderEnabled,
			integration.GoogleReaderUsername,
			integration.GoogleReaderPassword,
			integration.TelegramBotEnabled,
			integration.TelegramBotToken,
			integration.TelegramBotChatID,
			integration.UserID,
		)
	} else {
		query := `
		UPDATE
			integrations
		SET
			pinboard_enabled=$1,
			pinboard_token=$2,
			pinboard_tags=$3,
			pinboard_mark_as_unread=$4,
			instapaper_enabled=$5,
			instapaper_username=$6,
			instapaper_password=$7,
			fever_enabled=$8,
			fever_username=$9,
			fever_token=$10,
			wallabag_enabled=$11,
			wallabag_url=$12,
			wallabag_client_id=$13,
			wallabag_client_secret=$14,
			wallabag_username=$15,
			wallabag_password=$16,
			nunux_keeper_enabled=$17,
			nunux_keeper_url=$18,
			nunux_keeper_api_key=$19,
			pocket_enabled=$20,
			pocket_access_token=$21,
			pocket_consumer_key=$22,
			googlereader_enabled=$23,
			googlereader_username=$24,
		    googlereader_password=$25,
			telegram_bot_enabled=$26,
			telegram_bot_token=$27,
			telegram_bot_chat_id=$28
		WHERE
			user_id=$29
	`
		_, err = s.db.Exec(
			query,
			integration.PinboardEnabled,
			integration.PinboardToken,
			integration.PinboardTags,
			integration.PinboardMarkAsUnread,
			integration.InstapaperEnabled,
			integration.InstapaperUsername,
			integration.InstapaperPassword,
			integration.FeverEnabled,
			integration.FeverUsername,
			integration.FeverToken,
			integration.WallabagEnabled,
			integration.WallabagURL,
			integration.WallabagClientID,
			integration.WallabagClientSecret,
			integration.WallabagUsername,
			integration.WallabagPassword,
			integration.NunuxKeeperEnabled,
			integration.NunuxKeeperURL,
			integration.NunuxKeeperAPIKey,
			integration.PocketEnabled,
			integration.PocketAccessToken,
			integration.PocketConsumerKey,
			integration.GoogleReaderEnabled,
			integration.GoogleReaderUsername,
			integration.GoogleReaderPassword,
			integration.TelegramBotEnabled,
			integration.TelegramBotToken,
			integration.TelegramBotChatID,
			integration.UserID,
		)
	}

	if err != nil {
		return fmt.Errorf(`store: unable to update integration row: %v`, err)
	}

	return nil
}

// HasSaveEntry returns true if the given user can save articles to third-parties.
func (s *Storage) HasSaveEntry(userID int64) (result bool) {
	query := `
		SELECT
			true
		FROM
			integrations
		WHERE
			user_id=$1
		AND
			(pinboard_enabled='t' OR instapaper_enabled='t' OR wallabag_enabled='t' OR nunux_keeper_enabled='t' OR pocket_enabled='t')
	`
	if err := s.db.QueryRow(query, userID).Scan(&result); err != nil {
		result = false
	}

	return result
}


text:
.class Lcom/android/server/BatteryService$7;
.super Landroid/os/UEventObserver;
.source "BatteryService.java"

# annotations
.annotation system Ldalvik/annotation/EnclosingMethod;
    value = Lcom/android/server/BatteryService;-><init>(Landroid/content/Context;)V
.end annotation

.annotation system Ldalvik/annotation/InnerClass;
    accessFlags = 0x0
    name = null
.end annotation

# instance fields
.field final synthetic this$0:Lcom/android/server/BatteryService;

# direct methods
.method constructor <init>(Lcom/android/server/BatteryService;)V
    .locals 0

    iput-object p1, p0, Lcom/android/server/BatteryService$7;->this$0:Lcom/android/server/BatteryService;

    invoke-direct {p0}, Landroid/os/UEventObserver;-><init>()V

    return-void
.end method

# virtual methods
.method public onUEvent(Landroid/os/UEventObserver$UEvent;)V
    .locals 3

    const-string/jumbo v1, "1"

    const-string/jumbo v2, "SWITCH_STATE"

    invoke-virtual {p1, v2}, Landroid/os/UEventObserver$UEvent;->get(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v2

    invoke-virtual {v1, v2}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

    move-result v1

    if-eqz v1, :cond_1

    const/4 v0, 0x1

    :goto_0
    iget-object v1, p0, Lcom/android/server/BatteryService$7;->this$0:Lcom/android/server/BatteryService;

    invoke-static {v1}, Lcom/android/server/BatteryService;->-get19(Lcom/android/server/BatteryService;)Ljava/lang/Object;

    move-result-object v2

    monitor-enter v2

    :try_start_0
    iget-object v1, p0, Lcom/android/server/BatteryService$7;->this$0:Lcom/android/server/BatteryService;

    invoke-static {v1}, Lcom/android/server/BatteryService;->-get14(Lcom/android/server/BatteryService;)I

    move-result v1

    if-eq v1, v0, :cond_0

    iget-object v1, p0, Lcom/android/server/BatteryService$7;->this$0:Lcom/android/server/BatteryService;

    invoke-static {v1, v0}, Lcom/android/server/BatteryService;->-set3(Lcom/android/server/BatteryService;I)I
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    :cond_0
    monitor-exit v2

    return-void

    :cond_1
    const/4 v0, 0x0

    goto :goto_0

    :catchall_0
    move-exception v1

    monitor-exit v2

    throw v1
.end method


text:
require 'spec_helper'

describe Trivia::ChosenAnswer do
  before do
    User.delete_all
    Question.delete_all
    @joe = User.create(:name => 'Joe')
    @question = Question.create(:question => 'Is the cake lie?', :points => 42)
    @yes = Answer.create(:answer => 'Yes', :right => true, :question => @question)
    @no = Answer.create(:answer => 'No', :right => false, :question => @question)
  end

  context "when creating chosen answer" do
    before do
      ChosenAnswer.delete_all
    end

    it "should validate foreign keys" do
      chosen = ChosenAnswer.new
      chosen.valid?.should be_false
      chosen.errors.should include(:user)
      chosen.errors.should include(:answer)
      chosen.errors.size.should == 2

      chosen.user = @joe
      chosen.valid?.should be_false
      chosen.errors.should include(:answer)
      chosen.errors.size.should == 1

      chosen.answer = @yes
      chosen.valid?.should be_true
    end

    it "should not allow answering same question again" do
      first = ChosenAnswer.create(:user => @joe, :answer => @yes)
      first.valid?.should be_true

      # Same answer
      second = ChosenAnswer.create(:user => @joe, :answer => @yes)
      second.valid?.should be_false

      # Different answer
      third = ChosenAnswer.create(:user => @joe, :answer => @no)
      second.valid?.should be_false
    end

    it "should have same points as question if right" do
      chosen = ChosenAnswer.create(:user => @joe, :answer => @yes)
      chosen.points.should == 42
    end

    it "should have 0 points if wrong" do
      chosen = ChosenAnswer.create(:user => @joe, :answer => @no)
      chosen.new_record?.should be_false
      chosen.points.should == 0
    end

    it "should not change points if set when creating" do
      chosen = ChosenAnswer.create(:user => @joe, :answer => @yes, :points => 13)
      chosen.new_record?.should be_false
      chosen.points.should == 13
    end
  end
end


text:
package bat

import (
	"context"
	"encoding/json"
	"fmt"
	"math/rand"
	"os"
	"os/exec"
	"strings"
	"time"
)

const instanceTemplateDesc = `{ "host_id" : "{{.HostID | js }}",
    "tenant_id" : "{{.TenantID | js }}", "flavor_id" : "{{.Flavor.ID | js}}",
    "image_id" : "{{.Image.ID | js}}", "status" : "{{.Status | js}}",
    "ssh_ip" : "{{.SSHIP | js }}", "ssh_port" : {{.SSHPort}},
    "volumes" : {{tojson .OsExtendedVolumesVolumesAttached}}
    {{ $addrLen := len .Addresses.Private }}
    {{- if gt $addrLen 0 }}
      {{- with index .Addresses.Private 0 -}}
      , "private_ip" : "{{.Addr | js }}", "mac_address" : "{{.OSEXTIPSMACMacAddr | js -}}"
      {{end -}}
    {{- end }}
  }
`

// Tenant contains basic information about a tenant
type Tenant struct {
	ID   string `json:"id"`
	Name string `json:"name"`
}

// Workload contains detailed information about a workload
type Workload struct {
	ID        string `json:"id"`
	Name      string `json:"name"`
	ImageUUID string `json:"disk"`
	CPUs      int    `json:"vcpus"`
	Mem       int    `json:"ram"`
}

// Instance contains detailed information about an instance
type Instance struct {
	HostID     string   `json:"host_id"`
	TenantID   string   `json:"tenant_id"`
	FlavorID   string   `json:"flavor_id"`
	ImageID    string   `json:"image_id"`
	Status     string   `json:"status"`
	PrivateIP  string   `json:"private_ip"`
	MacAddress string   `json:"mac_address"`
	SSHIP      string   `json:"ssh_ip"`
	SSHPort    int      `json:"ssh_port"`
	Volumes    []string `json:"volumes"`
}

// CNCI contains information about a CNCI
type CNCI struct {
	TenantID  string   `json:"tenant_id"`
	IPv4      string   `json:"ip"`
	Geography string   `json:"geo"`
	Subnets   []string `json:"subnets"`
}

// ClusterStatus contains information about the status of a ciao cluster
type ClusterStatus struct {
	TotalNodes            int `json:"total_nodes"`
	TotalNodesReady       int `json:"total_nodes_ready"`
	TotalNodesFull        int `json:"total_nodes_full"`
	TotalNodesOffline     int `json:"total_nodes_offline"`
	TotalNodesMaintenance int `json:"total_nodes_maintenance"`
}

// ComputeNodeStatus contains information about the status of a compute node
type ComputeNodeStatus struct {
	ID                    string    `json:"id"`
	Timestamp             time.Time `json:"updated"`
	Status                string    `json:"status"`
	MemTotal              int       `json:"ram_total"`
	MemAvailable          int       `json:"ram_available"`
	DiskTotal             int       `json:"disk_total"`
	DiskAvailable         int       `json:"disk_available"`
	Load                  int       `json:"load"`
	OnlineCPUs            int       `json:"online_cpus"`
	TotalInstances        int       `json:"total_instances"`
	TotalRunningInstances int       `json:"total_running_instances"`
	TotalPendingInstances int       `json:"total_pending_instances"`
	TotalPausedInstances  int       `json:"total_paused_instances"`
}

func checkEnv(vars []string) error {
	for _, k := range vars {
		if os.Getenv(k) == "" {
			return fmt.Errorf("%s is not defined", k)
		}
	}
	return nil
}

// RunCIAOCLI execs the ciao-cli command with a set of arguments.  The ciao-cli
// process will be killed if the context is Done.  An error will be returned if
// the following environment are not set; CIAO_IDENTITY,  CIAO_CONTROLLER,
// CIAO_USERNAME, CIAO_PASSWORD.  On success the data written to ciao-cli on stdout
// will be returned.
func RunCIAOCLI(ctx context.Context, tenant string, args []string) ([]byte, error) {
	vars := []string{"CIAO_IDENTITY", "CIAO_CONTROLLER", "CIAO_USERNAME", "CIAO_PASSWORD"}
	if err := checkEnv(vars); err != nil {
		return nil, err
	}

	if tenant != "" {
		args = append([]string{"-tenant-id", tenant}, args...)
	}

	data, err := exec.CommandContext(ctx, "ciao-cli", args...).Output()
	if err != nil {
		var failureText string
		if err, ok := err.(*exec.ExitError); ok {
			failureText = string(err.Stderr)
		}
		return nil, fmt.Errorf("failed to launch ciao-cli %v : %v\n%s",
			args, err, failureText)
	}

	return data, nil
}

// RunCIAOCLIJS is similar to RunCIAOCLI with the exception that the output
// of the ciao-cli command is expected to be in json format.  The json is
// decoded into the jsdata parameter which should be a pointer to a type
// that corresponds to the json output.
func RunCIAOCLIJS(ctx context.Context, tenant string, args []string, jsdata interface{}) error {
	data, err := RunCIAOCLI(ctx, tenant, args)
	if err != nil {
		return err
	}

	err = json.Unmarshal(data, jsdata)
	if err != nil {
		return err
	}

	return nil
}

// RunCIAOCLIAsAdmin execs the ciao-cli command as the admin user with a set of
// provided arguments.  The ciao-cli process will be killed if the context is
// Done.  An error will be returned if the following environment are not set;
// CIAO_IDENTITY, CIAO_CONTROLLER, CIAO_ADMIN_USERNAME, CIAO_ADMIN_PASSWORD.  In
// environments with multiple admin tenants CIAO_ADMIN_TENANT_NAME will be used
// to select the tenant.  On success the data written to ciao-cli on stdout will
// be returned.
func RunCIAOCLIAsAdmin(ctx context.Context, tenant string, args []string) ([]byte, error) {
	vars := []string{"CIAO_IDENTITY", "CIAO_CONTROLLER", "CIAO_ADMIN_USERNAME", "CIAO_ADMIN_PASSWORD"}
	if err := checkEnv(vars); err != nil {
		return nil, err
	}

	if tenant != "" {
		args = append([]string{"-tenant-id", tenant}, args...)
	}

	env := os.Environ()
	envCopy := make([]string, 0, len(env))
	for _, v := range env {
		if !strings.HasPrefix(v, "CIAO_USERNAME=") &&
			!strings.HasPrefix(v, "CIAO_PASSWORD=") &&
			!strings.HasPrefix(v, "CIAO_TENANT_NAME=") {
			envCopy = append(envCopy, v)
		}
	}
	envCopy = append(envCopy, fmt.Sprintf("CIAO_USERNAME=%s",
		os.Getenv("CIAO_ADMIN_USERNAME")))
	envCopy = append(envCopy, fmt.Sprintf("CIAO_PASSWORD=%s",
		os.Getenv("CIAO_ADMIN_PASSWORD")))
	if adminTenantName, ok := os.LookupEnv("CIAO_ADMIN_TENANT_NAME"); ok {
		envCopy = append(envCopy, fmt.Sprintf("CIAO_TENANT_NAME=%s",
			adminTenantName))
	}

	cmd := exec.CommandContext(ctx, "ciao-cli", args...)
	cmd.Env = envCopy
	data, err := cmd.Output()
	if err != nil {
		var failureText string
		if err, ok := err.(*exec.ExitError); ok {
			failureText = string(err.Stderr)
		}
		return nil, fmt.Errorf("failed to launch ciao-cli %v : %v\n%v",
			args, err, failureText)
	}

	return data, nil
}

// RunCIAOCLIAsAdminJS is similar to RunCIAOCLIAsAdmin with the exception that
// the output of the ciao-cli command is expected to be in json format.  The
// json is decoded into the jsdata parameter which should be a pointer to a type
// that corresponds to the json output.
func RunCIAOCLIAsAdminJS(ctx context.Context, tenant string, args []string,
	jsdata interface{}) error {
	data, err := RunCIAOCLIAsAdmin(ctx, tenant, args)
	if err != nil {
		return err
	}

	err = json.Unmarshal(data, jsdata)
	if err != nil {
		return err
	}

	return nil
}

// GetAllTenants retrieves a list of all tenants in the cluster by calling
// ciao-cli tenant list -all.  An error will be returned if the following
// environment variables are not set; CIAO_IDENTITY,  CIAO_CONTROLLER,
// CIAO_ADMIN_USERNAME, CIAO_ADMIN_PASSWORD.
func GetAllTenants(ctx context.Context) ([]*Tenant, error) {
	var tenants []*Tenant

	args := []string{"tenant", "list", "-all", "-f", "{{tojson .}}"}
	err := RunCIAOCLIAsAdminJS(ctx, "", args, &tenants)
	if err != nil {
		return nil, err
	}

	return tenants, nil
}

// GetUserTenants retrieves a list of all the tenants the current user has
// access to. An error will be returned if the following environment variables
// are not set; CIAO_IDENTITY, CIAO_CONTROLLER, CIAO_USERNAME, CIAO_PASSWORD.
func GetUserTenants(ctx context.Context) ([]*Tenant, error) {
	var tenants []*Tenant

	args := []string{"tenant", "list", "-f", "{{tojson .}}"}
	err := RunCIAOCLIJS(ctx, "", args, &tenants)
	if err != nil {
		return nil, err
	}

	return tenants, nil
}

// GetInstance returns an Instance structure that contains information
// about a specific instance.  The informaion is retrieved by calling
// ciao-cli show --instance.  An error will be returned if the following
// environment variables are not set; CIAO_IDENTITY,  CIAO_CONTROLLER,
// CIAO_USERNAME, CIAO_PASSWORD.
func GetInstance(ctx context.Context, tenant string, uuid string) (*Instance, error) {
	var instance *Instance
	args := []string{"instance", "show", "--instance", uuid, "-f", instanceTemplateDesc}
	err := RunCIAOCLIJS(ctx, tenant, args, &instance)
	if err != nil {
		return nil, err
	}

	return instance, nil
}

// GetAllInstances returns information about all instances in the specified
// tenant in a map.  The key of the map is the instance uuid.  The information
// is retrieved by calling ciao-cli instance list.  An error will be returned
// if the following environment variables are not set; CIAO_IDENTITY,
// CIAO_CONTROLLER, CIAO_USERNAME, CIAO_PASSWORD.
func GetAllInstances(ctx context.Context, tenant string) (map[string]*Instance, error) {
	var instances map[string]*Instance
	template := `
{
{{- range $i, $val := .}}
  {{- if $i }},{{end}}
  "{{$val.ID | js }}" : {{with $val}}` + instanceTemplateDesc + `{{end}}
{{- end }}
}
`
	args := []string{"instance", "list", "-f", template}
	err := RunCIAOCLIJS(ctx, tenant, args, &instances)
	if err != nil {
		return nil, err
	}

	return instances, nil
}

// RetrieveInstanceStatus retrieve the status of a specific instance.  This
// information is retrieved using ciao-cli instance show.  An error will be
// returned if the following environment variables are not set; CIAO_IDENTITY,
// CIAO_CONTROLLER, CIAO_USERNAME, CIAO_PASSWORD.
func RetrieveInstanceStatus(ctx context.Context, tenant string, instance string) (string, error) {
	args := []string{"instance", "show", "-instance", instance, "-f", "{{.Status}}"}
	data, err := RunCIAOCLI(ctx, tenant, args)
	if err != nil {
		return "", err
	}
	return string(data), nil
}

// RetrieveInstancesStatuses retrieves the statuses of a slice of specific instances.
// This information is retrieved using ciao-cli instance list.  An error will be
// returned if the following environment variables are not set; CIAO_IDENTITY,
// CIAO_CONTROLLER, CIAO_USERNAME, CIAO_PASSWORD.
func RetrieveInstancesStatuses(ctx context.Context, tenant string) (map[string]string, error) {
	var statuses map[string]string
	template := `
{
{{- range $i, $val := .}}
  {{- if $i }},{{end}}
   "{{$val.ID | js }}" : "{{$val.Status | js }}"
{{- end }}
}
`
	args := []string{"instance", "list", "-f", template}
	err := RunCIAOCLIJS(ctx, tenant, args, &statuses)
	if err != nil {
		return nil, err
	}
	return statuses, nil
}

// StopInstance stops a ciao instance by invoking the ciao-cli instance stop command.
// An error will be returned if the following environment variables are not set;
// CIAO_IDENTITY, CIAO_CONTROLLER, CIAO_USERNAME, CIAO_PASSWORD.
func StopInstance(ctx context.Context, tenant string, instance string) error {
	args := []string{"instance", "stop", "-instance", instance}
	_, err := RunCIAOCLI(ctx, tenant, args)
	return err
}

// StopInstanceAndWait stops a ciao instance by invoking the ciao-cli instance stop command.
// It then waits until the instance's status changes to exited.
// An error will be returned if the following environment variables are not set;
// CIAO_IDENTITY, CIAO_CONTROLLER, CIAO_USERNAME, CIAO_PASSWORD.
func StopInstanceAndWait(ctx context.Context, tenant string, instance string) error {
	if err := StopInstance(ctx, tenant, instance); err != nil {
		return err
	}
	for {
		status, err := RetrieveInstanceStatus(ctx, tenant, instance)
		if err != nil {
			return err
		}

		if status == "exited" {
			return nil
		}

		select {
		case <-time.After(time.Second):
			continue
		case <-ctx.Done():
			return ctx.Err()
		}
	}
}

// RestartInstance restarts a ciao instance by invoking the ciao-cli instance restart
// command.  An error will be returned if the following environment variables are not set;
// CIAO_IDENTITY, CIAO_CONTROLLER, CIAO_USERNAME, CIAO_PASSWORD.
func RestartInstance(ctx context.Context, tenant string, instance string) error {
	args := []string{"instance", "restart", "-instance", instance}
	_, err := RunCIAOCLI(ctx, tenant, args)
	return err
}

// RestartInstanceAndWait restarts a ciao instance by invoking the ciao-cli instance
// restart command.   It then waits until the instance's status changes to active.
// An error will be returned if the following environment variables are not set;
// CIAO_IDENTITY, CIAO_CONTROLLER, CIAO_USERNAME, CIAO_PASSWORD.
func RestartInstanceAndWait(ctx context.Context, tenant string, instance string) error {
	if err := RestartInstance(ctx, tenant, instance); err != nil {
		return err
	}
	for {
		status, err := RetrieveInstanceStatus(ctx, tenant, instance)
		if err != nil {
			return err
		}

		if status == "active" {
			return nil
		}

		select {
		case <-time.After(time.Second):
			continue
		case <-ctx.Done():
			return ctx.Err()
		}
	}
}

// DeleteInstance deletes a specific instance from the cluster.  It deletes
// the instance using ciao-cli instance delete.  An error will be returned
// if the following environment variables are not set; CIAO_IDENTITY,
// CIAO_CONTROLLER, CIAO_USERNAME, CIAO_PASSWORD.
func DeleteInstance(ctx context.Context, tenant string, instance string) error {
	args := []string{"instance", "delete", "-instance", instance}
	_, err := RunCIAOCLI(ctx, tenant, args)
	return err
}

// DeleteInstanceAndWait deletes a specific instance from the cluster.  It deletes
// the instance using ciao-cli instance delete and then blocks until ciao-cli
// reports that the instance is truly deleted.  An error will be returned
// if the following environment variables are not set; CIAO_IDENTITY,
// CIAO_CONTROLLER, CIAO_USERNAME, CIAO_PASSWORD.
func DeleteInstanceAndWait(ctx context.Context, tenant string, instance string) error {
	if err := DeleteInstance(ctx, tenant, instance); err != nil {
		return err
	}

	// TODO:  The correct thing to do here is to wait for the Delete Events
	// But these do not yet contain enough information to easily identify
	// the event we're interested in.

	for {
		_, err := RetrieveInstanceStatus(ctx, tenant, instance)
		if err == nil {
			select {
			case <-time.After(time.Second):
				continue
			case <-ctx.Done():
				return ctx.Err()
			}
		}

		if err == context.Canceled {
			return err
		}

		return nil
	}
}

// DeleteInstances deletes a set of instances provided by the instances slice.
// If the function encounters an error deleting an instance it records the error
// and proceeds to the delete the next instance. The function returns two values,
// an error and a slice of errors.  A single error value is set if any of the
// instance deletion attempts failed. A slice of errors is also returned so that
// the caller can determine which of the deletion attempts failed. The indices
// in the error slice match the indicies in the instances slice, i.e., a non nil
// value in the first element of the error slice indicates that there was an
// error deleting the first instance in the instances slice.  An error will be
// returned if the following environment variables are not set; CIAO_IDENTITY,
// CIAO_CONTROLLER, CIAO_USERNAME, CIAO_PASSWORD.
func DeleteInstances(ctx context.Context, tenant string, instances []string) ([]error, error) {
	var err error
	errs := make([]error, len(instances))

	for i, instance := range instances {
		errs[i] = DeleteInstance(ctx, tenant, instance)
		if err == nil && errs[i] != nil {
			err = fmt.Errorf("At least one instance deletion attempt failed")
		}
	}

	return errs, err
}

// DeleteAllInstances deletes all the instances created for the specified
// tenant by calling ciao-cli instance delete -all.  It returns an error
// if the ciao-cli command fails.  An error will be returned if the following
// environment variables are not set; CIAO_IDENTITY,  CIAO_CONTROLLER,
// CIAO_USERNAME, CIAO_PASSWORD.
func DeleteAllInstances(ctx context.Context, tenant string) error {
	args := []string{"instance", "delete", "-all"}
	_, err := RunCIAOCLI(ctx, tenant, args)
	return err
}

func checkStatuses(instances []string, statuses map[string]string,
	mustBeActive bool) ([]string, bool, error) {

	var err error
	scheduled := make([]string, 0, len(instances))
	finished := true
	for _, instance := range instances {
		status, ok := statuses[instance]
		if !ok {
			if err == nil {
				err = fmt.Errorf("Instance %s does not exist", instance)
			}
			continue
		}

		scheduled = append(scheduled, instance)

		if status == "pending" {
			finished = false
		} else if err == nil && mustBeActive && status == "exited" {
			err = fmt.Errorf("Instance %s has exited", instance)
		}
	}

	return scheduled, finished, err
}

// WaitForInstancesLaunch waits for a slice of newly created instances to be
// scheduled.  An instance is scheduled when its status changes from pending
// to exited or active.  If mustBeActive is set to true, the function will
// fail if it sees an instance that has been scheduled but whose status is
// exited.  The function returns a slice of instance UUIDs and an error.
// In the case of success, the returned slice of UUIDs will equal the instances
// array.  In the case of error, these two slices may be different.  This
// can happen if one or more of the instances has failed to launch.  If errors
// are detected with multiple instances, e.g., mustBeActive is true and two
// instances have a status of 'exited' the error returned will refers to the
// first instance only.    An error will be returned if the following
// environment variables are not set; CIAO_IDENTITY,  CIAO_CONTROLLER,
// CIAO_USERNAME, CIAO_PASSWORD.
func WaitForInstancesLaunch(ctx context.Context, tenant string, instances []string,
	mustBeActive bool) ([]string, error) {

	scheduled := make([]string, 0, len(instances))
	for {
		statuses, err := RetrieveInstancesStatuses(ctx, tenant)
		if err != nil {
			return scheduled, err
		}

		var finished bool
		scheduled, finished, err = checkStatuses(instances, statuses, mustBeActive)
		if finished || err != nil {
			return scheduled, err
		}

		select {
		case <-time.After(time.Second):
		case <-ctx.Done():
			return scheduled, ctx.Err()
		}
	}
}

// LaunchInstances launches num instances of the specified workload.  On success
// the function returns a slice of UUIDs of the successfully launched instances.
// If some instances failed to start then the error can be found in the event
// log.  The instances are launched using ciao-cli instance add. If no instances
// successfully launch then an error will be returned.  An error will be
// returned if the following environment variables are not set; CIAO_IDENTITY,
// CIAO_CONTROLLER, CIAO_USERNAME, CIAO_PASSWORD.
func LaunchInstances(ctx context.Context, tenant string, workload string, num int) ([]string, error) {
	template := `
[
{{- range $i, $val := .}}
  {{- if $i }},{{end}}"{{$val.ID | js }}"
{{- end }}
]
`
	args := []string{"instance", "add", "--workload", workload,
		"--instances", fmt.Sprintf("%d", num), "-f", template}
	var instances []string
	err := RunCIAOCLIJS(ctx, tenant, args, &instances)
	if err != nil {
		return nil, err
	}

	return instances, nil
}

// StartRandomInstances starts a specified number of instances using
// a random workload.  The UUIDs of the started instances are returned
// to the user.  An error will be returned if the following
// environment variables are not set; CIAO_IDENTITY,  CIAO_CONTROLLER,
// CIAO_USERNAME, CIAO_PASSWORD.
func StartRandomInstances(ctx context.Context, tenant string, num int) ([]string, error) {
	wklds, err := GetAllWorkloads(ctx, tenant)
	if err != nil {
		return nil, err
	}

	if len(wklds) == 0 {
		return nil, fmt.Errorf("No workloads defined")
	}

	wkldUUID := wklds[rand.Intn(len(wklds))].ID
	return LaunchInstances(ctx, tenant, wkldUUID, num)
}

// GetCNCIs returns a map of the CNCIs present in the cluster.  The key
// of the map is the CNCI ID.  The CNCI information is retrieved using
// ciao-cli list -cnci command.  An error will be returned if the
// following environment are not set;  CIAO_IDENTITY,  CIAO_CONTROLLER,
// CIAO_ADMIN_USERNAME, CIAO_ADMIN_PASSWORD.
func GetCNCIs(ctx context.Context) (map[string]*CNCI, error) {
	var CNCIs map[string]*CNCI
	template := `
{
{{- range $i, $val := .}}
  {{- if $i }},{{end}}
   "{{$val.ID | js }}" : {
    "tenant_id" : "{{$val.TenantID | js }}", "ip" : "{{$val.IPv4 | js}}",
    "geo": "{{$val.Geography | js }}", "subnets": [
        {{- range $j, $net := $val.Subnets -}}
              {{- if $j }},{{end -}}
              "{{- $net.Subnet -}}"
        {{- end -}}
    ]}
  {{- end }}
}
`
	args := []string{"node", "list", "-cnci", "-f", template}
	err := RunCIAOCLIAsAdminJS(ctx, "", args, &CNCIs)
	if err != nil {
		return nil, err
	}

	return CNCIs, nil
}

// GetComputeNodes returns a map containing status information about
// each node in the cluster.  The key of the map is the Node ID.  The
// information is retrieved using ciao-cli list -compute command.  An
// error will be returned if the following environment are not set;
// CIAO_IDENTITY,  CIAO_CONTROLLER, CIAO_ADMIN_USERNAME, CIAO_ADMIN_PASSWORD.
func GetComputeNodes(ctx context.Context) (map[string]*ComputeNodeStatus, error) {
	var computeList []*ComputeNodeStatus
	args := []string{"node", "list", "-compute", "-f", "{{tojson .}}"}
	err := RunCIAOCLIAsAdminJS(ctx, "", args, &computeList)
	if err != nil {
		return nil, err
	}

	computeMap := make(map[string]*ComputeNodeStatus)
	for _, n := range computeList {
		computeMap[n.ID] = n
	}

	return computeMap, nil
}

// GetClusterStatus returns the status of the ciao cluster.  The information
// is retrieved by calling ciao-cli node status.  An error will be returned
// if the following environment are not set; CIAO_IDENTITY,  CIAO_CONTROLLER,
// CIAO_ADMIN_USERNAME, CIAO_ADMIN_PASSWORD.
func GetClusterStatus(ctx context.Context) (*ClusterStatus, error) {
	var cs *ClusterStatus
	args := []string{"node", "status", "-f", "{{tojson .}}"}
	err := RunCIAOCLIAsAdminJS(ctx, "", args, &cs)
	if err != nil {
		return nil, err
	}

	return cs, nil
}


text:
iris.screen(
    function (self) {
        self.create = function () {
            console.log("Home Screen Created");
            self.tmpl(iris.path.home.html);
        };

        self.awake = function (params) {
            console.log("Home Screen Awakened");
            self.get("year_parameter").text("The value of the year parameter is: " + self.params.year);
            self.get("month_parameter").text("The value of the month parameter is: " + self.params.month);
        };

        self.sleep = function () {
            console.log("Home Screen Asleep");
        };

        self.destroy = function () {
            console.log("Home Screen Destroyed");
        };
    },
    iris.path.home.js
);


text:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item>
        <shape android:shape="rectangle">
            <solid android:color="#99666666" />
        </shape>
    </item>
    <item android:top="1dp" android:right="1dp">
        <shape android:shape="rectangle">
            <solid android:color="#ff0303" />
        </shape>
    </item>
</layer-list>


text:
<?xml version="1.0" encoding="UTF-8"?>

<channel name="displays" version="1.0">
  <property name="Default" type="empty">
    <property name="LVDS1" type="string" value="Laptop">
      <property name="Active" type="bool" value="true"/>
      <property name="Resolution" type="string" value="1600x900"/>
      <property name="RefreshRate" type="double" value="60.001222"/>
      <property name="Rotation" type="int" value="0"/>
      <property name="Reflection" type="string" value="0"/>
      <property name="Primary" type="bool" value="false"/>
      <property name="Position" type="empty">
        <property name="X" type="int" value="0"/>
        <property name="Y" type="int" value="0"/>
      </property>
    </property>
  </property>
</channel>


text:
layout: post
title:  "A Few More Galaxies Caught by Spitzer"
date:   2017-04-18 18:00:00
categories: Astronomy
tags: [astronomy, image-processing, deep-sky, spitzer]
---
I found a few more gems in the Spitzer archives.

Using the same procedure as I did for my previous images, I, once again used IRAC Map images, with images filtered at the 3.6μm, 4.5μm, 5.8μm and 8.0μm wavelength bands.

I used the same artificial colouring as my previous images, which were then merged.

#### [NGC 2903](https://en.wikipedia.org/wiki/NGC_2903)
* Barred spiral in Leo
* Apparent magnitude: 9.7
* Apparent size: 12.6' x 6.0'

#### [NGC 6221](https://en.wikipedia.org/wiki/NGC_6221)
* Barred spiral galaxy in Ara
* Apparent magnitude: 9.28
* Apparent size: 3.5' x 2.5'

#### [NGC 3628](https://en.wikipedia.org/wiki/NGC_3628)
* Spiral galaxy in Leo, also known as the Hamburger Galaxy
* Apparent magnitude: 10.2
* Apparent size: 15' x 3.6'

#### [NGC 3115](https://en.wikipedia.org/wiki/NGC_3115)
* Lenticular galaxy with ring structure in Sextans
* Apparent magnitude: 9.9
* Apparent size: 7.2' x 2.5'


text:
package org.itas.core.bytecode;

import javassist.CtField;
import javassist.NotFoundException;
import junit.framework.Assert;

import org.itas.core.bytecode.AbstractFieldProvider.javassistType;
import org.junit.Before;

public class FDMapProviderTest extends AbstreactFieldProvider {

	@Before
	public void setUP() throws NotFoundException {
		super.setUP();
		provider = FDMapProvider.PROVIDER;
	}

	@Override
	public void typeTest() throws NotFoundException, Exception {
		final CtField[] fields = clazz.getDeclaredFields();
		for (CtField field : fields) {
			if (field == this.field || javassistType.map_.subtypeOf(field.getType())) {
				Assert.assertEquals(true, provider.isType(field.getType()));
			} else {
				Assert.assertEquals(false, provider.isType(field.getType()));
			}
		}
	}

	@Override
	public void setStatementTest() throws Exception {
		javaBaseStatementTest();
		resourceStatementTest();
		enumStatementTest();
		simpleStatmentTest();
	}

	@Override
	public void getResultSetTest() throws Exception {
		javaBaseResultTest();
		resourceResultTest();
		enumResultTest();
		simpleResultTest();
	}

	public void javaBaseStatementTest() throws Exception {
		CtField field = clazz.getDeclaredField("heroGroups");

		String expected = "\n\t\t"
				+ "state.setString(1, toString(getHeroGroups()));";
		String content = provider.setStatement(1, field);
		Assert.assertEquals(expected, content);
	}

	public void javaBaseResultTest() throws Exception {
		CtField field = clazz.getDeclaredField("heroGroups");
		String expected =	"\n\t\t"
				+ "{"	+ "\n\t\t\t"
				+ "String value_ = result.getString(\"heroGroups\");"	+ "\n\t\t\t"
				+ "org.itas.util.Pair[] valueArray_ = parsePair(value_);"	+ "\n\t\t\t"
				+ "java.util.Map valueList_ = new java.util.HashMap(8);"	+ "\n\t\t\t"
				+ "org.itas.util.Pair pair;"	+ "\n\t\t\t"
				+ "for (int i = 0; i < valueArray_.length; i ++) {"	+ "\n\t\t\t\t"
				+ "pair = valueArray_[i];"	+ "\n\t\t\t\t"
				+ "valueList_.put(java.lang.Integer.valueOf((String)pair.getKey()), new org.itas.core.Simple((String)pair.getValue()));"	+ "\n\t\t\t"
				+ "}"	+ "\n\t\t\t"
				+ "setHeroGroups(valueList_);"	+ "\n\t\t"
				+ "}";

		String content = provider.getResultSet(field);
		Assert.assertEquals(expected, content);
	}

	public void resourceStatementTest() throws Exception {
		CtField field = clazz.getDeclaredField("heroResMap");

		String expected = "\n\t\t"
				+ "state.setString(1, toString(getHeroResMap()));";
		String content = provider.setStatement(1, field);
		Assert.assertEquals(expected, content);
	}

	public void resourceResultTest() throws Exception {
		CtField field = clazz.getDeclaredField("heroResMap");

		String expected = "\n\t\t"
				+ "{"	+ "\n\t\t\t"
				+ "String value_ = result.getString(\"heroResMap\");"	+ "\n\t\t\t"
				+ "org.itas.util.Pair[] valueArray_ = parsePair(value_);"	+ "\n\t\t\t"
				+ "java.util.Map valueList_ = new java.util.HashMap(16);"	+ "\n\t\t\t"
				+ "org.itas.util.Pair pair;"	+ "\n\t\t\t"
				+ "for (int i = 0; i < valueArray_.length; i ++) {"	+ "\n\t\t\t\t"
				+ "pair = valueArray_[i];"	+ "\n\t\t\t\t"
				+ "valueList_.put(org.itas.core.Pool.getResource((String)pair.getKey()), java.lang.Integer.valueOf((String)pair.getValue()));"	+ "\n\t\t\t"
				+ "}"	+ "\n\t\t\t"
				+ "setHeroResMap(valueList_);"	+ "\n\t\t"
				+ "}";

		String content = provider.getResultSet(field);
		Assert.assertEquals(expected, content);
	}

	public void enumStatementTest() throws Exception {
		CtField field = clazz.getDeclaredField("sexCoinMap");

		String expected = "\n\t\t"
				+ "state.setString(1, toString(getSexCoinMap()));";
		String content = provider.setStatement(1, field);
		Assert.assertEquals(expected, content);
	}

	public void enumResultTest() throws Exception {
		CtField field = clazz.getDeclaredField("sexCoinMap");

		String expected = 	"\n\t\t"
				+ "{"	+ "\n\t\t\t"
				+ "String value_ = result.getString(\"sexCoinMap\");"	+ "\n\t\t\t"
				+ "org.itas.util.Pair[] valueArray_ = parsePair(value_);"	+ "\n\t\t\t"
				+ "java.util.Map valueList_ = new java.util.HashMap(8);"	+ "\n\t\t\t"
				+ "org.itas.util.Pair pair;"	+ "\n\t\t\t"
				+ "for (int i = 0; i < valueArray_.length; i ++) {"	+ "\n\t\t\t\t"
				+ "pair = valueArray_[i];"	+ "\n\t\t\t\t"
				+ "valueList_.put(parse(org.itas.core.bytecode.Model.SexType.class, java.lang.Byte.valueOf((String)pair.getKey())), java.lang.Float.valueOf((String)pair.getValue()));"	+ "\n\t\t\t"
				+ "}"	+ "\n\t\t\t"
				+ "setSexCoinMap(valueList_);"	+ "\n\t\t"
				+ "}";

		String content = provider.getResultSet(field);
		Assert.assertEquals(expected, content);
	}

	public void simpleStatmentTest() throws Exception {
		CtField field = clazz.getDeclaredField("cardGroupNames");

		String expected =
				"\n\t\t"
						+ "state.setString(1, toString(getCardGroupNames()));";
		String content = provider.setStatement(1, field);
		Assert.assertEquals(expected, content);
	}

	public void simpleResultTest() throws Exception {
		CtField field = clazz.getDeclaredField("cardGroupNames");

		String expected = 	"\n\t\t"
				+ "{"	+ "\n\t\t\t"
				+ "String value_ = result.getString(\"cardGroupNames\");"	+ "\n\t\t\t"
				+ "org.itas.util.Pair[] valueArray_ = parsePair(value_);"	+ "\n\t\t\t"
				+ "java.util.Map valueList_ = new java.util.LinkedHashMap(8);"	+ "\n\t\t\t"
				+ "org.itas.util.Pair pair;"	+ "\n\t\t\t"
				+ "for (int i = 0; i < valueArray_.length; i ++) {"	+ "\n\t\t\t\t"
				+ "pair = valueArray_[i];"	+ "\n\t\t\t\t"
				+ "valueList_.put(new org.itas.core.Simple((String)pair.getKey()), (String)pair.getValue());"	+ "\n\t\t\t"
				+ "}"	+ "\n\t\t\t"
				+ "setCardGroupNames(valueList_);"	+ "\n\t\t"
				+ "}";

		String content = provider.getResultSet(field);
		Assert.assertEquals(expected, content);
	}

}


text:
package proxy

import (
	"fmt"
	. "github.com/siddontang/mixer/mysql"
	"github.com/siddontang/mixer/sqlparser"
	"strings"
)

var nstring = sqlparser.String

func (c *Conn) handleSet(stmt *sqlparser.Set) error {
	if len(stmt.Exprs) != 1 {
		return fmt.Errorf("must set one item once, not %s", nstring(stmt))
	}

	k := string(stmt.Exprs[0].Name.Name)

	switch strings.ToUpper(k) {
	case `AUTOCOMMIT`:
		return c.handleSetAutoCommit(stmt.Exprs[0].Expr)
	case `NAMES`:
		return c.handleSetNames(stmt.Exprs[0].Expr)
	default:
		return fmt.Errorf("set %s is not supported now", k)
	}
}

func (c *Conn) handleSetAutoCommit(val sqlparser.ValExpr) error {
	value, ok := val.(sqlparser.NumVal)
	if !ok {
		return fmt.Errorf("set autocommit error")
	}
	switch value[0] {
	case '1':
		c.status |= SERVER_STATUS_AUTOCOMMIT
	case '0':
		c.status &= ^SERVER_STATUS_AUTOCOMMIT
	default:
		return fmt.Errorf("invalid autocommit flag %s", value)
	}

	return c.writeOK(nil)
}

func (c *Conn) handleSetNames(val sqlparser.ValExpr) error {
	value, ok := val.(sqlparser.StrVal)
	if !ok {
		return fmt.Errorf("set names charset error")
	}

	charset := strings.ToLower(string(value))
	cid, ok := CharsetIds[charset]
	if !ok {
		return fmt.Errorf("invalid charset %s", charset)
	}

	c.charset = charset
	c.collation = cid

	return c.writeOK(nil)
}


text:
from django.conf.urls.defaults import include, patterns, url

from tastypie.api import Api

import mozillians.users.api

v1_api = Api(api_name='v1')
v1_api.register(mozillians.users.api.UserResource())

urlpatterns = patterns('',
    url(r'', include(v1_api.urls)),
)


text:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">

<meta http-equiv="content-type" content="text/html; charset=utf-8" >
<meta name="google-site-verification" content="GcrnbgZkRkwn51jQmX7QBaMKSymq1h-iG8G_xeILIkM" />
<title>portable deployment pipeline</title>
<meta name="author" content="Speaker 48" >

<link rel="alternate" type="application/rss+xml" title="devopsdays RSS Feed" href="http://www.devopsdays.org/feed/" >

<link rel="stylesheet" href="/css/devops.min.css" type="text/css" media="screen, projection">
<link rel="stylesheet" href="/css/blueprint/print.css" type="text/css" media="print">

<link href="/css/googlemaps.css" rel="stylesheet">

      Home

      Contact

      Events

      Presentations

      Blog

portable deployment pipeline

Abstract:
Walter (github.com/walter-cd/walter) is a tiny tool for executing
deployment pipelines (such as automated build workflows) in Continuous
Integration / Delivery (CI / CD).

When managing a CI environment with Jenkins, we commonly use some sort of
build pipeline plugins such as build pipeline-plugin to define deployment
flows and execute the tasks in the flow one by one.

Although these Jenkins plugins are useful to manage and control CI, we
still have the following problems in the deployment of our services.

None of us is able to run build pipeline without our Jenkins server

No one is able to check if the pipeline works until starting the CI
jobs in the Jenkins server

We feel the difficulties to migrate the build pipeline settings to
other CI environments

Although we have built our system that maintains the servers settings
with configuration files of Chef or Ansible in the Git repositories, only
the deployment pipeline settings are still in Jenkins server… Of course
Modern CI services such as Travis-ci or Wercker provide the solution to
this problem. Unfortunately, we can't execute these services locally.

To manage the deployment settings with the local repositories, we have
developed a tiny deployment workflow engine in Golang.

At DevOpsDays, I would like to talk about how walter solves the problems
around the deployment systems. The session also covers use cases of
walter in the combination with other tools such as Docker. ref:
[http://]ainoya.io/docker-android-walter .

Speaker:
Speaker 48

Please enable JavaScript to view the comments powered by Disqus.
blog comments powered by Disqus

Tweets from devopsdays events

Past

      2009

      Ghent 2009

      2010

      Sydney 2010

      Mountain View 2010

      Hamburg 2010

      Sao Paulo 2010

      2011

      Boston 2011

      Mountain View 2011

      Melbourne 2011

      Bangalore 2011

      Göteborg 2011

      Manila 2011

      2012

      Austin 2012

      Tokyo 2012

      Delhi 2012

      Mountain View 2012

      Rome 2012

      New York 2012

      2013

      New Zealand 2013

      London 2013

      Paris 2013

      Austin 2013

      Berlin 2013

      Amsterdam 2013

      Silicon Valley 2013

      Downunder 2013

      Bangalore 2013

      London Autumn 2013

      Barcelona 2013

      Vancouver 2013

      Portland 2013

      New York 2013

      Atlanta 2013

      Tel Aviv 2013

      Tokyo 2013

      2014

      Nairobi 2014

      Ljubljana 2014

      Austin 2014

      Pittsburgh 2014

      Amsterdam 2014

      Silicon Valley 2014

      Minneapolis 2014

      Brisbane 2014

      Boston 2014

      Toronto 2014

      New York 2014

      Warsaw 2014

      Chicago 2014

      Berlin 2014

      Belgium 2014

      Helsinki 2014

      Vancouver 2014

      Tel Aviv 2014

      Bangalore 2014

      2015

      Ljubljana 2015

      Paris 2015

      Denver 2015

      New York 2015

      Austin 2015

      Toronto 2015

      Washington, DC 2015

      Amsterdam 2015

      Minneapolis 2015

      Melbourne 2015

      Pittsburgh 2015

      Chicago 2015

      Bangalore 2015

      Boston 2015

      Tel Aviv 2015

      Singapore 2015

      Berlin 2015

      Charlotte 2015

      Silicon Valley 2015

      Detroit 2015

      Ohio 2015

      Warsaw 2015

      2016

      Los Angeles (1 day)
      Vancouver

      London

      Denver

      Atlanta

Future

        2016

        Austin - May 2 & 3

        Kiel - May 12 & 13

        Seattle - May 12 & 13

        Toronto - May 26 & 27

        Istanbul - Jun 3 & 4

        Washington, DC - Jun 8 & 9

        Salt Lake City - Jun 14 & 15

        Silicon Valley - June 24 & 25

        Amsterdam - Jun 29, 30 & Jul 1

        Minneapolis - Jul 20 & 21

        Portland - Aug 9 & 10

        Boston - Aug 25 & 26

        Chicago - Aug 30 & 31

        Oslo - Sep 5 & 6

        Dallas - Sep 15 & 16

        New York - Sep 23 & 24

        Boise - Oct 7 & 8

        Singapore - Oct 8 & 9

        Detroit - Oct 12 & 13

        Kansas City - Oct 20 & 21

        Philadelphia - Oct 26 & 27

        2016, Dates TBD

        Ghent

        Raleigh

        New Zealand

        Ohio

        Nashville

        Madison

        Cape Town


text:
import random

from django.db import models

LOWER_BOUND = -2147483648
UPPER_BOUND = 2147483647
SHIFT = 92147483647

class ConvertedValue(str):
    def __new__(cls, value):
        value = int(value)

        if UPPER_BOUND < value:
            display_value = value
            db_value = value - SHIFT
        else:
            db_value = value
            display_value = value + SHIFT

        self = super(ConvertedValue, cls).__new__(cls, display_value)
        self.db_value = db_value

        return self

    def __repr__(self):
        return "<%s: %s>" % (self.__class__.__name__, self.db_value)

    def __eq__(self, other):
        if isinstance(other, self.__class__):
            return self.db_value == other.db_value
        return self.db_value == other

    def __hash__(self):
        return hash(self.db_value)

class ConvertedValueField(models.IntegerField):
    '''
        Roughly copied from https://github.com/django/django/blob/d6eaf7c0183cd04b78f2a55e1d60bb7e59598310/tests/custom_pk/fields.py
    '''

    def pre_save(self, instance, add):
        value = getattr(instance, self.attname, None)
        if not value:
            value = ConvertedValue(random.randint(LOWER_BOUND, UPPER_BOUND))
            setattr(instance, self.attname, value)
        return value

    def to_python(self, value):
        if not value:
            return
        if not isinstance(value, ConvertedValue):
            value = ConvertedValue(value)
        return value

    def from_db_value(self, value, expression, connection):
        if not value:
            return
        return ConvertedValue(value)

    def get_db_prep_save(self, value, connection):
        if not value:
            return
        return ConvertedValue(value).db_value

    def get_db_prep_value(self, value, connection, prepared=False):
        if not value:
            return
        return ConvertedValue(value).db_value

    def get_searchable_content(self, value):
        if not value:
            return
        return ConvertedValue(value).db_value


text:
using System.Reflection;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyProduct("SimpleAuthentication.Core")]
[assembly: AssemblyTitle("SimpleAuthentication - Core")]
[assembly: AssemblyDescription("A simple ASP.NET Web Social Authentication library.")]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("05a6ab10-4fac-4f87-a3f9-fcf19f101dda")]


text:
<?php

/*
 * This file is part of the Meli library.
 *
 * (c) Bruno Galeotti <bgaleotti@gmail.com>
 *
 * This source file is subject to the MIT license that is bundled
 * with this source code in the file LICENSE.
 */

namespace Meli\Resource;

use Meli\Resource;
use Pagerfanta\Pagerfanta;

/**
 * @author Bruno Galeotti <bgaleotti@gmail.com>
 */
class SiteDomains extends Resource
{
    public function findByUrl(string $url) : array
    {
        return $this->get("/site_domains/$url");
    }

    public function findAll() : Pagerfanta
    {
        return $this->createPaginator('/site_domains');
    }
}


text:
"use strict";

const EOF = Symbol.for('EOF');

const stylecow = require('../index');

stylecow.Root = class Root extends require('./classes/node-collection') {

    static create (reader, parent) {
        const element = new stylecow.Root(reader.data());

        while (reader.currToken !== EOF) {
            element.push(
                    stylecow.AtRule.create(reader, element)
                 || stylecow.NestedAtRule.create(reader, element)
                 || stylecow.Comment.create(reader, element)
                 || stylecow.Rule.create(reader, element)
                 || reader.error()
            );
        }

        return element;
    }

    constructor(data) {
        super(data, 'Root');
    }

    toString () {
        return this
            .map(child => child.toString())
            .filter(string => string ? true : false)
            .join("\n");
    }

    toCode (code) {
        this.forEach(child => child.toCode(code));
    }
}


text:
<?php return array (
  'Require e-mail.' => '',
  'General' => 'General',
  'Show Avatars from Gravatar.' => 'Show Avatars from Gravatar.',
  'Unable to comment. Please try again later.' => '',
  'Submit' => '',
  'Comment' => 'Comment',
  'Comments are closed.' => 'Comments are closed.',
  'Appearance' => 'Appearance',
  'Draft' => 'Draft',
  'Author' => 'Author',
  'Permalink' => 'Permalink',
  'Slug' => 'Slug',
  'Email invalid.' => 'Email invalid.',
  'Comment not found.' => 'Comment not found.',
  'Filter by' => '',
  '{1} %count% Comment selected|]1,Inf[ %count% Comments selected' => '{1} %count% Comment selected|]1,Inf[ %count% Comments selected',
  'Comments (%count%)' => 'Comments (%count%)',
  'Title' => 'Title',
  'Thank you! Your comment needs approval before showing up.' => '',
  'Insufficient user rights.' => 'Insufficient user rights.',
  'Posts View' => '',
  'Default post settings' => 'Default post settings',
  '{1} %count% Post selected|]1,Inf[ %count% Posts selected' => '{1} %count% Post selected|]1,Inf[ %count% Posts selected',
  'Comments' => 'Comments',
  'Image' => 'Image',
  'Posts' => 'Posts',
  'Pending' => 'Pending',
  'Disabled' => '',
  'Approved' => 'Approved',
  'Edit Post' => 'Edit Post',
  'Enable Comments' => 'Enable Comments',
  'Pending Review' => 'Pending Review',
  'Excerpt' => 'Excerpt',
  'Invalid post id.' => 'Invalid post id.',
  'Blog' => 'Blog',
  'Logged in as %name%' => 'Logged in as %name%',
  'Order comments by' => 'Order comments by',
  'Title cannot be blank.' => 'Title cannot be blank.',
  'Save' => 'Save',
  'Status' => 'Status',
  '{0} %count% Comments|{1} %count% Comment|]1,Inf[ %count% Comments' => '{0} %count% Comments|{1} %count% Comment|]1,Inf[ %count% Comments',
  'Please login to leave a comment.' => 'Please login to leave a comment.',
  'Posts per page' => 'Posts per page',
  'E-mail' => 'E-mail',
  'latest last' => '',
  'Please wait another %seconds% seconds before commenting again.' => 'Please wait another %seconds% seconds before commenting again.',
  'Post not found.' => 'Post not found.',
  'No comments found.' => 'No comments found.',
  'Publish on' => 'Publish on',
  'Name cannot be blank.' => 'Name cannot be blank.',
  'Invalid slug.' => 'Invalid slug.',
  'Please provide valid name and email.' => 'Please provide valid name and email.',
  'You are not allowed to post comments.' => 'You are not allowed to post comments.',
  'Author cannot be blank.' => 'Author cannot be blank.',
  'latest first' => '',
  'Unpublished' => 'Unpublished',
  'Custom' => 'Custom',
  'Published' => 'Published',
  '{0} %count% Posts|{1} %count% Post|]1,Inf[ %count% Posts' => '{0} %count% Posts|{1} %count% Post|]1,Inf[ %count% Posts',
  'Add Post' => 'Add Post',
  'Date' => 'Date',
  'Reply' => 'Reply',
  'Parent not found.' => 'Parent not found.',
  'URL' => 'URL',
  'Day and name' => 'Day and name',
  'Options' => 'Options',
  'Field must be a valid email address.' => 'Field must be a valid email address.',
  'levels deep.' => 'levels deep.',
  'Comments on %title%' => 'Comments on %title%',
  'Insufficient User Rights.' => 'Insufficient User Rights.',
  'Copy' => 'Copy',
  'Post not found!' => 'Post not found!',
  'Blog Settings' => 'Blog Settings',
  'days.' => 'days.',
  'Email' => 'Email',
  'No posts found.' => 'No posts found.',
  'Enable Markdown' => 'Enable Markdown',
  'Read more' => '',
  'Content cannot be blank.' => 'Content cannot be blank.',
  'Unknown' => 'Unknown',
  'Month and name' => 'Month and name',
  'Close comments on articles older than' => 'Close comments on articles older than',
  'Cancel' => 'Cancel',
  'Written by %name% on %date%' => 'Written by %name% on %date%',
  'Enable nested comments of' => 'Enable nested comments of',
  'Restrict Access' => 'Restrict Access',
  'Comment cannot be blank.' => 'Comment cannot be blank.',
  'Access denied.' => 'Access denied.',
  'Spam' => 'Spam',
  'Leave a comment' => 'Leave a comment',
  '{0} No comments|{1} %num% Comment|]1,Inf[ %num% Comments' => '{0} No comments|{1} %num% Comment|]1,Inf[ %num% Comments',
  'Post' => 'Post',
  'View' => '',
  'Numeric' => 'Numeric',
  'Name' => 'Name',
);


text:
import $ from 'jquery';
var screenDiv;
export function startScreensaver(){
    screenDiv = $('

');
    $('#main-body').prepend(screenDiv);
    var canvas = document.createElement('canvas');
    screenDiv.append(canvas);
    var ctx = canvas.getContext("2d");

    //Lets make the canvas occupy the full page
    var W = window.innerWidth, H = window.innerHeight;
    canvas.width = W;
    canvas.height = H;

    //Lets make some particles
    var particles = [];
    for(var i = 0; i < 10; i++)
    {
        particles.push(new particle());
    }

    function particle()
    {
        //location on the canvas
        this.location = {x: Math.random()*W, y: Math.random()*H};
        //radius - lets make this 0
        this.radius = 0;
        //speed
        this.speed = 2;
        //steering angle in degrees range = 0 to 360
        this.angle = Math.random()*360;
        //colors
        var r = Math.round(Math.random()*255);
        var g = Math.round(Math.random()*255);
        var b = Math.round(Math.random()*255);
        var a = Math.random();
        this.rgba = "rgba("+r+", "+g+", "+b+", "+a+")";
    }

    //Lets draw the particles
    function draw()
    {
        //re-paint the BG
        //Lets fill the canvas black
        //reduce opacity of bg fill.
        //blending time
        ctx.globalCompositeOperation = "source-over";
        ctx.fillStyle = "rgba(0, 0, 0, 0.02)";
        ctx.fillRect(0, 0, W, H);
        ctx.globalCompositeOperation = "lighter";

        for(var i = 0; i < particles.length; i++)
        {
            var p = particles[i];
            ctx.fillStyle = "grey";
            ctx.fillRect(p.location.x, p.location.y, p.radius, p.radius);

            //Lets move the particles
            //So we basically created a set of particles moving in random direction
            //at the same speed
            //Time to add ribbon effect
            for(var n = 0; n < particles.length; n++)
            {
                var p2 = particles[n];
                //calculating distance of particle with all other particles
                var yd = p2.location.y - p.location.y;
                var xd = p2.location.x - p.location.x;
                var distance = Math.sqrt(xd*xd + yd*yd);
                //draw a line between both particles if they are in 200px range
                if(distance < 200)
                {
                    ctx.beginPath();
                    ctx.lineWidth = 1;
                    ctx.moveTo(p.location.x, p.location.y);
                    ctx.lineTo(p2.location.x, p2.location.y);
                    ctx.strokeStyle = p.rgba;
                    ctx.stroke();
                    //The ribbons appear now.
                }
            }

            //We are using simple vectors here
            //New x = old x + speed * cos(angle)
            p.location.x = p.location.x + p.speed*Math.cos(p.angle*Math.PI/180);
            //New y = old y + speed * sin(angle)
            p.location.y = p.location.y + p.speed*Math.sin(p.angle*Math.PI/180);
            //You can read about vectors here:
            //http://physics.about.com/od/mathematics/a/VectorMath.htm

            if(p.location.x < 0) p.location.x = W;
            if(p.location.x > W) p.location.x = 0;
            if(p.location.y < 0) p.location.y = H;
            if(p.location.y > H) p.location.y = 0;
        }
    }

    setInterval(draw, 30);
}

export function stopScreensaver() {
    screenDiv.remove();
}


text:
layout: post
title: Up and running!
---

I finally found time to play with Jekyll for blogging. Inspired by Barry Clark's post, ["Build A Blog With Jekyll And GitHub Pages"](http://www.smashingmagazine.com/2014/08/01/build-blog-jekyll-github-pages/) --- originally inspired by Tom Preston-Werner's ["Blogging Like a Hacker."](http://tom.preston-werner.com/2008/11/17/blogging-like-a-hacker.html)

While I've always aspired to be a \[good\] writter--and blogging seemed like a natural step--I've never developed good habits and followed through with this. Here is a baby step... because it's never too late...


text:
require 'spec_helper'
#require 'forwardable'

class DomainClass
  include BasicPresenter::Concern

  attr_accessor :first_name, :last_name

  def initialize(first_name, last_name)
    @first_name = first_name
    @last_name = last_name
  end
end

#class BasePresenter
#  # extend Forwardable
#  # Presenter Class should allow DomainClass instance
#  # to be initialized
#
#  attr_reader :domain_object
#
#  def initialize(domain_object)
#    @domain_object = domain_object
#  end
#
#  class << self
#    def presents(name)
#      define_method(name) do
#        @domain_object
#      end
#    end
#  end
#end

class DomainClassPresenter < BasicPresenter::BasePresenter
  presents :domain_class

  @delegation_methods = [:first_name, :last_name]

  # def_delegators :domain_class, *@delegation_methods
  delegate *@delegation_methods, to: :domain_class

  def full_name
    first_name + last_name
  end
end

class AnotherPresenter < BasicPresenter::BasePresenter
  presents :domain_class

  def full_name
    domain_class.first_name + domain_class.last_name
  end
end

module BasicPresenter
  describe Concern do
    let(:dummy_domain_object) { DomainClass.new('Welcome', 'Presenter') }

    context "Presenter Class Modification Interface" do
      it "should determine default presenter class by the Domain Class" do
        expect(dummy_domain_object.default_presenter).to eq(DomainClassPresenter)
      end

      it "should tell current presenter class" do
        expect(dummy_domain_object.presenter_class).to eq(DomainClassPresenter)
      end

      it "should assume default presenter class as presenter class when not set" do
        expect(dummy_domain_object.presenter_class).to eq(DomainClassPresenter)
      end

      it "should recognize presenter class when set" do
        expect(dummy_domain_object.presenter_class).to eq(DomainClassPresenter)
        dummy_domain_object.presenter_class = AnotherPresenter
        expect(dummy_domain_object.presenter_class).to eq(AnotherPresenter)
      end
    end

    context "Helper Methods" do
      it "should be able to inform change in Presenter Class" do
        expect(dummy_domain_object.presenter_class).to eq(DomainClassPresenter)
        expect(dummy_domain_object).to be_presenter_class_not_changed
        dummy_domain_object.presenter_class = AnotherPresenter
        expect(dummy_domain_object).to be_presenter_class_changed
        expect(dummy_domain_object.presenter_class).to eq(AnotherPresenter)
      end
    end

    context "Presenter Instance Creation to allow delegation of Presenter Methods" do
      it "should delegate presenter methods on Default Presenter when not set" do
        expect(dummy_domain_object.presenter).to be_an_instance_of(DomainClassPresenter)
      end

      it "should delegate presenter methods on Explicit Presenter if set" do
        dummy_domain_object.presenter_class = AnotherPresenter
        expect(dummy_domain_object.presenter).to be_an_instance_of(AnotherPresenter)
      end

      context "Create Presenter Instance Once and return same if Presenter Class not changed" do
        it "when no Presenter Class set" do
          dummy_domain_object_presenter = dummy_domain_object.presenter
          expect(dummy_domain_object.presenter).to eq(dummy_domain_object_presenter)
          expect(dummy_domain_object.presenter).to eq(dummy_domain_object_presenter)
          expect(dummy_domain_object.presenter).to eq(dummy_domain_object_presenter)
        end

        it "when Presenter Class changed" do
          dummy_domain_object_presenter = dummy_domain_object.presenter
          dummy_domain_object.presenter_class = AnotherPresenter
          new_dummy_domain_object_presenter = dummy_domain_object.presenter
          expect(dummy_domain_object_presenter).to be_an_instance_of(DomainClassPresenter)
          expect(new_dummy_domain_object_presenter).to be_an_instance_of(AnotherPresenter)
          expect(dummy_domain_object.presenter).to eq(new_dummy_domain_object_presenter)
          expect(dummy_domain_object.presenter).to eq(new_dummy_domain_object_presenter)
          expect(dummy_domain_object.presenter).to eq(new_dummy_domain_object_presenter)
        end
      end
    end

    describe "Presenter Methods Available on Domain Object through #presenter" do
      it "should allow presenter methods to be called through #presenter" do
        expect(dummy_domain_object.presenter.full_name).to eq('WelcomePresenter')
      end

      it "should allow domain_object to be accessed through #domain_object" do
        expect(dummy_domain_object.presenter.domain_object).to eq(dummy_domain_object)
      end
    end
  end
end


text:
import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const Wrap = { template: '
child: <router-view></router-view>
' }

const Index = {
  template: '<wrap />',
  components: {
    Wrap
  }
}

const WithGuard = {
  template: '
{{ $route.name }}: {{ n }}
',
  data: () => ({ n: 0 }),
  beforeRouteEnter (to, from, next) {
    next(vm => {
      vm.n++
    })
  }
}

const IndexChild1 = { template: '
index child1
' }
const IndexChild2 = { template: '
index child2
' }

const Home = { template: '
home
' }

const ViewWithKeepalive = {
  template: '<keep-alive><router-view></router-view></keep-alive>'
}

const Parent = { template: '
msg: {{ msg }}<router-view />
', props: ['msg'] }

const RequiredProps = {
  template: '
props from route config is: {{ msg }}
',
  props: {
    msg: {
      type: String,
      required: true
    }
  }
}

// keep original values to restore them later
const originalSilent = Vue.config.silent
const originalWarnHandler = Vue.config.warnHandler

const CatchWarn = {
  template: `<div>{{ didWarn ? 'caught missing prop warn' : 'no missing prop warn' }}</div>`,
  data () {
    return {
      didWarn: false
    }
  },
  beforeRouteEnter (to, from, next) {
    let missPropWarn = false
    Vue.config.silent = false
    Vue.config.warnHandler = function (msg, vm, trace) {
      if (/Missing required prop/i.test(msg)) {
        missPropWarn = true
      }
    }
    next(vm => {
      vm.didWarn = missPropWarn
    })
  },
  beforeRouteLeave (to, from, next) {
    // restore vue config
    Vue.config.silent = originalSilent
    Vue.config.warnHandler = originalWarnHandler
    next()
  }
}

const router = new VueRouter({
  mode: 'history',
  base: __dirname,
  routes: [
    {
      path: '/index',
      component: Index,
      children: [
        {
          path: 'child1',
          component: IndexChild1
        },
        {
          path: 'child2',
          component: IndexChild2
        }
      ]
    },
    {
      path: '/home',
      component: Home
    },
    {
      path: '/with-guard1',
      name: 'with-guard1',
      component: WithGuard
    },
    {
      path: '/with-guard2',
      name: 'with-guard2',
      component: WithGuard
    },
    {
      path: '/one',
      component: ViewWithKeepalive,
      children: [
        {
          path: 'two',
          component: ViewWithKeepalive,
          children: [
            {
              path: 'child1',
              component: IndexChild1
            },
            {
              path: 'child2',
              component: IndexChild2
            }
          ]
        }
      ]
    },
    {
      path: '/config-required-props',
      component: Parent,
      props: { msg: 'from parent' },
      children: [
        {
          path: 'child',
          component: RequiredProps,
          props: {
            msg: 'from child'
          }
        }
      ]
    },
    {
      path: '/catch-warn',
      component: CatchWarn
    }
  ]
})

new Vue({
  router,
  template: `

<router-link to="/index/child1">/index/child1</router-link>

<router-link to="/index/child2">/index/child2</router-link>

<router-link to="/home">/home</router-link>

<router-link to="/with-guard1">/with-guard1</router-link>

<router-link to="/with-guard2">/with-guard2</router-link>

<router-link to="/one/two/child1">/one/two/child1</router-link>

<router-link to="/one/two/child2">/one/two/child2</router-link>

<router-link to="/config-required-props">/config-required-props</router-link>

<router-link to="/config-required-props/child">/config-required-props/child</router-link>

<router-link to="/catch-warn">/catch-warn</router-link>

      <keep-alive>
        <router-view class="view"></router-view>
      </keep-alive>

  `
}).$mount('#app')


text:
require 'miu'
require 'celluloid/io'
require 'celluloid/zmq'
require 'miu/nodes/irc/version'
require 'miu/nodes/irc/node'
Celluloid.logger = nil


text:
package com.gitlab.zloster.tfb.servlet3;

public class Helper {
	public static final String MEDIATYPE_APPLICATION_JSON = "application/json";
	public static final String MEDIATYPE_TEXT_PLAIN = "text/plain";
	public static final byte[] CONTENT = "Hello, World!".getBytes();
}