text:
({
    /**
     * Note that this test file operates in system mode (objects are not Lockerized) so the tests delegate logic and
     * verification to the controller and helper files, which operate in user mode.
     */

    // LockerService not supported on IE
    browsers: ["-IE8", "-IE9", "-IE10", "-IE11"],

    testInternalFieldsOnHostElement: {
        test: function(cmp) {
            cmp.find('lwcChild').testInternalFieldsOnHostElement();
        }
    }
})

redpajama_set_name: RedPajamaGithub


text:
Parallax scroll, we are back in 2010?? no, wish i was back there with the same knowledge i have today. I have tried parallax in videos games before and in some of my canvas experiments, but never tried to make a parallax scroll webpage!

There is lot's of plugins out there to archive the parallax effect, but i didn't use any of it. The main goal is learn how to make it and don't be limited by the plugin's features!

While programming this i realize (again), that it's possibe to extract numbers from anything and do crazy fun stuff with it. I think this is really really fun!

## Performance

I'm not animating colors, so it'll not be 'expensive' to repaint DOM stuff. I'm  using (CSS) translate to move all the rectangles. The canvas animations only runs (update and draw) if is on screen. And is not matematicaly possivel to have two canvas animations on screen at the same time!

The rectangles on the background are updated only if it's container is on screen and if the rectangle itself is on screen, about 12 rectangles a moved each time the scroll event is trigged and no more then 20 rectangles are checked!

## Tools

ES6 ([babel](https://babeljs.io));
[Zepto](zeptojs.com);
[tween.js](https://github.com/tweenjs/tween.js)
[random.js](https://github.com/ckknight/random-js)


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

    Licensed to the Apache Software Foundation (ASF) under one or more
    contributor license agreements.  See the NOTICE file distributed with
    this work for additional information regarding copyright ownership.
    The ASF licenses this file to You under the Apache License, Version 2.0
    (the "License"); you may not use this file except in compliance with
    the License.  You may obtain a copy of the License at

         http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.

-->
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:camel="http://camel.apache.org/schema/spring"
	xsi:schemaLocation="
	   http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
       http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">

	<camelContext xmlns="http://camel.apache.org/schema/spring">

		<route>
			<from uri="direct:set" />
			<setHeader headerName="CamelHazelcastOperationType">
				<constant>setvalue</constant>
			</setHeader>
			<to uri="hazelcast:atomicvalue:foo" />
		</route>

		<route>
			<from uri="direct:get" />
			<setHeader headerName="CamelHazelcastOperationType">
				<constant>get</constant>
			</setHeader>
			<to uri="hazelcast:atomicvalue:foo" />
		</route>

		<route>
			<from uri="direct:increment" />
			<setHeader headerName="CamelHazelcastOperationType">
				<constant>increment</constant>
			</setHeader>
			<to uri="hazelcast:atomicvalue:foo" />
		</route>

		<route>
			<from uri="direct:decrement" />
			<setHeader headerName="CamelHazelcastOperationType">
				<constant>decrement</constant>
			</setHeader>
			<to uri="hazelcast:atomicvalue:foo" />
		</route>

		<route>
			<from uri="direct:compareAndSet" />
			<setHeader headerName="CamelHazelcastOperationType">
				<constant>compareAndSet</constant>
			</setHeader>
			<to uri="hazelcast:atomicvalue:foo" />
		</route>

		<route>
			<from uri="direct:getAndAdd" />
			<setHeader headerName="CamelHazelcastOperationType">
				<constant>getAndAdd</constant>
			</setHeader>
			<to uri="hazelcast:atomicvalue:foo" />
		</route>

		<route>
			<from uri="direct:destroy" />
			<setHeader headerName="CamelHazelcastOperationType">
				<constant>destroy</constant>
			</setHeader>
			<to uri="hazelcast:atomicvalue:foo" />
		</route>

	</camelContext>

</beans>


text:
import { NgModule } from '@angular/core';
// services
import { AuthService } from './auth.service';

import { ActServiceService } from './act-service.service';
import { AuthGuard } from './auth.guard';
import { AdminGuard } from './admin.guard';
import { GoogleTagsService } from '../google-tags.service';

@NgModule({
  imports: [
  ],
  declarations: [],
  exports: [
  ],
  providers: [AuthService, AuthGuard, AdminGuard, ActServiceService, GoogleTagsService ]
})
export class CoreModule { }


text:
public class Lst ... implements LispObject {

    @Override
    public LispObject eval(Scope scope) throws InterpreterException {
        LispObject first = get(0);
        List<LispObject> rest = subList(1, size());
        LispObject firstEvaled =  first.eval(scope);
        if (!(firstEvaled instanceof Callable)) {
            throw new ArgShouldBeCallableException();
        }
        Callable callable = (Callable) firstEvaled;
        callable.validate(new ArgsValidator(rest), scope);
        return callable.call(rest, scope);
    }
}


text:
@echo off
call %~dp0test.bat


text:
Search

                    <button data-toggle="dropdown" class="btn btn-primary dropdown-toggle" type="button">
                        Show Search
                    </button>

                            {{ condName }}

                    <button class="btn btn-default" type="button" ng-click="startSearch()">
                        Start Search
                    </button>

                            Selected Date:
                            {{ selectedDate.value }}
                            Selected Category:
                            {{ selectedCategory.title }}

                                    Selected Tags:

                                        {{ tag.title }}

                            Categories:

                                {{ category.title }}

                            Tags:

                                {{ tag.title }}


text:
namespace login_manager {  // NOLINT
namespace gobject {  // NOLINT
#include "login_manager/bindings/server.h"
}  // namespace gobject
}  // namespace login_manager

namespace em = enterprise_management;
namespace login_manager {

using std::make_pair;
using std::pair;
using std::string;
using std::vector;

// Jacked from chrome base/eintr_wrapper.h
#define HANDLE_EINTR(x) ({ \
  typeof(x) __eintr_result__; \
  do { \
    __eintr_result__ = x; \
  } while (__eintr_result__ == -1 && errno == EINTR); \
  __eintr_result__;\
})

int g_shutdown_pipe_write_fd = -1;
int g_shutdown_pipe_read_fd = -1;

// static
// Common code between SIG{HUP, INT, TERM}Handler.
void SessionManagerService::GracefulShutdownHandler(int signal) {
  // Reinstall the default handler.  We had one shot at graceful shutdown.
  struct sigaction action;
  memset(&action, 0, sizeof(action));
  action.sa_handler = SIG_DFL;
  RAW_CHECK(sigaction(signal, &action, NULL) == 0);

  RAW_CHECK(g_shutdown_pipe_write_fd != -1);
  RAW_CHECK(g_shutdown_pipe_read_fd != -1);
  size_t bytes_written = 0;
  do {
    int rv = HANDLE_EINTR(
        write(g_shutdown_pipe_write_fd,
              reinterpret_cast<const char*>(&signal) + bytes_written,
              sizeof(signal) - bytes_written));
    RAW_CHECK(rv >= 0);
    bytes_written += rv;
  } while (bytes_written < sizeof(signal));

  RAW_LOG(INFO,
          "Successfully wrote to shutdown pipe, resetting signal handler.");
}

// static
void SessionManagerService::SIGHUPHandler(int signal) {
  RAW_CHECK(signal == SIGHUP);
  RAW_LOG(INFO, "Handling SIGHUP.");
  GracefulShutdownHandler(signal);
}
// static
void SessionManagerService::SIGINTHandler(int signal) {
  RAW_CHECK(signal == SIGINT);
  RAW_LOG(INFO, "Handling SIGINT.");
  GracefulShutdownHandler(signal);
}

// static
void SessionManagerService::SIGTERMHandler(int signal) {
  RAW_CHECK(signal == SIGTERM);
  RAW_LOG(INFO, "Handling SIGTERM.");
  GracefulShutdownHandler(signal);
}

// static
const uint32 SessionManagerService::kMaxEmailSize = 200;
// static
const char SessionManagerService::kEmailSeparator = '@';
// static
const char SessionManagerService::kLegalCharacters[] =
    "abcdefghijklmnopqrstuvwxyz"
    "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
    ".@1234567890-+_";
// static
const char SessionManagerService::kIncognitoUser[] = "";
// static
const char SessionManagerService::kDeviceOwnerPref[] = "cros.device.owner";
// static
const char SessionManagerService::kTestingChannelFlag[] =
    "--testing-channel=NamedTestingInterface:";
// static
const char SessionManagerService::kIOThreadName[] = "ThreadForIO";

namespace {

// Time we wait for child job to die (in seconds).
const int kKillTimeout = 3;

const int kMaxArgumentsSize = 1024;

}  // namespace

SessionManagerService::SessionManagerService(
    std::vector<ChildJobInterface*> child_jobs)
    : child_jobs_(child_jobs.begin(), child_jobs.end()),
      child_pids_(child_jobs.size(), -1),
      exit_on_child_done_(false),
      session_manager_(NULL),
      main_loop_(g_main_loop_new(NULL, FALSE)),
      system_(new SystemUtils),
      policy_(new DevicePolicy(FilePath(DevicePolicy::kDefaultPath))),
      nss_(NssUtil::Create()),
      key_(new OwnerKey(nss_->GetOwnerKeyFilePath())),
      gen_(new KeyGenerator),
      upstart_signal_emitter_(new UpstartSignalEmitter),
      session_started_(false),
      io_thread_(kIOThreadName),
      dont_use_directly_(new MessageLoopForUI),
      message_loop_(base::MessageLoopProxy::CreateForCurrentThread()),
      screen_locked_(false),
      set_uid_(false),
      shutting_down_(false) {
  io_thread_.Start();
  memset(signals_, 0, sizeof(signals_));
  SetupHandlers();
}

SessionManagerService::~SessionManagerService() {
  if (main_loop_)
    g_main_loop_unref(main_loop_);
  if (session_manager_)
    g_object_unref(session_manager_);

  // Remove this in case it was added by StopSession().
  g_idle_remove_by_data(this);

  // Remove this in case it was added by SetOwnerKey().
  g_idle_remove_by_data(key_.get());

  struct sigaction action;
  memset(&action, 0, sizeof(action));
  action.sa_handler = SIG_DFL;
  CHECK(sigaction(SIGUSR1, &action, NULL) == 0);
  CHECK(sigaction(SIGALRM, &action, NULL) == 0);
  CHECK(sigaction(SIGTERM, &action, NULL) == 0);
  CHECK(sigaction(SIGINT, &action, NULL) == 0);
  CHECK(sigaction(SIGHUP, &action, NULL) == 0);

  STLDeleteElements(&child_jobs_);
}

bool SessionManagerService::Initialize() {
  // Install the type-info for the service with dbus.
  dbus_g_object_type_install_info(
      gobject::session_manager_get_type(),
      &gobject::dbus_glib_session_manager_object_info);

  // Creates D-Bus GLib signal ids.
  signals_[kSignalSessionStateChanged] =
      g_signal_new("session_state_changed",
                   gobject::session_manager_get_type(),
                   G_SIGNAL_RUN_LAST,
                   0,               // class offset
                   NULL, NULL,      // accumulator and data
                   // TODO: This is wrong.  If you need to use it at some point
                   // (probably only if you need to listen to this GLib signal
                   // instead of to the D-Bus signal), you should generate an
                   // appropriate marshaller that takes two string arguments.
                   // See e.g. http://goo.gl/vEGT4.
                   g_cclosure_marshal_VOID__STRING,
                   G_TYPE_NONE,     // return type
                   2,               // num params
                   G_TYPE_STRING,   // state ("started" or "stopped")
                   G_TYPE_STRING);  // current user

  LOG(INFO) << "SessionManagerService starting";
  if (!policy_->LoadOrCreate())
    LOG(ERROR) << "Could not load existing policy.  Continuing anyway...";
  return Reset();
}

bool SessionManagerService::Register(
    const chromeos::dbus::BusConnection &connection) {
  if (!chromeos::dbus::AbstractDbusService::Register(connection))
    return false;
  const std::string filter =
      StringPrintf("type='method_call', interface='%s'", service_interface());
  DBusConnection* conn =
      ::dbus_g_connection_get_connection(connection.g_connection());
  CHECK(conn);
  DBusError error;
  ::dbus_error_init(&error);
  ::dbus_bus_add_match(conn, filter.c_str(), &error);
  if (::dbus_error_is_set(&error)) {
    LOG(WARNING) << "Failed to add match to bus: " << error.name << ", message="
                 << (error.message ? error.message : "unknown error");
    return false;
  }
  if (!::dbus_connection_add_filter(conn,
                                    &SessionManagerService::FilterMessage,
                                    this,
                                    NULL)) {
    LOG(WARNING) << "Failed to add filter to connection";
    return false;
  }
  return true;
}

bool SessionManagerService::Reset() {
  if (session_manager_)
    g_object_unref(session_manager_);
  session_manager_ =
      reinterpret_cast<gobject::SessionManager*>(
          g_object_new(gobject::session_manager_get_type(), NULL));

  // Allow references to this instance.
  session_manager_->service = this;

  if (main_loop_)
    g_main_loop_unref(main_loop_);
  main_loop_ = g_main_loop_new(NULL, false);
  if (!main_loop_) {
    LOG(ERROR) << "Failed to create main loop";
    return false;
  }
  dont_use_directly_.reset(NULL);
  dont_use_directly_.reset(new MessageLoopForUI);
  message_loop_ = base::MessageLoopProxy::CreateForCurrentThread();
  return true;
}

bool SessionManagerService::Run() {
  if (!main_loop_) {
    LOG(ERROR) << "You must have a main loop to call Run.";
    return false;
  }

  int pipefd[2];
  int ret = pipe(pipefd);
  if (ret < 0) {
    PLOG(DFATAL) << "Failed to create pipe";
  } else {
    g_shutdown_pipe_read_fd = pipefd[0];
    g_shutdown_pipe_write_fd = pipefd[1];
    g_io_add_watch_full(g_io_channel_unix_new(g_shutdown_pipe_read_fd),
                        G_PRIORITY_HIGH_IDLE,
                        GIOCondition(G_IO_IN | G_IO_PRI | G_IO_HUP),
                        HandleKill,
                        this,
                        NULL);
  }

  if (ShouldRunChildren()) {
    RunChildren();
  } else {
    AllowGracefulExit();
  }

  // TODO(cmasone): A corrupted owner key means that the user needs to go
  //                to recovery mode.  How to tell them that from here?
  CHECK(key_->PopulateFromDiskIfPossible());
  MessageLoop::current()->Run();
  CleanupChildren(kKillTimeout);

  return true;
}

bool SessionManagerService::ShouldRunChildren() {
  return !file_checker_.get() || !file_checker_->exists();
}

bool SessionManagerService::ShouldStopChild(ChildJobInterface* child_job) {
  return child_job->ShouldStop();
}

bool SessionManagerService::Shutdown() {
  DeregisterChildWatchers();
  if (session_started_) {
    DLOG(INFO) << "emitting D-Bus signal SessionStateChanged:stopped";
    if (signals_[kSignalSessionStateChanged]) {
      g_signal_emit(session_manager_,
                    signals_[kSignalSessionStateChanged],
                    0, "stopped", current_user_.c_str());
    }
  }

  // Even if we haven't gotten around to processing a persist task.
  base::WaitableEvent event(true, false);
  io_thread_.message_loop()->PostTask(
      FROM_HERE, NewRunnableMethod(this,
                                   &SessionManagerService::PersistPolicySync,
                                   &event));
  event.Wait();
  io_thread_.Stop();
  message_loop_->PostTask(FROM_HERE, new MessageLoop::QuitTask());
  LOG(INFO) << "SessionManagerService quitting run loop";
  return true;
}

void SessionManagerService::RunChildren() {
  bootstat_log("chrome-exec");
  for (size_t i_child = 0; i_child < child_jobs_.size(); ++i_child) {
    ChildJobInterface* child_job = child_jobs_[i_child];
    LOG(INFO) << "Running child " << child_job->GetName() << "...";
    child_pids_[i_child] = RunChild(child_job);
  }
}

int SessionManagerService::RunChild(ChildJobInterface* child_job) {
  child_job->RecordTime();
  int pid = fork();
  if (pid == 0) {
    child_job->Run();
    exit(1);  // Run() is not supposed to return.
  }
  // TODO(cmasone): Remove the watcher when the child exits.
  child_watchers_.push_back(g_child_watch_add_full(G_PRIORITY_HIGH_IDLE,
                                                   pid,
                                                   HandleChildExit,
                                                   this,
                                                   NULL));
  return pid;
}

void SessionManagerService::KillChild(const ChildJobInterface* child_job,
                                      int child_pid) {
  uid_t to_kill_as = getuid();
  if (child_job->IsDesiredUidSet())
    to_kill_as = child_job->GetDesiredUid();
  system_->kill(-child_pid, to_kill_as, SIGKILL);
}

void SessionManagerService::AdoptChild(ChildJobInterface* child_job,
                                       int child_pid) {
  child_jobs_.push_back(child_job);
  child_pids_.push_back(child_pid);
}

bool SessionManagerService::IsKnownChild(int pid) {
  return std::find(child_pids_.begin(), child_pids_.end(), pid) !=
      child_pids_.end();
}

void SessionManagerService::AllowGracefulExit() {
  shutting_down_ = true;
  if (exit_on_child_done_) {
    LOG(INFO) << "SessionManagerService set to exit on child done";
    message_loop_->PostTask(
        FROM_HERE,
        NewRunnableMethod(this, &SessionManagerService::Shutdown));
  }
}

///////////////////////////////////////////////////////////////////////////////
// SessionManagerService commands

gboolean SessionManagerService::EmitLoginPromptReady(gboolean* OUT_emitted,
                                                     GError** error) {
  bootstat_log("login-prompt-ready");
  // TODO(derat): Stop emitting this signal once no one's listening for it.
  // Jobs that want to run after we're done booting should wait for
  // login-prompt-visible or boot-complete.
  *OUT_emitted =
      upstart_signal_emitter_->EmitSignal("login-prompt-ready", "", error);
  return *OUT_emitted;
}

gboolean SessionManagerService::EmitLoginPromptVisible(GError** error) {
  bootstat_log("login-prompt-visible");
  return upstart_signal_emitter_->EmitSignal("login-prompt-visible", "", error);
}

gboolean SessionManagerService::EnableChromeTesting(gboolean force_relaunch,
                                                    gchar** extra_arguments,
                                                    gchar** OUT_filepath,
                                                    GError** error) {
  // Check to see if we already have Chrome testing enabled.
  bool already_enabled = !chrome_testing_path_.empty();

  if (!already_enabled) {
    // Create a write-only temporary directory to put the testing channel in.
    FilePath temp_dir_path;
    if (!file_util::CreateNewTempDirectory(
        FILE_PATH_LITERAL(""), &temp_dir_path))
      return FALSE;
    if (chmod(temp_dir_path.value().c_str(), 0003))
      return FALSE;

    // Get a temporary filename in the temporary directory.
    char* temp_path = tempnam(temp_dir_path.value().c_str(), "");
    if (!temp_path)
      return FALSE;
    chrome_testing_path_ = temp_path;
    free(temp_path);
  }

  *OUT_filepath = g_strdup(chrome_testing_path_.c_str());

  if (already_enabled && !force_relaunch)
    return TRUE;

  // Delete testing channel file if it already exists.
  file_util::Delete(FilePath(chrome_testing_path_), false);

  for (size_t i_child = 0; i_child < child_jobs_.size(); ++i_child) {
    ChildJobInterface* child_job = child_jobs_[i_child];
    if (child_job->GetName() != "chrome")
      continue;

    // Kill Chrome.
    KillChild(child_job, child_pids_[i_child]);

    std::vector<std::string> extra_argument_vector;
    // Create extra argument vector.
    while (*extra_arguments != NULL) {
      extra_argument_vector.push_back(*extra_arguments);
      ++extra_arguments;
    }
    // Add testing channel argument to extra arguments.
    std::string testing_argument = kTestingChannelFlag;
    testing_argument.append(chrome_testing_path_);
    extra_argument_vector.push_back(testing_argument);
    // Add extra arguments to Chrome.
    child_job->SetExtraArguments(extra_argument_vector);

    // Run Chrome.
    child_pids_[i_child] = RunChild(child_job);
    return TRUE;
  }

  return FALSE;
}

gboolean SessionManagerService::StartSession(gchar* email_address,
                                             gchar* unique_identifier,
                                             gboolean* OUT_done,
                                             GError** error) {
  if (session_started_) {
    const char msg[] = "Can't start session while session is already active.";
    LOG(ERROR) << msg;
    system_->SetGError(error, CHROMEOS_LOGIN_ERROR_SESSION_EXISTS, msg);
    return *OUT_done = FALSE;
  }
  if (!ValidateAndCacheUserEmail(email_address, error)) {
    *OUT_done = FALSE;
    return FALSE;
  }

  // If the current user is the owner, and isn't whitelisted or set
  // as the cros.device.owner pref, then do so.
  bool can_access_key = CurrentUserHasOwnerKey(key_->public_key_der(), error);
  if (can_access_key) {
    policy_->StoreOwnerProperties(key_.get(), current_user_, NULL);
  }
  // Now, the flip side...if we believe the current user to be the owner
  // based on the cros.owner.device setting, and he DOESN'T have the private
  // half of the public key, we must mitigate.
  bool user_is_owner = policy_->CurrentUserIsOwner(current_user_);
  if (user_is_owner && !can_access_key) {
    if (!(*OUT_done = mitigator_->Mitigate(key_.get())))
      return FALSE;
  }

  // Send each user login event to UMA (right before we start session
  // since the metrics library does not log events in guest mode).
  int dev_mode = system_->IsDevMode();
  if (dev_mode > -1) {
    LoginMetrics login_metrics;
    login_metrics.SendLoginUserType(dev_mode,
                                    current_user_ == kIncognitoUser,
                                    user_is_owner);
  }
  *OUT_done =
      upstart_signal_emitter_->EmitSignal(
          "start-user-session",
          StringPrintf("CHROMEOS_USER=%s", current_user_.c_str()),
          error);

  if (*OUT_done) {
    for (size_t i_child = 0; i_child < child_jobs_.size(); ++i_child) {
      ChildJobInterface* child_job = child_jobs_[i_child];
      child_job->StartSession(current_user_);
    }
    session_started_ = true;
    DLOG(INFO) << "emitting D-Bus signal SessionStateChanged:started";
    if (signals_[kSignalSessionStateChanged]) {
      g_signal_emit(session_manager_,
                    signals_[kSignalSessionStateChanged],
                    0, "started", current_user_.c_str());
    }
    if (key_->HaveCheckedDisk() && !key_->IsPopulated() &&
        current_user_ != kIncognitoUser) {
      gen_->Start(set_uid_ ? uid_ : 0, key_.get(), this);
    }
  }

  return *OUT_done;
}

void SessionManagerService::HandleKeygenExit(GPid pid,
                                             gint status,
                                             gpointer data) {
  SessionManagerService* manager = static_cast<SessionManagerService*>(data);
  int i_child = manager->FindChildByPid(pid);
  manager->child_pids_[i_child] = -1;
  delete *(manager->child_jobs_.erase(manager->child_jobs_.begin() + i_child));

  if (WIFEXITED(status) && WEXITSTATUS(status) == 0) {
    std::string key;
    file_util::ReadFileToString(
        FilePath(file_util::GetHomeDir().AppendASCII(
            KeyGenerator::kTemporaryKeyFilename)),
        &key);
    manager->ValidateAndStoreOwnerKey(key);
  } else {
    if (WIFSIGNALED(status))
      LOG(ERROR) << "keygen exited on signal " << WTERMSIG(status);
    else
      LOG(ERROR) << "keygen exited with exit code " << WEXITSTATUS(status);
  }
}

void SessionManagerService::ValidateAndStoreOwnerKey(const std::string& buf) {
  std::vector<uint8> pub_key;
  NssUtil::BlobFromBuffer(buf, &pub_key);

  if (!CurrentUserHasOwnerKey(pub_key, NULL)) {
    SendSignal(chromium::kOwnerKeySetSignal, false);
    return;
  }

  // If we're not mitigating a key loss, we should be able to populate |key_|.
  // If we're mitigating a key loss, we should be able to clobber |key_|.
  if ((!mitigator_->Mitigating() && !key_->PopulateFromBuffer(pub_key)) ||
      (mitigator_->Mitigating() && !key_->ClobberCompromisedKey(pub_key))) {
    SendSignal(chromium::kOwnerKeySetSignal, false);
    return;
  }
  io_thread_.message_loop()->PostTask(
      FROM_HERE, NewRunnableMethod(this, &SessionManagerService::PersistKey));
  if (policy_->StoreOwnerProperties(key_.get(), current_user_, NULL)) {
    io_thread_.message_loop()->PostTask(
        FROM_HERE,
        NewRunnableMethod(this, &SessionManagerService::PersistPolicy));
  } else {
    LOG(WARNING) << "Could not immediately store owner properties in policy";
  }
}

gboolean SessionManagerService::StopSession(gchar* unique_identifier,
                                            gboolean* OUT_done,
                                            GError** error) {
  // Most calls to StopSession() will log the reason for the call.
  // If you don't see a log message saying the reason for the call, it is
  // likely a DBUS message. See interface.cc for that call.
  LOG(INFO) << "SessionManagerService StopSession";
  g_idle_add_full(G_PRIORITY_DEFAULT_IDLE,
                  ServiceShutdown,
                  this,
                  NULL);
  DeregisterChildWatchers();
  // TODO(cmasone): re-enable these when we try to enable logout without exiting
  //                the session manager
  // child_job_->StopSession();
  // session_started_ = false;
  return *OUT_done = TRUE;
}

gboolean SessionManagerService::SetOwnerKey(GArray* public_key_der,
                                            GError** error) {
  const char msg[] = "The session_manager now sets the Owner's public key.";
  LOG(ERROR) << msg;
  system_->SetGError(error, CHROMEOS_LOGIN_ERROR_ILLEGAL_PUBKEY, msg);
  // Just to be safe, send back a nACK in addition to returning an error.
  SendSignal(chromium::kOwnerKeySetSignal, false);
  return FALSE;
}

void SessionManagerService::SendBooleanReply(DBusGMethodInvocation* context,
                                             bool succeeded) {
  if (context)
    dbus_g_method_return(context, succeeded);
}

gboolean SessionManagerService::StorePolicy(GArray* policy_blob,
                                            DBusGMethodInvocation* context) {
  std::string policy_str(policy_blob->data, policy_blob->len);
  em::PolicyFetchResponse policy;
  if (!policy.ParseFromString(policy_str) ||
      !policy.has_policy_data() ||
      !policy.has_policy_data_signature()) {
    const char msg[] = "Unable to parse policy protobuf.";
    LOG(ERROR) << msg;
    system_->SetAndSendGError(CHROMEOS_LOGIN_ERROR_DECODE_FAIL, context, msg);
    return FALSE;
  }

  // Determine if the policy has pushed a new owner key and, if so, set it.
  if (policy.has_new_public_key() && !key_->Equals(policy.new_public_key())) {
    // The policy contains a new key, and it is different from |key_|.
    std::vector<uint8> der;
    nss_->BlobFromBuffer(policy.new_public_key(), &der);

    if (session_started_) {
      bool rotated = false;
      if (policy.has_new_public_key_signature()) {
        // Graceful key rotation.
        std::vector<uint8> sig;
        nss_->BlobFromBuffer(policy.new_public_key_signature(), &sig);
        rotated = key_->Rotate(der, sig);
      }
      if (!rotated) {
        const char msg[] = "Failed attempted key rotation!";
        LOG(ERROR) << msg;
        system_->SetAndSendGError(CHROMEOS_LOGIN_ERROR_ILLEGAL_PUBKEY,
                                 context,
                                 msg);
        return FALSE;
      }
    } else {
      // Force a new key, regardless of whether we have one or not.
      if (key_->IsPopulated()) {
        key_->ClobberCompromisedKey(der);
        LOG(INFO) << "Clobbered existing key outside of session";
      } else {
        CHECK(key_->PopulateFromBuffer(der));  // Should be unable to fail.
        LOG(INFO) << "Setting key outside of session";
      }
    }
    // If here, need to persit new key to disk.  Already loaded key into memory.
    io_thread_.message_loop()->PostTask(
        FROM_HERE, NewRunnableMethod(this, &SessionManagerService::PersistKey));
  }

  // Validate signature on policy and persist to disk
  const std::string& sig = policy.policy_data_signature();
  SessionManagerService::SigReturnCode verify_result =
      VerifyHelper(policy.policy_data(), sig.c_str(), sig.length());
  if (verify_result == NO_KEY) {
    NOTREACHED() << "Should have set the key earlier in this function!";
    return FALSE;
  } else if (verify_result == SIGNATURE_FAIL) {
    const char msg[] = "Signature could not be verified in StorePolicy.";
    LOG(ERROR) << msg;
    system_->SetAndSendGError(CHROMEOS_LOGIN_ERROR_VERIFY_FAIL, context, msg);
    return FALSE;
  }
  policy_->Set(policy);
  io_thread_.message_loop()->PostTask(
      FROM_HERE, NewRunnableMethod(this,
                                   &SessionManagerService::PersistPolicyReturn,
                                   context));
  return TRUE;
}

gboolean SessionManagerService::RetrievePolicy(GArray** OUT_policy_blob,
                                               GError** error) {
  std::string polstr;
  if (!policy_->SerializeToString(&polstr)) {
    const char msg[] = "Unable to serialize policy protobuf.";
    LOG(ERROR) << msg;
    system_->SetGError(error, CHROMEOS_LOGIN_ERROR_ENCODE_FAIL, msg);
    return FALSE;
  }
  *OUT_policy_blob = g_array_sized_new(FALSE, FALSE, 1, polstr.length());
  if (!*OUT_policy_blob) {
    const char msg[] = "Unable to allocate memory for response.";
    LOG(ERROR) << msg;
    system_->SetGError(error, CHROMEOS_LOGIN_ERROR_DECODE_FAIL, msg);
    return FALSE;
  }
  g_array_append_vals(*OUT_policy_blob, polstr.c_str(), polstr.length());
  return TRUE;
}

gboolean SessionManagerService::RetrieveSessionState(gchar** OUT_state,
                                                     gchar** OUT_user) {
  *OUT_state = g_strdup(session_started_ ? "started" : "stopped");
  *OUT_user = g_strdup(session_started_ && !current_user_.empty() ?
                       current_user_.c_str() : "");
  return TRUE;
}

gboolean SessionManagerService::LockScreen(GError** error) {
  screen_locked_ = TRUE;
  system_->SendSignalToChromium(chromium::kLockScreenSignal, NULL);
  LOG(INFO) << "LockScreen";
  return TRUE;
}

gboolean SessionManagerService::UnlockScreen(GError** error) {
  screen_locked_ = FALSE;
  system_->SendSignalToChromium(chromium::kUnlockScreenSignal, NULL);
  LOG(INFO) << "UnlockScreen";
  return TRUE;
}

gboolean SessionManagerService::RestartJob(gint pid,
                                           gchar* arguments,
                                           gboolean* OUT_done,
                                           GError** error) {
  int child_pid = pid;
  std::vector<int>::iterator child_pid_it =
      std::find(child_pids_.begin(), child_pids_.end(), child_pid);
  size_t child_index = child_pid_it - child_pids_.begin();

  if (child_pid_it == child_pids_.end() ||
      child_jobs_[child_index]->GetName() != "chrome") {
    // If we didn't find the pid, or we don't think that job was chrome...
    *OUT_done = FALSE;
    const char msg[] = "Provided pid is unknown.";
    LOG(ERROR) << msg;
    system_->SetGError(error, CHROMEOS_LOGIN_ERROR_UNKNOWN_PID, msg);
    return FALSE;
  }

  // Waiting for Chrome to shutdown takes too much time.
  // We're killing it immediately hoping that data Chrome uses before
  // logging in is not corrupted.
  // TODO(avayvod): Remove RestartJob when crosbug.com/6924 is fixed.
  KillChild(child_jobs_[child_index], child_pid);

  char arguments_buffer[kMaxArgumentsSize + 1];
  snprintf(arguments_buffer, sizeof(arguments_buffer), "%s", arguments);
  arguments_buffer[kMaxArgumentsSize] = '\0';
  string arguments_string(arguments_buffer);

  child_jobs_[child_index]->SetArguments(arguments_string);
  child_pids_[child_index] = RunChild(child_jobs_[child_index]);

  // To set "logged-in" state for BWSI mode.
  return StartSession(const_cast<gchar*>(kIncognitoUser), NULL,
                      OUT_done, error);
}

gboolean SessionManagerService::RestartEntd(GError** error) {
  LOG(INFO) << "Restarting entd.";
  // Shutdown entd if it is currently running, blocking this thread and
  // method call until it has finished shutting down.
  int stop_status = system("/sbin/initctl stop entd");
  // Stop may have failed, but it may be ok if not already running.  Error
  // messages will go to session manager log.
  LOG_IF(INFO, stop_status != 0)
      << "Could not stop entd, likely was not running.";
  string command = StringPrintf("/sbin/initctl start entd "
                                "CHROMEOS_USER=%s",
                                current_user_.c_str());
  // Start entd with the current user passed in, blocking this thread
  // and method call until it has finished starting.
  bool restarted = (system(command.c_str()) == 0);
  LOG(INFO) << "Restart was " << (restarted ? "" : "not ")
            << "successful.";
  return restarted;
}

///////////////////////////////////////////////////////////////////////////////
// glib event handlers

void SessionManagerService::HandleChildExit(GPid pid,
                                            gint status,
                                            gpointer data) {
  // If I could wait for descendants here, I would.  Instead, I kill them.
  kill(-pid, SIGKILL);

  DLOG(INFO) << "Handling child process exit.";
  if (WIFSIGNALED(status)) {
    DLOG(INFO) << "  Exited with signal " << WTERMSIG(status);
  } else if (WIFEXITED(status)) {
    DLOG(INFO) << "  Exited with exit code " << WEXITSTATUS(status);
    CHECK(WEXITSTATUS(status) != ChildJobInterface::kCantSetUid);
    CHECK(WEXITSTATUS(status) != ChildJobInterface::kCantExec);
  } else {
    DLOG(INFO) << "  Exited...somehow, without an exit code or a signal??";
  }

  // If the child _ever_ exits uncleanly, we want to start it up again.
  SessionManagerService* manager = static_cast<SessionManagerService*>(data);

  // Do nothing if already shutting down.
  if (manager->shutting_down_)
    return;

  ChildJobInterface* child_job = NULL;
  int i_child = manager->FindChildByPid(pid);
  if (i_child >= 0) {
    child_job = manager->child_jobs_[i_child];
    manager->child_pids_[i_child] = -1;
  }

  LOG(ERROR) << StringPrintf(
      "Process %s(%d) exited.",
      child_job ? child_job->GetName().c_str() : "",
      pid);
  if (manager->screen_locked_) {
    LOG(ERROR) << "Screen locked, shutting down",
    ServiceShutdown(data);
    return;
  }

  if (child_job) {
    if (manager->ShouldStopChild(child_job)) {
      LOG(INFO) << "Child stopped, shutting down",
      ServiceShutdown(data);
    } else if (manager->ShouldRunChildren()) {
      // TODO(cmasone): deal with fork failing in RunChild()
      LOG(INFO) << StringPrintf(
          "Running child %s again...", child_job->GetName().data());
      manager->child_pids_[i_child] = manager->RunChild(child_job);
    } else {
      LOG(INFO) << StringPrintf(
          "Should NOT run %s again...", child_job->GetName().data());
      manager->AllowGracefulExit();
    }
  } else {
    LOG(ERROR) << "Couldn't find pid of exiting child: " << pid;
  }
}

gboolean SessionManagerService::HandleKill(GIOChannel* source,
                                           GIOCondition condition,
                                           gpointer data) {
  // We only get called if there's data on the pipe.  If there's data, we're
  // supposed to exit.  So, don't even bother to read it.
  LOG(INFO) << "SessionManagerService - data on pipe, so exiting";
  return ServiceShutdown(data);
}

gboolean SessionManagerService::ServiceShutdown(gpointer data) {
  SessionManagerService* manager = static_cast<SessionManagerService*>(data);
  manager->Shutdown();
  LOG(INFO) << "SessionManagerService exiting";
  return FALSE;  // So that the event source that called this gets removed.
}

void SessionManagerService::PersistKey() {
  LOG(INFO) << "Persisting Owner key to disk.";
  bool what_happened = key_->Persist();
  message_loop_->PostTask(
      FROM_HERE, NewRunnableMethod(this, &SessionManagerService::SendSignal,
                                   chromium::kOwnerKeySetSignal,
                                   what_happened));
}

void SessionManagerService::PersistPolicySync(base::WaitableEvent* event) {
  policy_->Persist();
  LOG(INFO) << "Persisted policy to disk.";
  event->Signal();
}

void SessionManagerService::PersistPolicyReturn(DBusGMethodInvocation* ctxt) {
  LOG(INFO) << "Persisting policy to disk.";
  bool what_happened = policy_->Persist();
  message_loop_->PostTask(
      FROM_HERE, NewRunnableMethod(this,
                                   &SessionManagerService::SendBooleanReply,
                                   ctxt,
                                   what_happened));
}

void SessionManagerService::PersistPolicy() {
  LOG(INFO) << "Persisting policy to disk.";
  bool what_happened = policy_->Persist();
  message_loop_->PostTask(
      FROM_HERE, NewRunnableMethod(this, &SessionManagerService::SendSignal,
                                   chromium::kPropertyChangeCompleteSignal,
                                   what_happened));
}

///////////////////////////////////////////////////////////////////////////////
// Utility Methods

// This can probably be more efficient, if it needs to be.
// static
bool SessionManagerService::ValidateEmail(const string& email_address) {
  if (email_address.find_first_not_of(kLegalCharacters) != string::npos)
    return false;

  size_t at = email_address.find(kEmailSeparator);
  // it has NO @.
  if (at == string::npos)
    return false;

  // it has more than one @.
  if (email_address.find(kEmailSeparator, at+1) != string::npos)
    return false;

  return true;
}

// static
DBusHandlerResult SessionManagerService::FilterMessage(DBusConnection* conn,
                                                       DBusMessage* message,
                                                       void* data) {
  SessionManagerService* service = static_cast<SessionManagerService*>(data);
  if (::dbus_message_is_method_call(message,
                                    service->service_interface(),
                                    kSessionManagerRestartJob)) {
    const char* sender = ::dbus_message_get_sender(message);
    if (!sender) {
      LOG(ERROR) << "Call to RestartJob has no sender";
      return DBUS_HANDLER_RESULT_HANDLED;
    }
    LOG(INFO) << "Received RestartJob from " << sender;
    DBusMessage* get_pid =
        ::dbus_message_new_method_call("org.freedesktop.DBus",
                                       "/org/freedesktop/DBus",
                                       "org.freedesktop.DBus",
                                       "GetConnectionUnixProcessID");
    CHECK(get_pid);
    ::dbus_message_append_args(get_pid,
                               DBUS_TYPE_STRING, &sender,
                               DBUS_TYPE_INVALID);
    DBusMessage* got_pid =
        ::dbus_connection_send_with_reply_and_block(conn, get_pid, -1, NULL);
    ::dbus_message_unref(get_pid);
    if (!got_pid) {
      LOG(ERROR) << "Could not look up sender of RestartJob";
      return DBUS_HANDLER_RESULT_HANDLED;
    }
    uint32 pid;
    if (!::dbus_message_get_args(got_pid, NULL,
                                 DBUS_TYPE_UINT32, &pid,
                                 DBUS_TYPE_INVALID)) {
      ::dbus_message_unref(got_pid);
      LOG(ERROR) << "Could not extract pid of sender of RestartJob";
      return DBUS_HANDLER_RESULT_HANDLED;
    }
    ::dbus_message_unref(got_pid);
    if (!service->IsKnownChild(pid)) {
      LOG(WARNING) << "Sender of RestartJob is no child of mine!";
      return DBUS_HANDLER_RESULT_HANDLED;
    }
  }
  return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
}

void SessionManagerService::SetupHandlers() {
  // I have to ignore SIGUSR1, because Xorg sends it to this process when it's
  // got no clients and is ready for new ones.  If we don't ignore it, we die.
  struct sigaction action;
  memset(&action, 0, sizeof(action));
  action.sa_handler = SIG_IGN;
  CHECK(sigaction(SIGUSR1, &action, NULL) == 0);

  action.sa_handler = SessionManagerService::do_nothing;
  CHECK(sigaction(SIGALRM, &action, NULL) == 0);

  // We need to handle SIGTERM, because that is how many POSIX-based distros ask
  // processes to quit gracefully at shutdown time.
  action.sa_handler = SIGTERMHandler;
  CHECK(sigaction(SIGTERM, &action, NULL) == 0);
  // Also handle SIGINT - when the user terminates the browser via Ctrl+C.
  // If the browser process is being debugged, GDB will catch the SIGINT first.
  action.sa_handler = SIGINTHandler;
  CHECK(sigaction(SIGINT, &action, NULL) == 0);
  // And SIGHUP, for when the terminal disappears. On shutdown, many Linux
  // distros send SIGHUP, SIGTERM, and then SIGKILL.
  action.sa_handler = SIGHUPHandler;
  CHECK(sigaction(SIGHUP, &action, NULL) == 0);
}

gboolean SessionManagerService::CurrentUserHasOwnerKey(
    const std::vector<uint8>& pub_key,
    GError** error) {
  if (!nss_->MightHaveKeys())
    return FALSE;
  if (!nss_->OpenUserDB()) {
    const char msg[] = "Could not open the current user's NSS database.";
    LOG(ERROR) << msg;
    system_->SetGError(error, CHROMEOS_LOGIN_ERROR_NO_USER_NSSDB, msg);
    return FALSE;
  }
  if (!nss_->GetPrivateKey(pub_key)) {
    const char msg[] = "Could not verify that public key belongs to the owner.";
    LOG(WARNING) << msg;
    system_->SetGError(error, CHROMEOS_LOGIN_ERROR_ILLEGAL_PUBKEY, msg);
    return FALSE;
  }
  return TRUE;
}

gboolean SessionManagerService::ValidateAndCacheUserEmail(
    const gchar* email_address,
    GError** error) {
  // basic validity checking; avoid buffer overflows here, and
  // canonicalize the email address a little.
  char email[kMaxEmailSize + 1];
  snprintf(email, sizeof(email), "%s", email_address);
  email[kMaxEmailSize] = '\0';  // Just to be sure.
  string email_string(email);
  if (email_string != kIncognitoUser && !ValidateEmail(email_string)) {
    const char msg[] = "Provided email address is not valid.  ASCII only.";
    LOG(ERROR) << msg;
    system_->SetGError(error, CHROMEOS_LOGIN_ERROR_INVALID_EMAIL, msg);
    return FALSE;
  }
  current_user_ = StringToLowerASCII(email_string);
  return TRUE;
}

int SessionManagerService::FindChildByPid(int pid) {
  for (int i = 0; i < child_pids_.size(); ++i) {
    if (child_pids_[i] == pid)
      return i;
  }
  return -1;
}

void SessionManagerService::CleanupChildren(int timeout) {
  vector<pair<int, uid_t> > pids_to_kill;

  for (size_t i = 0; i < child_pids_.size(); ++i) {
    const int pid = child_pids_[i];
    if (pid < 0)
      continue;

    ChildJobInterface* job = child_jobs_[i];
    if (job->ShouldNeverKill())
      continue;

    const uid_t uid = job->IsDesiredUidSet() ? job->GetDesiredUid() : getuid();
    pids_to_kill.push_back(make_pair(pid, uid));
    system_->kill(pid, uid, (session_started_ ? SIGTERM : SIGKILL));
  }

  for (vector<pair<int, uid_t> >::const_iterator it = pids_to_kill.begin();
       it != pids_to_kill.end(); ++it) {
    const int pid = it->first;
    const uid_t uid = it->second;
    if (!system_->ChildIsGone(pid, timeout))
      system_->kill(pid, uid, SIGABRT);
  }
}

void SessionManagerService::DeregisterChildWatchers() {
  // Remove child exit handlers.
  for (size_t i = 0; i < child_watchers_.size(); ++i)
    g_source_remove(child_watchers_[i]);
  child_watchers_.clear();
}

gboolean SessionManagerService::DeprecatedError(const char* msg,
                                                GError** error) {
  LOG(ERROR) << msg;
  system_->SetGError(error, CHROMEOS_LOGIN_ERROR_UNKNOWN_PROPERTY, msg);
  SendSignal(chromium::kPropertyChangeCompleteSignal, false);
  return FALSE;
}

SessionManagerService::SigReturnCode
SessionManagerService::VerifyHelperArray(const std::string& data, GArray* sig) {
  return VerifyHelper(data, sig->data, sig->len);
}

SessionManagerService::SigReturnCode
SessionManagerService::VerifyHelper(const std::string& data,
                                    const char* sig,
                                    uint32 sig_len) {
  if (!key_->IsPopulated())
    return NO_KEY;
  if (!key_->Verify(reinterpret_cast<const uint8*>(data.c_str()),
                    data.length(),
                    reinterpret_cast<const uint8*>(sig),
                    sig_len)) {
    return SIGNATURE_FAIL;
  }
  return SUCCESS;
}

void SessionManagerService::SendSignal(const char signal_name[],
                                       bool succeeded) {
  system_->SendSignalToChromium(signal_name, succeeded ? "success" : "failure");
}

// static
std::vector<std::vector<std::string> > SessionManagerService::GetArgLists(
    std::vector<std::string> args) {
  std::vector<std::string> arg_list;
  std::vector<std::vector<std::string> > arg_lists;
  for (size_t i_arg = 0; i_arg < args.size(); ++i_arg) {
    if (args[i_arg] == "--") {
      if (arg_list.size()) {
        arg_lists.push_back(arg_list);
        arg_list.clear();
      }
    } else {
      arg_list.push_back(args[i_arg]);
    }
  }
  if (arg_list.size()) {
    arg_lists.push_back(arg_list);
  }
  return arg_lists;
}

}  // namespace login_manager


text:
/** @jsx Yolk.createElement */

const test = require(`tape`)
const Yolk = require(`../../lib/yolk`)

test(`addings and removing props after the initial render`, t => {
  t.plan(1)

  const component =

  const nextComponent =

  const node = document.createElement(`div`)
  Yolk.render(component, node)
  Yolk.render(nextComponent, node)

  t.equal(node.innerHTML, `<div class="some-class"></div>`)
})


text:
package com.squeezer.designpatterns.command;

public class BoldCommand extends UndoableCommand {

    private Document mDocument;
    // Undo management
    private String mPreviousText;

    public BoldCommand(Document doc) {
        this.mDocument = doc;
        mPreviousText = this.mDocument.getText();
    }

    @Override
    public void execute() {
        mDocument.BoldSelection();
    }

    @Override
    public void Undo() {
        mDocument.setText(mPreviousText);
    }

}


text:
population true to size

 * 1.08 million people per pixel


text:
require_relative "jrb-libsvm/version"
require "java"
require_relative "java/libsvm"

module Libsvm
  java_import "libsvm.Parameter"
  java_import "libsvm.Model"
  java_import "libsvm.Problem"
  java_import "libsvm.Node"
  java_import "libsvm.Svm"

  module CoreExtensions
    module Collection
      def to_example
        Node.features(self)
      end
    end
  end
end

require_relative 'jrb-libsvm/parameter'
require_relative 'jrb-libsvm/model'
require_relative 'jrb-libsvm/node'
require_relative 'jrb-libsvm/problem'

class Hash
  include Libsvm::CoreExtensions::Collection
end
class Array
  include Libsvm::CoreExtensions::Collection
end


text:
package com.katla.restaurant.maker.ui;

import android.app.Fragment;
import android.content.Intent;
import android.os.Bundle;
import android.provider.DocumentsContract.Root;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.View.OnClickListener;
import android.widget.CheckBox;
import android.widget.ImageView;
import android.widget.Toast;

import com.katla.restaurant.maker.R;

/**
 * A placeholder fragment containing a simple view.
 */
public  class IntroFragment extends Fragment {
	/**
	 * The fragment argument representing the section number for this
	 * fragment.
	 */
	private static final String ARG_SECTION_NUMBER = "section_number";

	/**
	 * Returns a new instance of this fragment for the given section number.
	 */
	public static IntroFragment newInstance(int sectionNumber) {
		IntroFragment fragment = new IntroFragment();
		Bundle args = new Bundle();
		args.putInt(ARG_SECTION_NUMBER, sectionNumber);
		fragment.setArguments(args);
		return fragment;
	}

	public IntroFragment() {
	}

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		int sectionNumber = this.getArguments().getInt(ARG_SECTION_NUMBER);
		final View rootView;
		switch (sectionNumber){
		case 1:
			rootView = inflater.inflate(R.layout.fragment_intro_1,
					container, false);
			break;
		case 2:
			rootView = inflater.inflate(R.layout.fragment_intro_2,
					container, false);
			break;
		case 3:
			rootView = inflater.inflate(R.layout.fragment_intro_3,
					container, false);
			CheckBox dontShowAgain = (CheckBox) rootView.findViewById(R.id.dont_show_again);
			ImageView doneButton = (ImageView) rootView.findViewById(R.id.done_image);
			doneButton.setOnClickListener(new OnClickListener() {

				@Override
				public void onClick(View arg0) {
					Intent intent = new Intent(getActivity(),WelcomeActivity.class);
					startActivity(intent);

				}
			});
			break;
	    default:
	    	rootView = inflater.inflate(R.layout.fragment_intro_1,
					container, false);
	    	break;
		}

		return rootView;
	}

	@Override
	public void onSaveInstanceState(Bundle outState) {
		// TODO Auto-generated method stub
		super.onSaveInstanceState(outState);
		 outState.putString("DO NOT CRASH", "OK");
	}
}


text:
(function() {
  var testFrames = 100;
  var testStep = 5000;

  function test() {
    var list = document.querySelector('#lt');
    var testStart = Date.now();
    var frames = 0;
    function next() {
      list.$.list.scrollOffset += testStep;
      frames++;
      if (frames < testFrames) {
        requestAnimationFrame(next);
      } else {
        console.log('time/frame: %fms',
           (Date.now() - testStart) / testFrames);
      }
    }
    requestAnimationFrame(next);
  }

  window.test = test;
})();


text:
class AzDesignSource < ActiveRecord::Base

  belongs_to  :az_design
  #has_many    :az_design_sources, :dependent => :destroy

  has_attached_file :source
  belongs_to :owner, :foreign_key => 'owner_id', :class_name => 'AzCompany'

  validates_attachment_size           :source, :in => 1..20.megabytes

  def before_destroy
    puts "#{self.class} #{self.id}"
  end

  def validate
    validate_owner_id
  end

  def validate_owner_id
    if !new_record? && az_design.owner_id != owner_id
      errors.add_to_base("Incorrect owner_id value. Design has '#{az_design.owner_id}', DesignSource has '#{owner_id}'")
    end
  end

  def self.from_az_hash(attributes, design_ids_original_copy, company, local_copy = true)
    design_source = AzDesignSource.new(attributes)
    design_source.copy_of = attributes['id']
    design_source.owner = company
    design_source.az_design_id = design_ids_original_copy[attributes['az_design_id']]
    if local_copy
      original_design_source = AzDesignSource.find(design_source.copy_of)
      if original_design_source == nil
        #raise "Design source not found!"
        return nil
      end

      if !FileTest::exist?(original_design_source.source.path)
        return nil
      end

      design_source.source = original_design_source.source
    end
    return design_source
  end

  def make_copy_design_source(design)
    puts "DESIGN_SOURCE MAKE_COPY new_owner_id = #{design.owner.id}"
    dup = self.clone
    dup.copy_of = self.id
    dup.az_design = design
    dup.owner = design.owner
    dup.save!

    to_path = dup.source.path
    from_path = source.path
    begin
       dir_name = File.dirname(to_path)
        if FileTest::exist?(from_path)
          FileUtils.makedirs(dir_name)
          FileUtils.copy(from_path, to_path)
        end
      #puts "==================================================================="
      dup.save
    rescue
      puts "AzDesignSource make copy ERROR!!!!!!!!!!!!!!!!!"
    end

    return dup
  end

  def get_project_over_block
    if az_design == nil
      return nil
    end
    return az_design.get_project_over_block
  end

  def get_label_for_activity
    return "Исходник дизайна #{az_design.get_label_for_activity}"
  end

end


text:
package com.tictacpaw;

import java.util.Random;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.*;
import android.database.sqlite.SQLiteDatabase;
import android.os.*;
import android.preference.PreferenceManager;
import android.text.InputFilter;
import android.view.*;
import android.view.View.*;
import android.widget.*;

/**
* @author Petroula
*
*/

public class MainActivity extends Activity implements OnClickListener {

	TicTacToeOpenHelper helper;
	SQLiteDatabase db;
	Random rand = new Random();
	Button[][] buttons=new Button[3][3];
	int x, y;
	Button newGame, back;
    TextView level, score, display;
    int count=1;
    Chronometer seconds;
    GestureDetector detector;
    int i, j;
    int[] a = {0, 2};
    int limit;
    String k = "O";
    long timeMillis;
	int timeSeconds;
	Integer level1score;
	Integer level2score;
	Integer level3score;
	String playerName;

	@SuppressWarnings("deprecation")
	@Override
    protected void onCreate(Bundle savedInstanceState) {
    	super.onCreate(savedInstanceState);
    	setContentView(R.layout.activity_main);

	    helper = new TicTacToeOpenHelper(this);

	    /** Dialog Box for the user to enter a name */
	    final AlertDialog alert = new AlertDialog.Builder(this).create();
	    final EditText name = new EditText(this);
	    name.setFilters(new InputFilter[] { new InputFilter.LengthFilter(5) });
		alert.setTitle("Player's Name");
		alert.setMessage("Please enter your name:");
		alert.setIcon(R.drawable.button_pic);
		alert.setView(name);
		alert.setButton("Ok", new DialogInterface.OnClickListener() {
		public void onClick(DialogInterface dialog, int which) {
			playerName=name.getText().toString();

			/** Starts the timer from 0 */
			seconds = (Chronometer) findViewById(R.id.chronometer);
	    	seconds.setBase(SystemClock.elapsedRealtime());
	    	seconds.start();
		 }
		});
		alert.setCanceledOnTouchOutside(false);
		alert.show();
		initializeGame();
    }

	/** Sets up the game */
	public void initializeGame() {
		for (x=0; x<3; x++) {
			for (y=0; y<3; y++) {
				buttons[x][y] = new Button(this);
				buttons[x][y].setOnClickListener(this);
			}
	    }

	    buttons[0][0] = (Button)findViewById(R.id.button1);
    	buttons[0][1] = (Button)findViewById(R.id.button2);
    	buttons[0][2] = (Button)findViewById(R.id.button3);
    	buttons[1][0] = (Button)findViewById(R.id.button4);
    	buttons[1][1] = (Button)findViewById(R.id.button5);
    	buttons[1][2] = (Button)findViewById(R.id.button6);
    	buttons[2][0] = (Button)findViewById(R.id.button7);
    	buttons[2][1] = (Button)findViewById(R.id.button8);
    	buttons[2][2] = (Button)findViewById(R.id.button9);

    	newGame = (Button)findViewById(R.id.newGame);
    	newGame.setOnClickListener(this);
	    back = (Button)findViewById(R.id.back);
	    back.setOnClickListener(this);

	}

	@Override
    public void onClick(View v) {

    	for (x=0; x<3; x++) {
			for (y=0; y<3; y++) {
				if (buttons[x][y].isPressed() && buttons[x][y].isEnabled()) {

					/** Assigns an X to the button pressed */
    		        buttons[x][y].setText("X");
					buttons[x][y].setBackgroundResource(R.drawable.button_pic);
    		        buttons[x][y].setEnabled(false);
                    if(checkWin()==true || checkLose()==true || checkTie()==true) {
                    	checkEnd();
                    } else {
                    	 vsUser();
                    }
                 }
    	     }
         }

    	/** Starts a new game */
    	if (v.getId()==R.id.newGame) {
    		newGame();

      } else if (v.getId()==R.id.back) {

    	  Intent changeView = new Intent(getApplicationContext(), WelcomeActivity.class);
      	  startActivity(changeView);
      }
    }

    /** Checks for 2-in-a-row */
    public boolean checkChain() {

    	if( (buttons[0][0].getText()==k && buttons[0][1].getText()==k && buttons[0][2].isEnabled())
    	||

    	(buttons[0][0].getText()==k && buttons[0][2].getText()==k && buttons[0][1].isEnabled())

    	||
    	(buttons[0][1].getText()==k && buttons[0][2].getText()==k && buttons[0][0].isEnabled())

        ||
        (buttons[0][0].getText()==k && buttons[1][0].getText()==k && buttons[2][0].isEnabled())

        ||
    	(buttons[0][0].getText()==k && buttons[2][0].getText()==k && buttons[1][0].isEnabled())

    	||
    	(buttons[1][0].getText()==k && buttons[2][0].getText()==k && buttons[0][0].isEnabled())

    	||
    	(buttons[2][2].getText()==k && buttons[2][1].getText()==k && buttons[2][0].isEnabled())

    	||
        (buttons[2][2].getText()==k && buttons[2][0].getText()==k && buttons[2][1].isEnabled())

        ||
    	(buttons[2][0].getText()==k && buttons[2][1].getText()==k && buttons[2][2].isEnabled())

    	||
    	(buttons[2][2].getText()==k && buttons[1][2].getText()==k && buttons[0][2].isEnabled())

    	||
    	(buttons[2][2].getText()==k && buttons[0][2].getText()==k && buttons[1][2].isEnabled())

    	||
    	(buttons[0][2].getText()==k && buttons[1][2].getText()==k && buttons[2][2].isEnabled())

    	||
    	(buttons[0][0].getText()==k && buttons[1][1].getText()==k && buttons[2][2].isEnabled())

    	||
    	(buttons[0][0].getText()==k && buttons[2][2].getText()==k && buttons[1][1].isEnabled())

    	||
    	(buttons[1][1].getText()==k && buttons[2][2].getText()==k && buttons[0][0].isEnabled())

    	||
    	(buttons[2][0].getText()==k && buttons[1][1].getText()==k && buttons[0][2].isEnabled())

    	||
    	(buttons[2][0].getText()==k && buttons[0][2].getText()==k && buttons[1][1].isEnabled())

    	||
    	(buttons[1][1].getText()==k && buttons[0][2].getText()==k && buttons[2][0].isEnabled())

    	||
    	(buttons[1][0].getText()==k && buttons[1][1].getText()==k && buttons[1][2].isEnabled())

    	||
    	(buttons[1][0].getText()==k && buttons[1][2].getText()==k && buttons[1][1].isEnabled())

    	||
    	(buttons[1][1].getText()==k && buttons[1][2].getText()==k && buttons[1][0].isEnabled())

    	||
    	(buttons[0][1].getText()==k && buttons[1][1].getText()==k && buttons[2][1].isEnabled())

    	||
    	(buttons[0][1].getText()==k && buttons[2][1].getText()==k && buttons[1][1].isEnabled())

    	||
    	(buttons[1][1].getText()==k && buttons[2][1].getText()==k && buttons[0][1].isEnabled())) {

    		return true;
    	}
		return false;

    }

    /** Strategic move */
    public void AImove() {

    	if(buttons[0][0].getText()==k && buttons[0][1].getText()==k && buttons[0][2].isEnabled()) {
    		buttons[0][2].setText("O");
    		buttons[0][2].setBackgroundResource(R.drawable.button_pic_white);
    		buttons[0][2].setEnabled(false);
    	} else if (buttons[0][0].getText()==k && buttons[0][2].getText()==k && buttons[0][1].isEnabled()) {
    		buttons[0][1].setText("O");
    		buttons[0][1].setBackgroundResource(R.drawable.button_pic_white);
    		buttons[0][1].setEnabled(false);
    	} else if (buttons[0][1].getText()==k && buttons[0][2].getText()==k && buttons[0][0].isEnabled()) {
    		buttons[0][0].setText("O");
    		buttons[0][0].setBackgroundResource(R.drawable.button_pic_white);
    		buttons[0][0].setEnabled(false);
    	} else if (buttons[0][0].getText()==k && buttons[1][0].getText()==k && buttons[2][0].isEnabled()) {
    		buttons[2][0].setText("O");
    		buttons[2][0].setBackgroundResource(R.drawable.button_pic_white);
    		buttons[2][0].setEnabled(false);
    	} else if (buttons[0][0].getText()==k && buttons[2][0].getText()==k && buttons[1][0].isEnabled()) {
    		buttons[1][0].setText("O");
    		buttons[1][0].setBackgroundResource(R.drawable.button_pic_white);
    		buttons[1][0].setEnabled(false);
    	} else if (buttons[1][0].getText()==k && buttons[2][0].getText()==k && buttons[0][0].isEnabled()) {
    		buttons[0][0].setText("O");
    		buttons[0][0].setBackgroundResource(R.drawable.button_pic_white);
    		buttons[0][0].setEnabled(false);
    	} else if (buttons[2][2].getText()==k && buttons[2][1].getText()==k && buttons[2][0].isEnabled()) {
    		buttons[2][0].setText("O");
    		buttons[2][0].setBackgroundResource(R.drawable.button_pic_white);
    		buttons[2][0].setEnabled(false);
    	} else if (buttons[2][2].getText()==k && buttons[2][0].getText()==k && buttons[2][1].isEnabled()) {
    		buttons[2][1].setText("O");
    		buttons[2][1].setBackgroundResource(R.drawable.button_pic_white);
    		buttons[2][1].setEnabled(false);
    	} else if (buttons[2][0].getText()==k && buttons[2][1].getText()==k && buttons[2][2].isEnabled()) {
    		buttons[2][2].setText("O");
    		buttons[2][2].setBackgroundResource(R.drawable.button_pic_white);
    		buttons[2][2].setEnabled(false);
    	} else if (buttons[2][2].getText()==k && buttons[1][2].getText()==k && buttons[0][2].isEnabled()) {
    		buttons[0][2].setText("O");
    		buttons[0][2].setBackgroundResource(R.drawable.button_pic_white);
    		buttons[0][2].setEnabled(false);
    	} else if (buttons[2][2].getText()==k && buttons[0][2].getText()==k && buttons[1][2].isEnabled()) {
    		buttons[1][2].setText("O");
    		buttons[1][2].setBackgroundResource(R.drawable.button_pic_white);
    		buttons[1][2].setEnabled(false);
    	} else if (buttons[0][2].getText()==k && buttons[1][2].getText()==k && buttons[2][2].isEnabled()) {
    		buttons[2][2].setText("O");
    		buttons[2][2].setBackgroundResource(R.drawable.button_pic_white);
    		buttons[2][2].setEnabled(false);
    	} else if (buttons[0][0].getText()==k && buttons[1][1].getText()==k && buttons[2][2].isEnabled()) {
    		buttons[2][2].setText("O");
    		buttons[2][2].setBackgroundResource(R.drawable.button_pic_white);
    		buttons[2][2].setEnabled(false);
    	} else if (buttons[0][0].getText()==k && buttons[2][2].getText()==k && buttons[1][1].isEnabled()) {
    		buttons[1][1].setText("O");
    		buttons[1][1].setBackgroundResource(R.drawable.button_pic_white);
    		buttons[1][1].setEnabled(false);
    	} else if (buttons[1][1].getText()==k && buttons[2][2].getText()==k && buttons[0][0].isEnabled()) {
    		buttons[0][0].setText("O");
    		buttons[0][0].setBackgroundResource(R.drawable.button_pic_white);
    		buttons[0][0].setEnabled(false);
    	} else if (buttons[2][0].getText()==k && buttons[1][1].getText()==k && buttons[0][2].isEnabled()) {
    		buttons[0][2].setText("O");
    		buttons[0][2].setBackgroundResource(R.drawable.button_pic_white);
    		buttons[0][2].setEnabled(false);
    	} else if (buttons[2][0].getText()==k && buttons[0][2].getText()==k && buttons[1][1].isEnabled()) {
    		buttons[1][1].setText("O");
    		buttons[1][1].setBackgroundResource(R.drawable.button_pic_white);
    		buttons[1][1].setEnabled(false);
    	} else if (buttons[1][1].getText()==k && buttons[0][2].getText()==k && buttons[2][0].isEnabled()) {
    		buttons[2][0].setText("O");
    		buttons[2][0].setBackgroundResource(R.drawable.button_pic_white);
    		buttons[2][0].setEnabled(false);
    	} else if (buttons[1][0].getText()==k && buttons[1][1].getText()==k && buttons[1][2].isEnabled()) {
    		buttons[1][2].setText("O");
    		buttons[1][2].setBackgroundResource(R.drawable.button_pic_white);
    		buttons[1][2].setEnabled(false);
    	} else if (buttons[1][0].getText()==k && buttons[1][2].getText()==k && buttons[1][1].isEnabled()) {
    		buttons[1][1].setText("O");
    		buttons[1][1].setBackgroundResource(R.drawable.button_pic_white);
    		buttons[1][1].setEnabled(false);
    	} else if (buttons[1][1].getText()==k && buttons[1][2].getText()==k && buttons[1][0].isEnabled()) {
    		buttons[1][0].setText("O");
    		buttons[1][0].setBackgroundResource(R.drawable.button_pic_white);
    		buttons[1][0].setEnabled(false);
    	} else if (buttons[0][1].getText()==k && buttons[1][1].getText()==k && buttons[2][1].isEnabled()) {
    		buttons[2][1].setText("O");
    		buttons[2][1].setBackgroundResource(R.drawable.button_pic_white);
    		buttons[2][1].setEnabled(false);
    	} else if (buttons[0][1].getText()==k && buttons[2][1].getText()==k && buttons[1][1].isEnabled()) {
    		buttons[1][1].setText("O");
    		buttons[1][1].setBackgroundResource(R.drawable.button_pic_white);
    		buttons[1][1].setEnabled(false);
    	} else if (buttons[1][1].getText()==k && buttons[2][1].getText()==k && buttons[0][1].isEnabled()) {
    		buttons[0][1].setText("O");
    		buttons[0][1].setBackgroundResource(R.drawable.button_pic_white);
    		buttons[0][1].setEnabled(false);
    	}
    }

    public void randomMove() {

    	i = rand.nextInt(3);
		j = rand.nextInt(3);
		if (buttons[i][j].isEnabled() ) {
			buttons[i][j].setText("O");
			buttons[i][j].setBackgroundResource(R.drawable.button_pic_white);
			buttons[i][j].setEnabled(false);
		} else {
			randomMove();
		}
    }

    public void randomCorner() {

    	i = a[rand.nextInt(a.length)];
	    j = a[rand.nextInt(a.length)];
	    if (buttons[i][j].isEnabled()) {
	    	buttons[i][j].setText("O");
	    	buttons[i][j].setBackgroundResource(R.drawable.button_pic_white);
	    	buttons[i][j].setEnabled(false);
	    } else {
	    	randomCorner();
	    }
    }

    public boolean checkCorner() {
    	if (buttons[0][0].isEnabled() || buttons[0][2].isEnabled() ||
    			buttons[2][0].isEnabled() || buttons[2][2].isEnabled()) {
    		return true;
    	}
    	return false;
    }

    /** This method handles the computer's strategy */
    public void vsUser() {

    	/** Chooses randomly where to assign an O, when at level 1 */
    	if (count==1) {
    		randomMove();

    	/** Uses a strategy for assigning O's, when at level 2 and 3 */
    	} else if (count==2 || count==3) {
    		if (buttons[1][1].isEnabled()) {
    			buttons[1][1].setText("O");
    			buttons[1][1].setBackgroundResource(R.drawable.button_pic_white);
    			buttons[1][1].setEnabled(false);
    		} else if (!buttons[1][1].isEnabled() && checkChain()==false) {
    			k="X";
    			if (checkChain() == true) {
    				/** Aims at blocking opponent's 2 in a row */
    				AImove();
    				k="O";
    			} else if (checkChain() == false && checkCorner() == true){
    				randomCorner();
    			} else if (checkChain() == false && checkCorner() == false){
    				randomMove();
    			}
    		} else if (!buttons[1][1].isEnabled() && checkChain()==true) {
    			/** Aims at creating 3 in a row */
    			AImove();
    		}
    	}
        checkEnd();
     }

    /** Checks for win, lose or tie situation */
    @SuppressWarnings("deprecation")
	public void checkEnd() {

    	score = (TextView) findViewById(R.id.score);

    	/** Checks which box was selected and adjusts the limit */
    	Intent changeView = getIntent();
    	if(changeView.getStringExtra("mode").contains("easy")) {
    		limit = 10;
    	} else if (changeView.getStringExtra("mode").contains("medium")) {
    		limit = 7;
    	} else if (changeView.getStringExtra("mode").contains("hard")) {
    		limit = 5;
    	}

        if (checkWin()==true) {
        	endGame();
        	seconds.stop();

        	timeMillis = SystemClock.elapsedRealtime() - seconds.getBase();

        	/** Counts the seconds it took to win the game */
        	timeSeconds = (int) (timeMillis / 1000);

        	/** Adds the score to the database */
                helper.addScore(playerName, count, timeSeconds);

        	/** Stores the quickest paw after comparing with the current one */
        	if(!score.getText().toString().isEmpty()) {
        		SharedPreferences shared = PreferenceManager.getDefaultSharedPreferences(this);
            	if(timeSeconds<shared.getInt("Quickest Paw", timeSeconds)){
            		SharedPreferences.Editor sharedEditor = shared.edit();
                    sharedEditor.putFloat("Quickest Paw", timeSeconds);
                    sharedEditor.commit();
                    score.setText("The Quickest Paw is approximately: "
                    + Integer.toString(timeSeconds) + " seconds");

                 }

            /** Stores the quickest paw for the first time  */
        	} else if (score.getText().toString().isEmpty()) {
        		SharedPreferences shared = PreferenceManager.getDefaultSharedPreferences(this);
        		SharedPreferences.Editor sharedEditor = shared.edit();
                sharedEditor.putInt("Quickest Paw", timeSeconds);
                sharedEditor.commit();
                score.setText("The Quickest Paw is approximately: "
                + Integer.toString(timeSeconds) + " seconds");

        	}

        	/** Wins only if the user's time is under the limit for the current difficulty mode (easy, medium, hard) */
        	if(timeSeconds<limit) {
        		//win
        		final AlertDialog alert = new AlertDialog.Builder(this).create();
        		alert.setTitle("You won!");
        		alert.setMessage("Clicking on the 'New Game' will lead you to next level!");
        		alert.setIcon(R.drawable.button_pic);
        		alert.setButton("Ok", new DialogInterface.OnClickListener() {
        			public void onClick(DialogInterface dialog, int which) {
        				alert.dismiss();
        			}
        			});
        		alert.setCanceledOnTouchOutside(false);
        		alert.show();
        	    count++;
        	} else {
        		//win too slow
        		final AlertDialog alert = new AlertDialog.Builder(this).create();
        		alert.setTitle("Too slow!");
        		alert.setMessage("You won..but you were too slow! You have to try again!");
        		alert.setIcon(R.drawable.button_pic);
        		alert.setButton("Ok", new DialogInterface.OnClickListener() {
        			public void onClick(DialogInterface dialog, int which) {
        				alert.dismiss();
        			}
        			});
        		alert.setCanceledOnTouchOutside(false);
        		alert.show();
            }

            if(count==4 && timeSeconds<limit) {
            	//win all levels
            	final AlertDialog alert = new AlertDialog.Builder(this).create();
            	alert.setTitle("You won!");
        		alert.setMessage("Well done, you won all levels!");
        		alert.setIcon(R.drawable.button_pic);
        		alert.setButton("Ok", new DialogInterface.OnClickListener() {
        			public void onClick(DialogInterface dialog, int which) {
        				alert.dismiss();
        			}
        			});
        		alert.setCanceledOnTouchOutside(false);
        		alert.show();
                count=1;
            }

        } else if (checkLose()==true) {
            endGame();
        	seconds.stop();
        	//lost
        	final AlertDialog alert = new AlertDialog.Builder(this).create();
        	alert.setTitle("You lost!");
    		alert.setMessage("Unfortunately, you lost! Please try again!");
    		alert.setIcon(R.drawable.button_pic);
    		alert.setButton("Ok", new DialogInterface.OnClickListener() {
    			public void onClick(DialogInterface dialog, int which) {
    				alert.dismiss();
    			}
    			});
    		alert.setCanceledOnTouchOutside(false);
    		alert.show();
        } else if (checkTie()==true) {
            endGame();
            seconds.stop();
            //tie
            final AlertDialog alert = new AlertDialog.Builder(this).create();
            alert.setTitle("It's a tie!");
    		alert.setMessage("The game ended in a tie! Next time you may win!");
    		alert.setIcon(R.drawable.button_pic);
    		alert.setButton("Ok", new DialogInterface.OnClickListener() {
    			public void onClick(DialogInterface dialog, int which) {
    				alert.dismiss();
    			}
    			});
    		alert.setCanceledOnTouchOutside(false);
    		alert.show();
        }

    }

    /** Handles the rules for winning the game */
    public boolean checkWin() {

    	if ((buttons[0][0].getText()=="X" && buttons[0][1].getText()=="X" && buttons[0][2].getText()=="X")
				|| (buttons[1][0].getText()=="X" && buttons[1][1].getText()=="X" && buttons[1][2].getText()=="X")
			    || (buttons[2][0].getText()=="X" && buttons[2][1].getText()=="X" && buttons[2][2].getText()=="X")

			    || (buttons[0][0].getText()=="X" && buttons[1][0].getText()=="X" && buttons[2][0].getText()=="X")
			    || (buttons[0][1].getText()=="X" && buttons[1][1].getText()=="X" && buttons[2][1].getText()=="X")
			    || (buttons[0][2].getText()=="X" && buttons[1][2].getText()=="X" && buttons[2][2].getText()=="X")

			    || (buttons[0][0].getText()=="X" && buttons[1][1].getText()=="X" && buttons[2][2].getText()=="X")
			    || (buttons[0][2].getText()=="X" && buttons[1][1].getText()=="X" && buttons[2][0].getText()=="X")) {
    		return true;
    	}
    	return false;
     }

    public boolean checkLose() {

    	if ((buttons[0][0].getText()=="O" && buttons[0][1].getText()=="O" && buttons[0][2].getText()=="O")
				|| (buttons[1][0].getText()=="O" && buttons[1][1].getText()=="O" && buttons[1][2].getText()=="O")
			    || (buttons[2][0].getText()=="O" && buttons[2][1].getText()=="O" && buttons[2][2].getText()=="O")

			    || (buttons[0][0].getText()=="O" && buttons[1][0].getText()=="O" && buttons[2][0].getText()=="O")
			    || (buttons[0][1].getText()=="O" && buttons[1][1].getText()=="O" && buttons[2][1].getText()=="O")
			    || (buttons[0][2].getText()=="O" && buttons[1][2].getText()=="O" && buttons[2][2].getText()=="O")

			    || (buttons[0][0].getText()=="O" && buttons[1][1].getText()=="O" && buttons[2][2].getText()=="O")
			    || (buttons[0][2].getText()=="O" && buttons[1][1].getText()=="O" && buttons[2][0].getText()=="O")) {
    		return true;
    	}
    	return false;
     }

    public boolean checkTie() {
    	if (checkWin()==false && checkLose()==false && (!buttons[0][0].isEnabled() && !buttons[0][1].isEnabled() &&
    			!buttons[0][2].isEnabled() && !buttons[1][0].isEnabled() && !buttons[1][1].isEnabled() && !buttons[1][2].isEnabled()
    			&& !buttons[2][0].isEnabled() && !buttons[2][1].isEnabled() && !buttons[2][2].isEnabled())) {
    		return true;
    	}
		return false;
    }

    public void endGame() {

    	for (x=0; x<3; x++) {
			for (y=0; y<3; y++) {
				buttons[x][y].setEnabled(false);
			}
	    }
    }

    public void newGame() {

    	/** Resets the timer */
    	seconds.setBase(SystemClock.elapsedRealtime());
    	seconds.start();

    	level = (TextView) findViewById(R.id.level);

    	for (x=0; x<3; x++) {
			for (y=0; y<3; y++) {
				buttons[x][y].setEnabled(true);
				buttons[x][y].setText("");
				buttons[x][y].setBackgroundResource(R.drawable.button_pic0);
			}
	    }
    	level.setText("Level " + count);

    	if (count==3) {
    		vsUser();
    	}
    }
}


text:
package ivorius.ivtoolkit.tools;

import net.minecraft.util.ResourceLocation;

import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.nio.file.*;
import java.nio.file.attribute.BasicFileAttributes;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Objects;

/**
 * Created by lukas on 14.10.14.
 */
public class IvPathHelper
{
    public static Path resourceToPath(URL resource) throws IOException, URISyntaxException
    {
        Objects.requireNonNull(resource, "Resource URL cannot be null");
        URI uri = resource.toURI();

        String scheme = uri.getScheme();
        if (scheme.equals("file")) {
            return Paths.get(uri);
        }

        if (!scheme.equals("jar")) {
            throw new IllegalArgumentException("Cannot convert to Path: " + uri);
        }

        String s = uri.toString();
        int separator = s.indexOf("!/");
        String entryName = s.substring(separator + 2);
        URI fileURI = URI.create(s.substring(0, separator));

        try {
            FileSystem fs = FileSystems.getFileSystem(fileURI);
            if (fs.isOpen())
                return fs.getPath(entryName);
        }
        catch (FileSystemNotFoundException ignored) {
        }

        FileSystem fs = FileSystems.newFileSystem(fileURI, Collections.<String, Object>emptyMap());
        return fs.getPath(entryName);
    }

    public static Path pathFromResourceLocation(ResourceLocation resourceLocation) throws URISyntaxException, IOException
    {
        URL resource = IvPathHelper.class.getResource("/assets/" + resourceLocation.getNamespace() + "/" + resourceLocation.getPath());
        return resource != null ? resourceToPath(resource.toURI().toURL()) : null;
    }

    public static List<Path> listFilesRecursively(Path dir, final DirectoryStream.Filter<Path> filter, final boolean recursive) throws IOException
    {
        final List<Path> files = new ArrayList<>();
        Files.walkFileTree(dir, new SimpleFileVisitor<Path>()
        {
            @Override
            public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException
            {
                if (filter.accept(file))
                    files.add(file);

                return recursive ? FileVisitResult.CONTINUE : FileVisitResult.SKIP_SUBTREE;
            }
        });
        return files;
    }
}


text:
package org.onosproject.evpnrouteservice;

import java.util.Objects;

import org.onlab.packet.IpPrefix;
import org.onlab.packet.MacAddress;

import static com.google.common.base.MoreObjects.toStringHelper;
import static com.google.common.base.Preconditions.checkNotNull;

/**
 * Represents a evpn prefix.
 */
public final class EvpnPrefix {

    private final RouteDistinguisher rd;
    private final MacAddress macAddress;
    private final IpPrefix ipAddress;

    /**
     * Constructor to initialize the parameters.
     *
     * @param rd         route distinguisher
     * @param macAddress mac address
     * @param ipAddress  IP address
     */
    public EvpnPrefix(RouteDistinguisher rd, MacAddress macAddress,
                      IpPrefix ipAddress) {
        checkNotNull(rd);
        checkNotNull(macAddress);
        checkNotNull(ipAddress);
        this.rd = rd;
        this.macAddress = macAddress;
        this.ipAddress = ipAddress;
    }

    /**
     * Creates the evpn prefix by given parameters.
     *
     * @param rd         route distinguisher
     * @param macAddress mac address
     * @param ipAddress  ip address
     * @return EvpnPrefix
     */
    public static EvpnPrefix evpnPrefix(RouteDistinguisher rd,
                                        MacAddress macAddress,
                                        IpPrefix ipAddress) {
        return new EvpnPrefix(rd, macAddress, ipAddress);
    }

    /**
     * Returns the route distinguisher.
     *
     * @return RouteDistinguisher
     */
    public RouteDistinguisher routeDistinguisher() {
        return rd;
    }

    /**
     * Returns the mac address.
     *
     * @return MacAddress
     */
    public MacAddress macAddress() {
        return macAddress;
    }

    /**
     * Returns the IP address.
     *
     * @return Ip4Address
     */
    public IpPrefix ipAddress() {
        return ipAddress;
    }

    @Override
    public int hashCode() {
        return Objects.hash(rd, macAddress, ipAddress);
    }

    @Override
    public boolean equals(Object other) {
        if (this == other) {
            return true;
        }

        if (!(other instanceof EvpnPrefix)) {
            return false;
        }

        EvpnPrefix that = (EvpnPrefix) other;

        return Objects.equals(this.macAddress(), that.macAddress())
                && Objects.equals(this.ipAddress, that.ipAddress)
                && Objects.equals(this.rd, that.rd);
    }

    @Override
    public String toString() {
        return toStringHelper(this).add("macAddress", this.macAddress())
                .add("ipAddress", this.ipAddress()).add("rd", this.rd)
                .toString();
    }
}