text:
'use strict';

angular.module('htc.services')

.factory('reportService', ['$http', 'routerService', function ($http, routerService) {
	var reports = [],
		_createReport = function (report, cb, err) {
			$http.post(routerService.createReportUrl, JSON.stringify(report)).then(function (response) {
				cb(response.data);
			}, function (response) {
				if (err) err(response.data);
			});
		},
		_getListOfReportsWithUser = function (cb, err) {
			$http.get(routerService.getListOfReportsWithUser).then(function (response) {
				cb(response.data);
			}, function (response) {
				if (err) err(response.data);
			});
		},
		_getReportById = function (id, cb, err) {
			$http.get(routerService.getReportById + id).then(function (response) {
				cb(response.data);
			}, function (response) {
				if (err) err(response.data);
			});
		},
		_increaseRelevance = function (data, cb, err) {
			$http.post(routerService.increaseRelevance, JSON.stringify(data)).then(function (response) {
				cb(response.data);
			}, function (response) {
				if (err) err(response.data);
			});
		},
		_decreaseRelevance = function (userId, reportId, cb, err) {
			$http.delete(routerService.decreaseRelevance + '?userId=' + userId + '&reportId=' + reportId).then(function (response) {
				cb(response.data);
			}, function (response) {
				if (err) err(response.data);
			});
		},
		_getRelevance  = function (userId, reportId, cb, err) {
			$http.get(routerService.getRelevance + '?userId=' + userId + '&reportId=' + reportId).then(function (response) {
				cb(response.data);
			}, function (response) {
				if (err) err(response.data);
			});
		},
		_getPostDate = function (report) {
			var diff = new Date() - report.date;
			var milliseconds, seconds, minutes, hours, days, months, years;
			var result;

			diff = (diff - (milliseconds = diff % 1000)) / 1000;
			diff = (diff - (seconds = diff % 60)) / 60;
			diff = (diff - (minutes = diff % 60)) / 60;
			diff = (diff - (hours = diff % 24)) / 24;
			diff = (diff - (days = diff % 30)) / 30;
			years = (diff - (months = diff % 12)) / 12;

			if (years > 0) {
				result = years === 1 ? '1 ano' : years + ' anos';
			} else if (months > 0) {
				result = months === 1 ? '1 mes' : months + ' meses';
			} else if (days > 0) {
				result = days === 1 ? '1 dia' : days + ' dias';
			} else if (hours > 0) {
				result = hours === 1 ? '1 hora' : hours + ' horas';
			} else if (minutes > 0) {
				result = minutes === 1 ? '1 minuto' : minutes + ' minutos';
			} else if (seconds > 0) {
				result = seconds === 1 ? '1 segundo' : seconds + ' segundos';
			}

			return result;
		};

	return {
		createReport: _createReport,
		getListOfReportsWithUser: _getListOfReportsWithUser,
		getReportById: _getReportById,
		increaseRelevance: _increaseRelevance,
		decreaseRelevance: _decreaseRelevance,
		getRelevance: _getRelevance,
		getPostDate: _getPostDate
	};
}]);


text:
layout: page
title: "Work"
description: "Some of the things I keep myself alive with... "
header-img: "img/gallery-bg.jpg"
---

	<meta content="charset=utf-8">

	<link rel="stylesheet" href="../css/flexslider.css" type="text/css" media="screen" />

            DataScienceLab Frankfurt

            nostradamIQ

            GAIA Solutions Ltd.

            Freelance work

            Investment Consultant Services

redpajama_set_name: RedPajamaGithub


text:
package com.accela.tetrixgame.gamelogic.geometry;

/**
 *
 * 表示一个向x轴正方向和y轴正方向无限延伸 的网格。网格的起点在(0,0)。每个网格 都有一个行数和列数,它们都是从零开始的。
 *
 */
public class Grid {
	/**
	 * 每个网格的宽度
	 */
	private int gridWidth;
	/**
	 * 每个网格的高度
	 */
	private int gridHeight;

	/**
	 * 新建一个网格对象
	 *
	 * @param gridWidth
	 *            网格宽度
	 * @param gridHeight
	 *            网格高度
	 */
	public Grid(int gridWidth, int gridHeight) {
		if (gridWidth <= 0) {
			throw new IllegalArgumentException("gridWidth shoud not be null");
		}
		if (gridHeight <= 0) {
			throw new IllegalArgumentException("gridHeight shoud not be null");
		}

		this.gridWidth = gridWidth;
		this.gridHeight = gridHeight;
	}

	public int getGridWidth() {
		return gridWidth;
	}

	public int getGridHeight() {
		return gridHeight;
	}

	/**
	 * 用Point返回指定的点p在网格的哪一行哪一列上
	 */
	public void atWhichRowColumn(Point result, Point p) {
		if (null == p) {
			throw new NullPointerException("p should not be null");
		}
		if (null == result) {
			throw new NullPointerException("result should not be null");
		}

		result.reset(p.y / gridHeight, p.x / gridWidth);
	}

	/**
	 * 用Point返回指定的矩形的左上角点在网格的哪一行哪一列上
	 */
	public void atWhichRowColumn(Point result, Rectangle rect) {
		if (null == rect) {
			throw new NullPointerException("rect should not be null");
		}
		if (null == result) {
			throw new NullPointerException("result should not be null");
		}

		Point leftUp = Point.create();
		rect.getLeftUpPoint(leftUp);

		atWhichRowColumn(result, leftUp);

		Point.dispose(leftUp);
	}

	/**
	 * 给定的点是否在网格的网格线上
	 *
	 * @param x
	 *            给定的点的横坐标
	 * @param y
	 *            给定的点的纵坐标
	 * @return 给定的点是否在网格线上
	 */
	public boolean isOnGridLine(int x, int y) {
		if (x < 0) {
			throw new IllegalArgumentException("x should be nonnegtive");
		}
		if (y < 0) {
			throw new IllegalArgumentException("y should be nonnegtive");
		}

		return x % gridWidth == 0 || y % gridHeight == 0;
	}

	/**
	 * 给定的点是否在网格线上
	 *
	 * @param point
	 *            给定的点
	 * @return 给定的点是否在网格线上
	 */
	public boolean isOnGridLine(Point point) {
		if (null == point) {
			throw new IllegalArgumentException("point should not be null");
		}

		return point.x % gridWidth == 0 || point.y % gridHeight == 0;
	}

	/**
	 * 给定的点(x,y)是否在网格线的交点上
	 */
	public boolean isOnGridCross(Point point) {
		if (null == point) {
			throw new IllegalArgumentException("point should not be null");
		}

		return point.x % gridWidth == 0 && point.y % gridHeight == 0;
	}

	/**
	 * 给定的矩形是否在网格线的交点上
	 */
	public boolean isOnGridCross(Rectangle rect) {
		if (null == rect) {
			throw new IllegalArgumentException("rect should not be null");
		}

		Point temp = Point.create();

		rect.getLeftUpPoint(temp);
		if (!isOnGridCross(temp)) {
			return false;
		}

		rect.getLeftDownPoint(temp);
		if (!isOnGridCross(temp)) {
			return false;
		}

		rect.getRightUpPoint(temp);
		if (!isOnGridCross(temp)) {
			return false;
		}

		rect.getRightDownPoint(temp);
		if (!isOnGridCross(temp)) {
			return false;
		}

		Point.dispose(temp);

		return true;
	}

	/**
	 * 检查给定的点是否在竖直的网格线上
	 */
	public boolean isOnVerticalGridLine(Point point) {
		if (null == point) {
			throw new NullPointerException("point should not be null");
		}

		return point.x % gridWidth == 0;
	}

	/**
	 * 检查给定的矩形的两条竖直边是否都在网格的竖直网格线上
	 */
	public boolean isOnVerticalGridLine(Rectangle rect) {
		if (null == rect) {
			throw new NullPointerException("rect should not be null");
		}

		Point temp = Point.create();

		rect.getLeftUpPoint(temp);
		if (!isOnVerticalGridLine(temp)) {
			return false;
		}

		rect.getRightDownPoint(temp);
		if (!isOnVerticalGridLine(temp)) {
			return false;
		}

		Point.dispose(temp);

		return true;
	}

	/**
	 * 检查给定的点的两条水平边是否都在网格的水平网格线上
	 */
	public boolean isOnHerizontalGridLine(Point point) {
		if (null == point) {
			throw new NullPointerException("point should not be null");
		}

		return point.y % gridHeight == 0;
	}

	/**
	 * 检查给定的矩形的两条水平边是否都在网格的水平网格线上
	 */
	public boolean isOnHerizontalGridLine(Rectangle rect) {
		if (null == rect) {
			throw new NullPointerException("rect should not be null");
		}

		Point temp = Point.create();

		rect.getLeftUpPoint(temp);
		if (!isOnHerizontalGridLine(temp)) {
			return false;
		}

		rect.getLeftDownPoint(temp);
		if (!isOnHerizontalGridLine(temp)) {
			return false;
		}

		Point.dispose(temp);

		return true;
	}

	/**
	 * 返回一个点在它所在的网格中,相对于该网格的左上角的横坐标
	 */
	public int xCoordinateInGrid(Point point) {
		if (null == point) {
			throw new IllegalArgumentException("point should not be null");
		}

		return point.x % gridWidth;
	}

	/**
	 * 返回一个点在它所在的网格中,相对于该网格的左上角的纵坐标
	 */
	public int yCoordinateInGrid(Point point) {
		if (null == point) {
			throw new IllegalArgumentException("point should not be null");
		}

		return point.y % gridHeight;
	}

	/**
	 * 检查给定的两个点是否在网格的同一行
	 */
	public boolean isAtSameRow(Point point1, Point point2) {
		if (null == point1) {
			throw new IllegalArgumentException("point1 should not be null");
		}
		if (null == point2) {
			throw new IllegalArgumentException("point2 should not be null");
		}

		return point1.y / gridHeight == point2.y / gridHeight;
	}

	/**
	 * 检查给定的两个点是否在网格的同一列
	 */
	public boolean isAtSameColumn(Point point1, Point point2) {
		if (null == point1) {
			throw new IllegalArgumentException("point1 should not be null");
		}
		if (null == point2) {
			throw new IllegalArgumentException("point2 should not be null");
		}

		return point1.x / gridWidth == point2.x / gridWidth;
	}

	/**
	 * 检查给定的两个点是否在网格的同一格
	 */
	public boolean isInSameGrid(Point point1, Point point2) {
		if (null == point1) {
			throw new IllegalArgumentException("point1 should not be null");
		}
		if (null == point2) {
			throw new IllegalArgumentException("point2 should not be null");
		}

		return isAtSameRow(point1, point2) && isAtSameColumn(point1, point2);
	}
}


text: export { Rome as default } from "../../";


text:
uid: network-security
title: Network Security
---

# Akka.Remote Security

There are 2 ways you may like to achieve network security when using Akka.Remote:

- Transport Layer Security (introduced with Akka.Remote Version 1.2)
- Virtual Private Networks

### Akka.Remote with TLS (Transport Layer Security)
The release of Akka.NET version 1.2.0 introduces the default [DotNetty](https://github.com/Azure/DotNetty) transport and the ability to configure [TLS](http://en.wikipedia.org/wiki/Transport_Layer_Security) security across Akka.Remote Actor Systems.  In order to use TLS, you must first install a valid SSL certificate on all Akka.Remote hosts that you intend to use TLS.

Once you've installed valid SSL certificates, TLS is enabled via your HOCON configuration by setting `enable-ssl = true` and configuring the `ssl` HOCON configuration section like below:

```
akka {
  loglevel = DEBUG
  actor {
    provider = remote
  }
  remote {
    dot-netty.tcp {
      port = 0
      hostname = 127.0.0.1
      enable-ssl = true
      log-transport = true
      ssl {
        suppress-validation = true
        certificate {
          # valid ssl certificate must be installed on both hosts
          path = "<valid certificate path>"
          password = "<certificate password>"
          # flags is optional: defaults to "default-flag-set" key storage flag
          # other available storage flags:
          #   exportable | machine-key-set | persist-key-set | user-key-set | user-protected
          flags = [ "default-flag-set" ]
        }
      }
    }
  }
}
```

### Akka.Remote with Virtual Private Networks
The absolute best practice for securing remote Akka.NET applications today is to make the network around the applications secure - don't use public, open networks! Instead, use a private network to restrict machines that can contact Akka.Remote processes to ones who have your VPN credentials.

Some options for doing this:

* [OpenVPN](https://openvpn.net/) - for "do it yourself" environments;
* [Azure Virtual Networks](http://azure.microsoft.com/en-us/services/virtual-network/) - for Windows Azure customers; and
* [Amazon Virtual Private Cloud (VPC)](http://aws.amazon.com/vpc/) - for Amazon Web Services customers.


text:
module Web.Twitter.Feed.Tests where

import Test.HUnit hiding (Test)
import Test.Framework.Providers.HUnit (testCase)
import Test.Framework (Test, testGroup)

import Web.Twitter.Feed
import Web.Twitter.Types

addLinkTest :: Assertion
addLinkTest = addLink (Link 8 8 "not ") "this is a test" @?= "this is not a test"

addLinkEllipsisTest :: Assertion
addLinkEllipsisTest = addLink (Link 139 140 "link") tweet @?= expected
  where
    tweet    = replicate 130 'a' ++ " http://ww"
    expected = replicate 130 'a' ++ " link"

timelineUrlTest :: Assertion
timelineUrlTest = timelineUrl "someone" 3 True @?= expected
  where
    expected = concat [ "https://api.twitter.com/1.1/statuses/user_timeline.json"
                      , "?screen_name=someone&count=3&exclude_replies=true"
                      ]

sortLinkTest :: Assertion
sortLinkTest =
  sortLinks urlEntitiesExamples userEntitiesExamples mediaEntitiesExamples
      @?= sortedLinks

tests :: Test
tests = testGroup "Web.Twitter.Feed"
          [ testCase "addLink"         addLinkTest
          , testCase "addLinkEllipsis" addLinkEllipsisTest
          , testCase "timelineUrl"     timelineUrlTest
          , testCase "sortLinks"       sortLinkTest
          ]

sortedLinks :: [Link]
sortedLinks =
  [ Link 2  12  "t.co/g"
  , Link 13 20 "\
    \@Hackage"
  , Link 20 39 "t.co/s"
  , Link 50 62 "\
    \@StackBuilders"
  , Link 70 92 "\
    \pic.twitter.com/xhzEs8NuQa"
  ]

urlEntitiesExamples :: [URLEntity]
urlEntitiesExamples =
  [ URLEntity "google.com"        (2, 12)  "t.co/g"
  , URLEntity "stackbuilders.com" (20, 39) "t.co/s"
  ]

userEntitiesExamples :: [UserEntity]
userEntitiesExamples =
  [ UserEntity "Hackage"       (13, 20)
  , UserEntity "StackBuilders" (50, 62)
  ]

mediaEntitiesExamples :: [MediaEntity]
mediaEntitiesExamples =
  [ MediaEntity "http://t.co/xhzEs8NuQa" (70, 92) "pic.twitter.com/xhzEs8NuQa" ]


text:
package org.gwt.dynamic.module.gwtp.client.application.roles;

import java.util.Set;
import java.util.logging.Logger;

import org.gwt.dynamic.module.gwtp.client.event.RolesLoadedEvent;
import org.gwt.dynamic.module.gwtp.shared.RoleBean;

import com.google.inject.Inject;
import com.google.web.bindery.event.shared.EventBus;
import com.gwtplatform.mvp.client.HasUiHandlers;
import com.gwtplatform.mvp.client.PresenterWidget;
import com.gwtplatform.mvp.client.View;

public class RolesPresenter extends PresenterWidget<RolesPresenter.MyView>
implements RolesUiHandlers, RolesLoadedEvent.Handler {

	private static final Logger LOG = Logger.getLogger(RolesPresenter.class.getName());

	public interface MyView extends View, HasUiHandlers<RolesUiHandlers> {

		void setData(Set<RoleBean> roles);

		void update();
	}

	@Inject
	public RolesPresenter(final EventBus eventBus, final MyView view) {
		super(eventBus, view);
		getView().setUiHandlers(this);
		LOG.info("RolesPresenter: instantiated");
	}

	@Override
	protected void onBind() {
		super.onBind();
		LOG.info("RolesPresenter.onBind");
		addRegisteredHandler(RolesLoadedEvent.getType(), this);
	}

	@Override
	protected void onReveal() {
		super.onReveal();
		LOG.info("RolesPresenter.onReveal");
	}

	@Override
	protected void onReset() {
		super.onReset();
		LOG.info("RolesPresenter.onReset");
		getView().update();
	}

	@Override
	public void onRolesLoaded(RolesLoadedEvent event) {
		LOG.fine("RolesPresenter.onRolesLoaded: event.roles=" + event.getRoles());
		getView().setData(event.getRoles());
	}
}


text:
<!DOCTYPE html>

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

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

  <title>

      Home · Peter Giuffrida

  </title>

  <link rel="stylesheet" href="/public/css/poole.css">
  <link rel="stylesheet" href="/public/css/hyde.css">
  <link rel="stylesheet" href="/public/css/custom.css">
  <link rel="stylesheet" href="http://fonts.googleapis.com/css?family=PT+Sans:400,400italic,700|Abril+Fatface">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css">

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

  <link rel="alternate" type="application/rss+xml" title="RSS" href="/atom.xml">
  <link rel="canonical" href="http://localhost:4000/" />

Peter Giuffrida

I build robots made out of wood to hold other robots.

        Home

        About Me

        Projects

        Reading

        Kids

Peter Giuffrida

Senior IT professional with an outstanding track record. High energy performer who implements positive change within organizations. Has four children, three of whom are okay.

About Me

My background and career.

Projects

A selection of things I’ve done.

Reading

See books I've read since 2016.

Kids

I have three amazing children and another one too.

Recent Stories

Robot Revolution

December 2016

Robots are the way of the future. Especially ones made out of wood.

The Walking Dead

December 2016

I love this show!


text:
//
// Removes duplicate functions. That can happen due to C++ templates,
// and also due to types being different at the source level, but
// identical when finally lowered into concrete wasm code.
//

#include "ir/function-utils.h"
#include "ir/hashed.h"
#include "ir/module-utils.h"
#include "ir/utils.h"
#include "opt-utils.h"
#include "pass.h"
#include "wasm.h"

namespace wasm {

struct DuplicateFunctionElimination : public Pass {
  // FIXME Merge DWARF info
  bool invalidatesDWARF() override { return true; }

  // This pass merges functions but does not alter their contents.
  bool requiresNonNullableLocalFixups() override { return false; }

  void run(Module* module) override {
    // Multiple iterations may be necessary: A and B may be identical only after
    // we see the functions C1 and C2 that they call are in fact identical.
    // Rarely, such "chains" can be very long, so we limit how many we do.
    auto& options = getPassOptions();
    Index limit;
    if (options.optimizeLevel >= 3 || options.shrinkLevel >= 1) {
      limit = module->functions.size(); // no limit
    } else if (options.optimizeLevel >= 2) {
      // 10 passes usually does most of the work, as this is typically
      // logarithmic
      limit = 10;
    } else {
      limit = 1;
    }
    while (limit > 0) {
      limit--;
      // Hash all the functions
      auto hashes = FunctionHasher::createMap(module);
      FunctionHasher(&hashes).run(getPassRunner(), module);
      // Find hash-equal groups
      std::map<uint32_t, std::vector<Function*>> hashGroups;
      ModuleUtils::iterDefinedFunctions(*module, [&](Function* func) {
        hashGroups[hashes[func]].push_back(func);
      });
      // Find actually equal functions and prepare to replace them
      std::map<Name, Name> replacements;
      std::set<Name> duplicates;
      for (auto& [_, group] : hashGroups) {
        Index size = group.size();
        if (size == 1) {
          continue;
        }
        // The groups should be fairly small, and even if a group is large we
        // should have almost all of them identical, so we should not hit actual
        // O(N^2) here unless the hash is quite poor.
        for (Index i = 0; i < size - 1; i++) {
          auto* first = group[i];
          if (duplicates.count(first->name)) {
            continue;
          }
          for (Index j = i + 1; j < size; j++) {
            auto* second = group[j];
            if (duplicates.count(second->name)) {
              continue;
            }
            if (FunctionUtils::equal(first, second)) {
              // great, we can replace the second with the first!
              replacements[second->name] = first->name;
              duplicates.insert(second->name);
            }
          }
        }
      }
      // perform replacements
      if (replacements.size() > 0) {
        // remove the duplicates
        module->removeFunctions(
          [&](Function* func) { return duplicates.count(func->name) > 0; });
        OptUtils::replaceFunctions(getPassRunner(), *module, replacements);
      } else {
        break;
      }
    }
  }
};

Pass* createDuplicateFunctionEliminationPass() {
  return new DuplicateFunctionElimination();
}

} // namespace wasm


text:
package com.Joe.mobilesafe.activity;

import com.Joe.mobilesafe.R;

import android.app.Activity;
import android.os.Bundle;

public class AppLockActivity extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_app_lock);
	}

}


text:
package com.pushtorefresh.storio.contentresolver.integration;

import android.database.Cursor;
import android.support.annotation.NonNull;

import com.pushtorefresh.storio.StorIOException;
import com.pushtorefresh.storio.contentresolver.BuildConfig;
import com.pushtorefresh.storio.contentresolver.operations.delete.DeleteResult;
import com.pushtorefresh.storio.contentresolver.operations.get.PreparedGetCursor;
import com.pushtorefresh.storio.contentresolver.operations.put.PutResult;
import com.pushtorefresh.storio.contentresolver.queries.Query;
import com.pushtorefresh.storio.test.AbstractEmissionChecker;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricGradleTestRunner;
import org.robolectric.annotation.Config;

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.Queue;

import rx.Subscription;
import rx.functions.Action1;
import rx.observers.TestSubscriber;

import static org.assertj.core.api.Assertions.assertThat;

@RunWith(RobolectricGradleTestRunner.class)
@Config(constants = BuildConfig.class, sdk = 21)
public class RxQueryTest extends IntegrationTest {

    private class EmissionChecker extends AbstractEmissionChecker<List<Tweet>> {

        public EmissionChecker(@NonNull Queue<List<Tweet>> expected) {
            super(expected);
        }

        @Override
        @NonNull
        public Subscription subscribe() {
            return storIOContentResolver
                    .get()
                    .listOfObjects(Tweet.class)
                    .withQuery(Query.builder()
                            .uri(TweetMeta.CONTENT_URI)
                            .build())
                    .prepare()
                    .createObservable()
                    .subscribe(new Action1<List<Tweet>>() {
                        @Override
                        public void call(List<Tweet> tweets) {
                            onNextObtained(tweets);
                        }
                    });
        }
    }

    @Test
    public void queryShouldBeUpdatedAfterInsert() {
        // First of all -> insert some tweets into the Content Provider
        final List<Tweet> tweets = insertTweets(TestFactory.newTweets(10));

        final Queue<List<Tweet>> expectedTweets = new LinkedList<List<Tweet>>();

        // First emission: 10 tweets
        expectedTweets.add(tweets);

        final Tweet tweet = TestFactory.newTweet();

        final List<Tweet> tweetsAfterInsert = new ArrayList<Tweet>(tweets);
        tweetsAfterInsert.add(tweet);

        // Second emission: 11 tweets
        expectedTweets.add(tweetsAfterInsert);

        final EmissionChecker emissionChecker = new EmissionChecker(expectedTweets);
        final Subscription subscription = emissionChecker.subscribe();

        // We should receive 10 tweets after subscription
        emissionChecker.awaitNextExpectedValue();

        final PutResult putResult = storIOContentResolver
                .put()
                .object(tweet)
                .prepare()
                .executeAsBlocking();

        assertThat(putResult.wasInserted()).isTrue();

        // Then we should receive 11 tweets
        emissionChecker.awaitNextExpectedValue();

        emissionChecker.assertThatNoExpectedValuesLeft();
        subscription.unsubscribe();
    }

    @Test
    public void queryShouldBeUpdatedAfterUpdate() {
        // First of all -> insert some tweets into the Content Provider
        final List<Tweet> tweets = insertTweets(TestFactory.newTweets(10));

        final Queue<List<Tweet>> expectedTweets = new LinkedList<List<Tweet>>();

        // First emission: 10 tweets
        expectedTweets.add(tweets);

        final List<Tweet> tweetsAfterUpdate = new ArrayList<Tweet>(tweets);

        final Tweet tweetToUpdate = tweetsAfterUpdate.get(0);
        tweetsAfterUpdate.set(0, Tweet.newInstance(tweetToUpdate.id(), 1L, "New Content"));

        // Second emission: 10 tweets, where 1 tweet updated
        expectedTweets.add(tweetsAfterUpdate);

        final EmissionChecker emissionChecker = new EmissionChecker(expectedTweets);
        final Subscription subscription = emissionChecker.subscribe();

        // We should receive 10 tweets after subscription
        emissionChecker.awaitNextExpectedValue();

        final PutResult putResult = storIOContentResolver
                .put()
                .object(tweetsAfterUpdate.get(0))
                .prepare()
                .executeAsBlocking();

        assertThat(putResult.wasUpdated()).isTrue();

        // Then we should receive 10 tweets after update, but first tweet should be changed
        emissionChecker.awaitNextExpectedValue();

        emissionChecker.assertThatNoExpectedValuesLeft();
        subscription.unsubscribe();
    }

    @Test
    public void queryShouldBeUpdatedAfterDelete() {
        // First of all -> insert some tweets into the Content Provider
        final List<Tweet> tweets = insertTweets(TestFactory.newTweets(10));

        final Queue<List<Tweet>> expectedTweets = new LinkedList<List<Tweet>>();

        // First emission: 10 tweets
        expectedTweets.add(tweets);

        final List<Tweet> tweetsAfterDelete = new ArrayList<Tweet>(tweets);
        tweetsAfterDelete.remove(0);

        // Second emission: 9 tweets, first tweet should be deleted
        expectedTweets.add(tweetsAfterDelete);

        final EmissionChecker emissionChecker = new EmissionChecker(expectedTweets);
        final Subscription subscription = emissionChecker.subscribe();

        // We should receive 10 tweets after subscription
        emissionChecker.awaitNextExpectedValue();

        final DeleteResult deleteResult = storIOContentResolver
                .delete()
                .object(tweets.get(0))
                .prepare()
                .executeAsBlocking();

        assertThat(deleteResult.numberOfRowsDeleted()).isEqualTo(1);

        // Then we should receive 9 tweets after delete, first tweet should be deleted
        emissionChecker.awaitNextExpectedValue();

        emissionChecker.assertThatNoExpectedValuesLeft();
        subscription.unsubscribe();
    }

    @Test
    public void shouldThrowExceptionIfCursorNullObservable() {
        final PreparedGetCursor queryWithNullResult = createQueryWithNullResult();

        final TestSubscriber<Cursor> testSubscriber = new TestSubscriber<Cursor>();

        queryWithNullResult
                .createObservable()
                .subscribe(testSubscriber);

        testSubscriber.awaitTerminalEvent();
        testSubscriber.assertNoValues();

        Throwable expected = testSubscriber.getOnErrorEvents().get(0);
        assertThat(expected).isInstanceOf(StorIOException.class);
        assertThat(expected.getCause())
                .isInstanceOf(IllegalStateException.class)
                .hasMessage("Cursor returned by content provider is null");
    }
}


text:
namespace gifty.Shared.Infrastructure
{
    public interface IInfo
    {
    }
}


text:
package com.asakusafw.m3bp.mirror.jni;

import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.Matchers.*;
import static org.junit.Assert.*;

import java.nio.ByteBuffer;

import org.junit.ClassRule;
import org.junit.Test;

/**
 * Test for {@code NativeBufferUtil}.
 */
public class NativeBufferUtilTest {

    /**
     * Checks native library is enabled.
     */
    @ClassRule
    public static final NativeEnabled NATIVE = new NativeEnabled();

    /**
     * test about views.
     */
    @Test
    public void view() {
        byte[] contents = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, };

        ByteBuffer buffer = ByteBuffer.allocateDirect(contents.length);
        buffer.put(contents);
        buffer.clear();

        long address = NativeBufferUtil.getAddress(buffer);
        ByteBuffer view = NativeBufferUtil.getView(address, contents.length);
        assertThat(view.capacity(), is(contents.length));
        assertThat(NativeBufferUtil.getAddress(view), is(address));

        byte[] data = new byte[contents.length];
        view.get(data);
        view.clear();
        assertThat(data, is(contents));
    }

    /**
     * test about compare.
     */
    @Test
    public void compare() {
        byte[] contents = new byte[] { 1, 2, 3, 4, 5, 2, 3, 4, -1, };

        ByteBuffer buffer = ByteBuffer.allocateDirect(contents.length);
        buffer.put(contents);
        buffer.clear();

        long address = NativeBufferUtil.getAddress(buffer);

        assertThat(NativeBufferUtil.compare(address, address, contents.length), is(0));

        // (2, 3, 4) == (2, 3, 4)
        assertThat(NativeBufferUtil.compare(address + 1, address + 5, 3), is(0));

        // (2, 3, 4) < (3, 4, 5)
        assertThat(NativeBufferUtil.compare(address + 1, address + 2, 3), lessThan(0));

        // (2, 3, 4) > (1, 2, 3)
        assertThat(NativeBufferUtil.compare(address + 1, address + 0, 3), greaterThan(0));

        // (+1) < (255) - unsigned
        assertThat(NativeBufferUtil.compare(address + 0, address + 8, 1), lessThan(0));
    }
}


text:
class UglyNumber {
public:

    bool isUgly(int num);
};

#endif // UGLY_NUMBER_HPP_


text:
package jp.mydns.sys1yagi.android.printingframeworksample;

import jp.mydns.sys1yagi.android.printingframeworksample.custom.CustomPrintActivity;
import jp.mydns.sys1yagi.android.printingframeworksample.html.HtmlPrintActivity;
import jp.mydns.sys1yagi.android.printingframeworksample.image.ImagePrintActivity;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;

public class PrintingFrameworkSampleActivity extends Activity {
    /**
     get this object for enclosing objects.
     @return PrintingFrameworkSampleActivity this object.
     */
    private PrintingFrameworkSampleActivity This() {
        return this;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_printing_framework_sample);
        ListView listView = (ListView) findViewById(R.id.listview);

        ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
                android.R.layout.simple_list_item_1, android.R.id.text1);

        adapter.add("Image Print");
        adapter.add("HTML Print");
        adapter.add("Custom Print");

        listView.setAdapter(adapter);
        listView.setOnItemClickListener(new OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> adapter, View view, int pos,
                    long id) {
                Intent intent = null;
                switch(pos){
                case 0:
                    intent = ImagePrintActivity.createIntent(This());
                    break;
                case 1:
                    intent = HtmlPrintActivity.createIntent(This());
                    break;
                case 2:
                    intent = CustomPrintActivity.createIntent(This());
                    break;
                }

                if(intent != null){
                    startActivity(intent);
                }

            }
        });
    }
}


text:
Education

B.E Computer Science

            Sri sairam institute of Technology
            <address>Anna university, chennai</address><time>2009 to 2013</time>

            Thesis: Secured sharing of E-med records using joint encryption and watermarking


text:
require 'walrus'
require 'fileutils'
require 'optparse'
require 'ostruct'
require 'pathname'
require 'rubygems'
require 'shellwords'

module Walrus
  # Exit statuses.
  #
  # @see {bin/walrus} for exit statuses 1 through 4
  module Exit
    # Indicates a problem occurred trying to read a file.
    READ_ERROR = 32

    # Indicates a problem occurred trying to create a directory.
    MKDIR_ERROR = 33

    # Indicates a problem occurred while trying to write to a file.
    WRITE_ERROR = 34

    # Indicates a problem occurred during compilation.
    COMPILE_ERROR = 34

    # Indicates problem occurred during filling.
    FILL_ERROR = 35

    # Indicates a problem occurred during running.
    RUN_ERROR = 36
  end # module Exit

  # The {Walrus::Runner} class is instantiated from the +walrus+ executable
  # tool. It processes command-line arguments and then compiles, fills and
  # runs Walrus templates accordingly. It can process single templates or
  # multiple templates in batches.
  #
  # = Overview
  #
  # The +walrus+ executable requires a command (one of +compile+, +fill+ or
  # +run+), zero or more option switches (described below), and a list of
  # one or more input files/directories:
  #
  #    !!!sh
  #    walrus command [options] input-file-or-directory...
  #
  # = Examples
  #
  # Given the following input templates:
  #
  # - +display.css.tmpl+
  # - +index.html.tmpl+
  # - +about.html.tmpl+
  #
  # Then running:
  #
  #     !!!sh
  #     walrus compile *.tmpl
  #
  # will produce the following compiled templates:
  #
  # - +display.css.rb+
  # - +index.html.rb+
  # - +about.html.rb+
  #
  # Running:
  #
  #     !!!sh
  #     walrus fill *.tmpl
  #
  # will produce the following filled (finalized output) templates:
  #
  # - +display.css+
  # - +index.html+
  # - +about.html+
  #
  # Note that it is not strictly necessary to perform a two-step
  # compile-then-fill process, because running +walrus fill+ will
  # compile the template automatically if required.
  #
  # Executing:
  #
  #     !!!sh
  #     walrus run index.tmpl
  #
  # Will execute a compiled template (compiling it first if necessary),
  # but instead of writing the output to a file will emit it to the
  # standard output.
  #
  # Compiled templates can also be run manually, without the +walrus+
  # tool; doing so causes them to print their filled content to standard
  # output:
  #
  #     !!!sh
  #     ./index.tmpl.rb
  #
  # = Commands
  #
  # - +compile+: compile a Walrus source template into Ruby code
  # - +fill+: execute a compiled template, writing the output to a file
  # - +run+: execute a compiled template, printing the output to standard
  #   output
  #
  # == The +compile+ command
  #
  # To compile a template Walrus reads and scans it for items which have
  # special meaning to Walrus:
  #
  # - directives: keywords which provide information about the structure or
  #   behavior of a template (examples: +#def+, +#block+ and +#set+)
  # - placeholders: instructions to dynamically insert content at "fill" time;
  #   placeholders look like +$foo+ or +$bar(1)+
  # - escape sequences: characters which would otherwise have special meaning for
  #   Walrus (+#+ and +$+) preceded by a backslash
  # - comments: Walrus comments start with either +##+ (single-line comments) or
  #   are delimited by +#*+ and +*#+ (multi-line comments)
  #
  # All other text is passed through unchanged, which means that Walrus can be
  # used to create output files in any language.
  #
  # Templates are compiled to executable Ruby code.
  #
  # == The +fill+ command
  #
  # "Filling" a template causes the compiled template to be run, and the output
  # is written back to a file on disk.
  #
  # == The +run+ command
  #
  # "Running" a template is like filling it, except that instead of writing the
  # output to a file on disk it is instead sent to the standard output.
  #
  # = Options
  #
  # == +-o+/+--output-dir DIR+
  #
  # Output directory (when filling).
  #
  # Defaults to same directory as input template.
  #
  # When compiling, this setting has no effect, because compiled templates
  # always reside in the same directory as the corresponding source
  # templates.
  #
  # == +-i+/+--input-extension EXT+
  #
  # Extension for input file(s).
  #
  # Defaults to +tmpl+.
  #
  # Walrus constructs input file names in the following manner:
  #
  # - if the specified file name already has the right extension it is used
  #   as-is
  # - otherwise, if the user has specified a zero-length extension (the empty
  #   string) via the +-i+/+--input-extension+ switch, the specified file
  #   name is used as-is
  # - otherwise, the extension is appended to the file name
  #
  # Normally Walrus expects input templates to have a +tmpl+ extension. Given
  # a template +example.html.tmpl+, you can instruct walrus to compile it
  # with either:
  #
  #     !!!sh
  #     walrus compile example.html.tmpl
  #
  # or:
  #
  #     !!!sh
  #     walrus compile example.html
  #
  # In general specifying the full file name including the +tmpl+ extension is
  # easier because it allows you to select source templates via tab-completion
  # or shell globs:
  #
  #     !!!sh
  #     walrus compile *.tmpl
  #
  # If you prefer to use another extension, such as +template+, for example,
  # you could use the +-i+/+--input-extension+ switch to process the
  # +example.html.template+ template with either:
  #
  #     !!!sh
  #     walrus compile -i template example.html.template
  #
  # or:
  #
  #     !!!sh
  #     walrus compile -i template example.html
  #
  # If you prefer to use no extension at all, that is possible also by passing
  # in an empty string for the +-i+/+--input-extension+ switch. For example,
  # given template +example.html+, you could compile with:
  #
  #     !!!sh
  #     walrus compile -i '' example.html
  #
  # Note that if you chose to fill such a template you will either need to add
  # an output extension using the +-e+/+--output-extension+ switch, or specify
  # a different output directory using the +-o+/+--output-dir+ switch, otherwise
  # the source template will be overwritten.
  #
  # == +-e+/+--output-extension EXT+
  #
  # Extension for output file(s) (when filling).
  #
  # Defaults to no extension.
  #
  # Walrus constructs output file names for filled templates in the following
  # manner:
  #
  # - if the input extension (default: +tmpl+) appears in the supplied input
  #   template file-name, remove it
  # - if an output extension was supplied via the +-e+/+--output-extension+
  #   switch (default: no extension) add it
  #
  # In a typical workflow this means the following:
  #
  #     !!!sh
  #     walrus compile example.html.tmpl  # => compiles to: example.html.rb
  #     walrus fill example.html.tmpl     # => writes to:   example.html
  #
  # == +-R+/+--[no-]recurse+
  #
  # Search subdirectories recursively for input files. If a directory is
  # supplied as one of the inputs then any subdirectories contained within
  # it will be recursively explored for templates.
  #
  # Defaults to on.
  #
  # When off, if a directory is specified then only templates in its top
  # level will be processed; subdirectories contained within will not be
  # explored.
  #
  # In both recursive and non-recursive modes of operation, Walrus decides
  # whether a directory entry should be processed on the basis of its
  # extension: only entries matching the +--input-extension+ will be selected
  # for processing.
  #
  # == +-b+/+--[no-]backup+
  #
  # Make backups before overwriting. A backup of the form +original_filename.bak+
  # will be written prior to modifying any file on disk.
  #
  # Defaults to on.
  #
  # == +-f+/+--force+
  #
  # Force recompile (when filling).
  #
  # Defaults to off (files are normally only recompiled if the source is newer
  # than the output).
  #
  # == +--halt+
  #
  # Halts when encountering an error (even a non-fatal error). If multiple input
  # templates were specified on the command-line any remaining templates will not
  # be processed.
  #
  # Defaults to off.
  #
  # When +--halt+ is off, processing will continue after non-fatal errors. In the
  # case of non-fatal errors in multiple input templates, the exit status of the
  # +walrus+ command-line tool will correspond to the last-encountered error.
  #
  # == +-t+/+--test+
  #
  # Performs a "dry" (test) run in which no modifications are made to the filesystem
  # during execution. This, combined with the +--verbose+ switch, can be used to get
  # a preview of what changes would be made, without actually committing any of the
  # changes to disk.
  #
  # Defaults to off.
  #
  # == +-v+/+--verbose+
  #
  # Run verbosely.
  #
  # Defaults to off.
  #
  # == +-h+/+--help+
  #
  # Shows usage information.
  #
  # == +--version+
  #
  # Shows the Walrus version.
  class Runner
    # Used to signal early exit to the caller when the +--halt+ option is
    # active.
    class Error < Exception
      attr_accessor :exit_status
    end

    # This is different from the standard ::ArgumentError; it is specifically
    # used to signal errors in the command-line arguments passed to the runner.
    class ArgumentError < Error; end

    def initialize
      @exit_status                = 0
      @options                    = OpenStruct.new
      @options.output_dir         = nil
      @options.input_extension    = 'tmpl'
      @options.output_extension   = ''
      @options.recurse            = true
      @options.backup             = true
      @options.force              = false
      @options.halt               = false
      @options.dry                = false
      @options.verbose            = false

      @command  = nil # "compile", "fill", "run"
      @inputs   = []  # list of input files/directories
      parser    = OptionParser.new do |o|
        o.banner  = "Usage: #{o.program_name} command input-file(s)-or-directory/ies [options]"
        o.separator ''
        o.separator "          ___"
        o.separator "       .-9 9 `\\           #{o.program_name} version #{Walrus::VERSION}"
        o.separator "     =(:(::)=  ;          Command-line front-end for the Walrus templating system"
        o.separator "       ||||     \\         #{Walrus::COPYRIGHT}"
        o.separator "       ||||      `-."
        o.separator "      ,\\|\\|         `,"
        o.separator "     /                \\"
        o.separator "    ;                  `'---.,"
        o.separator "    |                         `\\"
        o.separator "    ;                     /     |"
        o.separator "    \\                    |      /"
        o.separator "     )           \\  __,.--\\    /"
        o.separator "  .-' \\,..._\\     \\`   .-'  .-'"
        o.separator " `-=``       `:    |  /-/-/`"
        o.separator "               `.__/           jgs"
        o.separator ''
        o.separator 'Commands: compile -- compile templates to Ruby code'
        o.separator '          fill    -- run compiled templates, writing output to disk'
        o.separator '          run     -- run compiled templates, printing output to standard output'
        o.separator ''

        o.on('-o', '--output-dir DIR',
             'Output directory (when filling)',
             'defaults to same directory as input file') do |opt|
          @options.output_dir = Pathname.new opt
        end

        o.on('-i', '--input-extension EXT',
             'Extension for input file(s)', 'default: tmpl') do |opt|
          @options.input_extension = opt
        end

        o.on('-e', '--output-extension EXT',
             'Extension for output file(s) (when filling)',
             'default: none') do |opt|
          @options.output_extension = opt
        end

        o.on('-R', '--[no-]recurse',
             'Search subdirectories recursively for input files',
             'default: on') do |opt|
          @options.recurse = opts
        end

        o.on('-b', '--[no-]backup',
             'Make backups before overwriting', 'default: on') do |opt|
          @options.backup = opt
        end

        o.on('-f', '--force',
             'Force a recompile (when filling)',
             'default: off (files only recompiled if source newer than output)') do |opt|
          @options.force = opt
        end

        o.on('--halt',
             'Halts on encountering an error (even a non-fatal error)',
             'default: off') do |opt|
          @options.halt = opt
        end

        o.on('-t', '--test',
             'Performs a "dry" (test) run', 'default: off') do |opt|
          @options.dry = opt
        end

        o.on('-v', '--verbose', 'Run verbosely', 'default: off') do |opt|
          @options.verbose = opt
        end

        o.separator ''

        o.on_tail('-h', '--help', 'Show this message') do
          $stderr.puts o
          exit
        end

        o.on_tail('--version', 'Show version') do
          $stderr.puts 'Walrus ' + Walrus::VERSION
          exit
        end
      end

      begin
        parser.parse!
      rescue OptionParser::InvalidOption => e
        raise ArgumentError.new(e)
      end

      parser.order! do |item|
        if @command.nil?  # get command first ("compile", "fill" or "run")
          @command = item
        else # all others (must be at least one) are file or directory names
          @inputs << Pathname.new(item)
        end
      end

      raise ArgumentError, 'no command specified' if @command.nil?
      raise ArgumentError, 'no inputs specified' unless @inputs.length > 0
    end

    def run
      log "Beginning processing: #{Time.new}."
      expand(@inputs).each do |input|
        case @command
        when 'compile'
          log "Compiling '#{input}'."
          compile input
        when 'fill'
          log "Filling '#{input}'."
          compile_if_needed input
          begin
            write_string_to_path get_output(input),
              filled_output_path_for_input(input)
          rescue Exception => e
            handle_error e, Exit::FILL_ERROR
          end
        when 'run'
          log "Running '#{input}'."
          compile_if_needed input
          begin
            printf '%s', get_output(input)
            $stdout.flush
          rescue Exception => e
            handle_error e, Exit::RUN_ERROR
          end
        else
          raise ArgumentError, "unrecognized command '#{@command}'"
        end
      end
      log "Processing complete: #{Time.new}."
      @exit_status
    end

  private

    # Expects an array of Pathname objects.
    # Directory inputs are themselves recursively expanded if the "recurse"
    # option is set to true; otherwise only their top-level entries are
    # expanded.
    # Returns an expanded array of Pathname objects.
    def expand inputs
      expanded = []
      inputs.each do |input|
        if input.directory?
          input.each_entry do |entry|
            next if ['.', '..'].any? { |d| d == entry.to_s }
            entry = input + entry # want full path, not path relative to input
            if entry.directory?
              if @options.recurse
                expanded.concat expand([entry])
              end
            else # not a directory
              regexp = Regexp.escape @options.input_extension
              expanded << entry if entry.to_s =~ /\.#{regexp}\z/
            end
          end
        else # not a directory
          expanded << input
        end
      end
      expanded
    end

    def compile_if_needed input
      compile input, false
    end

    def compiled_path_older_than_source_path compiled_path, source_path
      begin
        compiled  = File.mtime compiled_path
        source    = File.mtime source_path
      rescue SystemCallError # perhaps one of them doesn't exist
        return true
      end
      compiled < source
    end

    def compile input, force = true
      template_source_path  = template_source_path_for_input input
      compiled_path         = compiled_source_path_for_input input
      if force or @options.force or not compiled_path.exist? or
        compiled_path_older_than_source_path(compiled_path, template_source_path)
        begin
          template = Template.new template_source_path
        rescue Exception => e
          handle_error \
            "failed to read input template '#{template_source_path}' (#{e})",
            Exit::READ_ERROR
          return
        end

        begin
          compiled = template.compile
        rescue Walrat::ParseError => e
          handle_error \
            "failed to compile input template '#{template_source_path}' (#{e})",
            Exit::COMPILE_ERROR
          return
        end
        write_string_to_path compiled, compiled_path, true
      end
    end

    def get_output input
      if @options.dry
        "(no output: dry run)\n"
      else
        path = compiled_source_path_for_input(input)
        Object.class_eval path.read, path.to_s
      end
    end

    def write_string_to_path string, path, executable = false
      if @options.dry
        log "Would write '#{path}' (dry run)."
      else
        unless path.dirname.exist?
          begin
            log "Creating directory '#{path.dirname}'."
            FileUtils.mkdir_p path.dirname
          rescue SystemCallError => e
            handle_error e, Exit::MKDIR_ERROR
            return
          end
        end

        log "Writing '#{path}'."
        begin
          File.open path, "a+" do |f|
            if not File.zero? path and @options.backup
              log "Making backup of existing file at '#{path}'."
              dir, base = path.split
              FileUtils.cp path, dir + "#{base}.bak"
            end
            f.flock File::LOCK_EX
            f.truncate 0
            f.write string
            f.chmod 0744 if executable
          end
        rescue SystemCallError => e
          handle_error e, Exit::WRITE_ERROR
        end
      end
    end

    def adjusted_output_path path
      if @options.output_dir
        if path.absolute?
          path = @options.output_dir + path.to_s.sub(/\A\//, '')
        else
          path = @options.output_dir + path
        end
      else
        path
      end
    end

    # If "input" already has the right extension it is returned unchanged.
    # If the "input extension" is zero-length then "input" is returned
    # unchanged.
    # Otherwise the "input extension" is added to "input" and returned.
    def template_source_path_for_input input
      return input if input.extname == ".#{@options.input_extension}" # input already has the right extension
      return input if @options.input_extension.length == 0            # zero-length extension, nothing to add
      dir, base = input.split
      dir + "#{base}.#{@options.input_extension}"                     # otherwise, add extension and return
    end

    def compiled_source_path_for_input input
      # remove input extension if present
      if input.extname == ".#{@options.input_extension}" and
        @options.input_extension.length > 0
        dir, base = input.split
        input = dir + base.basename(base.extname)
      end

      # add rb as an extension
      dir, base = input.split
      dir + "#{base}.rb"
    end

    def filled_output_path_for_input input
      # remove input extension if present
      if input.extname == ".#{@options.input_extension}" and
        @options.input_extension.length > 0
        dir, base = input.split
        input = dir + base.basename(base.extname)
      end

      # add output extension if appropriate
      if @options.output_extension.length > 0
        dir, base = input.split
        adjusted_output_path(dir + "#{base}.#{@options.output_extension}")
      else
        adjusted_output_path input
      end
    end

    # Writes "message" to standard error if user supplied the "--verbose"
    # switch.
    def log message
      if @options.verbose
        $stderr.puts message
      end
    end

    # If the user supplied the "--halt" switch raises a Runner::Error exception
    # based on "message".
    # Otherwise merely prints "message" to the standard error.
    def handle_error message, exit_status
      if @options.halt
        error = Error.new message
        error.exit_status = exit_status
        raise error
      else
        @exit_status = exit_status
        $stderr.puts ":: error: #{message}"
      end
    end
  end # class Runner
end # module Walrus


text:
import React from 'react';
import { Row, Col, Card, Icon } from 'antd';
import styles from './user-detail-container.less';
import weiGuDong from '../../appConstants/assets/images/微股东.png';
import normalCard from '../../appConstants/assets/images/普卡.png';
import silverCard from '../../appConstants/assets/images/银卡.png';
import goldenCard from '../../appConstants/assets/images/金卡.png';
import superGoldenCard from '../../appConstants/assets/images/白金卡.png';
import goodJujianshang from '../../appConstants/assets/images/good-jjs.png';
import { getUserDetailData } from '../../api/app-interaction-api.js';

const UserDetailContainer = React.createClass({
	getInitialState(){
		return {
			user_sn: '',
			userInfo: '',
			accounts: []
		}
	},
	jinLevels() {
        return ['注册用户', weiGuDong, normalCard, silverCard, goldenCard, superGoldenCard, goodJujianshang];
    },
    componentWillMount(){
    	const user_sn = this.props.params.userId;
        this.setState({
        	user_sn: user_sn
        })
    },
    componentDidMount(){
    	var _this = this;
    	const user_sn = this.state.user_sn;
    	getUserDetailData({sn:user_sn},function(info){
    		console.log(info)
    		_this.setState({
    			userInfo: info.data,
    			accounts: info.data.accounts
    		});
    	},function(info){
    		console.log('fail',info)
    	});
    },
	render(){
		const level = this.jinLevels();
        const data = this.state.userInfo;
        var wx_name = data.wechat_nickname ? '('+data.wechat_nickname+')' : '';
        var levelmark = data.level == 0 ? '注册用户' : (

        	);
        var goodJjsMark = data.is_excellent == 1 ? (

        ) : '';

        const accountList = this.state.accounts.map(function(data,index){
        	var accountStatus;
    		if(data.account_status == 2){
    			accountStatus = (

    				<Icon className="success" type="check-circle-o" />

已审核通过

)
    		}else if(data.account_status == 3){
    			accountStatus = (

    				<Icon className="fail" type="info-circle-o" />

审核未通过

)
    		}else{
    			accountStatus = (

    				<Icon className="ing" type="clock-circle-o" />

待审核

)
    		}
    		return (
		    	<Col span={8} className={styles.userAccountList}>

{data.type_name}

		    				<labal>账号</labal>

{data.account || (用户未开户)}

		    				<labal>身份证姓名</labal>

{data.real_name}

		    				<labal>身份证号</labal>

{data.id_card_no}

		    				<labal>银行卡号</labal>

{data.bank_card_no}

		    			{accountStatus}

				</Col>
    		)
    	});
		return (

{data.user_name}

{wx_name}

{levelmark}{goodJjsMark}

手机号码:{data.cellphone}

所属居间商:{data.jujianshang_corp_name}

一度人脉数量:{data.children_sum}

邀请人:{data.inv_user_name}

注册时间:{data.register_date}

					<Row className={styles.userAccount}>
						{accountList}
				    </Row>

		)
	},
});

export default UserDetailContainer;


text:
<?php

/*
 * This file is part of the BalloonFormBuilderBundle
 *
 * (c) Balloon <contact@balloonup.com>
 *
 * This source file is subject to the MIT license that is bundled
 * with this source code in the file LICENSE.
 */

namespace Balloon\Bundle\FormBuilderBundle\Form;

use Doctrine\Common\Persistence\ObjectManager;

/**
 * Manager
 *
 * @author Jules Boussekeyt <jules.boussekeyt@gmail.com>
 */
class Manager
{
    protected $objectManager;
    protected $repository;

    public function __construct(ObjectManager $objectManager, $repositoryName)
    {
        $this->objectManager    = $objectManager;
        $this->repository       = $this->objectManager->getRepository($repositoryName);
    }

    public function getRepository()
    {
        // @codeCoverageIgnoreStart
        return $this->repository;
        // @codeCoverageIgnoreEnd
    }

    public function find($id)
    {
        return $this->repository->find($id);
    }

    public function findAll()
    {
        return $this->repository->findAll();
    }
}