text:
namespace ash {
namespace printing {
namespace oauth2 {

namespace {

constexpr size_t kLengthOfCodeVerifier = 64;
constexpr size_t kLengthOfState = 16;

// Returns random string in Base64 format.
// `length` must be divisible by 4.
template <size_t length>
std::string RandBase64String() {
  static_assert(length % 4 == 0);
  static_assert(length > 3);
  std::vector<uint8_t> bytes(length * 3 / 4);
  crypto::RandBytes(bytes);
  return base::Base64Encode(bytes);
}

// The code challenge created with the algorithm S256 (see RFC7636-4.2).
// RFC7636-4.1 specifies the requirements for `code_verifier`:
// "code_verifier = high-entropy cryptographic random STRING using the
// unreserved characters [A-Z] / [a-z] / [0-9] / "-" / "." / "_" / "~"
// from Section 2.3 of [RFC3986], with a minimum length of 43 characters
// and a maximum length of 128 characters."
std::string CodeChallengeS256(const std::string& code_verifier) {
  DCHECK_GE(code_verifier.size(), 43u);
  DCHECK_LE(code_verifier.size(), 128u);
  std::string output;
  base::Base64Encode(crypto::SHA256HashString(code_verifier), &output);
  return output;
}

// Builds and returns URL for Authorization Request (see RFC6749-4.1) with
// a code challenge (see RFC7636-4).
std::string GetAuthorizationURL(const AuthorizationServerData& server_data,
                                const base::flat_set<std::string>& scope,
                                const std::string& state,
                                const std::string& code_verifier) {
  chromeos::Uri uri(server_data.AuthorizationEndpointURI().spec());
  auto query = uri.GetQuery();
  query.push_back(std::make_pair("response_type", "code"));
  query.push_back(std::make_pair("response_mode", "query"));
  query.push_back(std::make_pair("client_id", server_data.ClientId()));
  query.push_back(std::make_pair("redirect_uri", kRedirectURI));
  if (!scope.empty()) {
    std::vector<std::string> parts(scope.begin(), scope.end());
    query.push_back(std::make_pair("scope", base::JoinString(parts, " ")));
  }
  query.push_back(std::make_pair("state", state));
  query.push_back(
      std::make_pair("code_challenge", CodeChallengeS256(code_verifier)));
  query.push_back(std::make_pair("code_challenge_method", "S256"));
  uri.SetQuery(query);
  return uri.GetNormalized(false);
}

// Tries to extract the parameter `name` from `query`. Returns the value of
// extracted parameter or an error message. `query` cannot contain empty
// vectors, but the vectors may contain empty strings.
base::expected<std::string, std::string> ExtractParameter(
    const base::flat_map<std::string, std::vector<std::string>>& query,
    const std::string& name) {
  auto it = query.find(name);
  if (it == query.end()) {
    return base::unexpected(
        base::StrCat({"parameter '", name, "' is missing"}));
  }
  if (it->second.size() != 1) {
    return base::unexpected(
        base::StrCat({"parameter '", name, "' is duplicated"}));
  }
  std::string value = it->second.front();
  if (value.empty()) {
    return base::unexpected(base::StrCat({"parameter '", name, "' is empty"}));
  }
  return base::ok(std::move(value));
}

// Calls `callback` with `status` and `data` as parameters. When `status` equals
// StatusCode::kOK, ignores `data` and passes an empty string instead.
void NoDataForOK(StatusCallback callback, StatusCode status, std::string data) {
  std::move(callback).Run(status,
                          (status == StatusCode::kOK) ? "" : std::move(data));
}

}  // namespace

AuthorizationZoneImpl::WaitingAuthorization::WaitingAuthorization(
    base::flat_set<std::string>&& scopes,
    StatusCallback callback)
    : scopes(scopes), callback(std::move(callback)) {}
AuthorizationZoneImpl::WaitingAuthorization::~WaitingAuthorization() = default;

AuthorizationZoneImpl::PendingAuthorization::PendingAuthorization(
    base::flat_set<std::string>&& scopes,
    std::string&& state,
    std::string&& code_verifier)
    : scopes(scopes), state(state), code_verifier(code_verifier) {}
AuthorizationZoneImpl::PendingAuthorization::~PendingAuthorization() = default;

AuthorizationZoneImpl::AuthorizationZoneImpl(
    scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory,
    const GURL& authorization_server_uri,
    ClientIdsDatabase* client_ids_database)
    : server_data_(url_loader_factory,
                   authorization_server_uri,
                   client_ids_database),
      url_loader_factory_(url_loader_factory) {}

AuthorizationZoneImpl::~AuthorizationZoneImpl() = default;

void AuthorizationZoneImpl::InitAuthorization(const std::string& scope,
                                              StatusCallback callback) {
  DCHECK_LE(waiting_authorizations_.size(), kMaxNumberOfSessions);

  // If there are too many callbacks waiting, remove the oldest one.
  if (waiting_authorizations_.size() == kMaxNumberOfSessions) {
    std::move(waiting_authorizations_.front().callback)
        .Run(StatusCode::kTooManySessions,
             "Authorization Zone not initialized");
    waiting_authorizations_.pop_front();
  }

  // Add the callback to the waiting list.
  waiting_authorizations_.emplace_back(ParseScope(scope), std::move(callback));
  if (waiting_authorizations_.size() == 1) {
    // The list was empty and it is the first element.
    // Check if the server is ready.
    if (server_data_.IsReady()) {
      // The server is ready. Just go ahead and process the element.
      AuthorizationProcedure();
    } else {
      // The server must be initialized (it is the very first call to
      // InitAuthorization()). AuthorizationProcedure() will be called inside
      // OnInitializeCallback().
      // We can use base::Unretained() here because:
      // * AuthorizationServerData (and HttpExchange) guarantees that no calls
      //   will be returned after deletion of the object `server_data_`.
      // * `this` owns `server_data_`; it is guaranteed that deletion of
      //   `server_data_` is performed before deletion of `this`.
      server_data_.Initialize(
          base::BindOnce(&AuthorizationZoneImpl::OnInitializeCallback,
                         base::Unretained(this)));
    }
  }
}

void AuthorizationZoneImpl::FinishAuthorization(const GURL& redirect_url,
                                                StatusCallback callback) {
  // Parse the URL and retrieve the query segment.
  chromeos::Uri uri(redirect_url.spec());
  if (uri.GetLastParsingError().status !=
      chromeos::Uri::ParserStatus::kNoErrors) {
    std::move(callback).Run(StatusCode::kInvalidResponse,
                            "Authorization Request: cannot parse obtained URL");
    return;
  }
  const auto query = uri.GetQueryAsMap();

  // Extract the parameter "state".
  base::expected<std::string, std::string> val_or_err =
      ExtractParameter(query, "state");
  if (!val_or_err.has_value()) {
    std::move(callback).Run(
        StatusCode::kInvalidResponse,
        base::StrCat({"Authorization Request: ", val_or_err.error()}));
    return;
  }
  const std::string state = std::move(val_or_err.value());

  // Use `state` to match pending authorization.
  base::flat_set<std::string> scopes;
  std::string code_verifier;
  if (!FindAndRemovePendingAuthorization(state, scopes, code_verifier)) {
    std::move(callback).Run(StatusCode::kNoMatchingSession,
                            "Authorization Request");
    return;
  }

  // Check if the parameter "error" is present. If yes, try to extract the error
  // message.
  if (query.contains("error")) {
    val_or_err = ExtractParameter(query, "error");
    if (!val_or_err.has_value()) {
      std::move(callback).Run(
          StatusCode::kInvalidResponse,
          base::StrCat({"Authorization Request: ", val_or_err.error()}));
      return;
    }
    const std::string error = std::move(val_or_err.value());

    StatusCode status;
    if (error == "server_error") {
      status = StatusCode::kServerError;
    } else if (error == "temporarily_unavailable") {
      status = StatusCode::kServerTemporarilyUnavailable;
    } else {
      status = StatusCode::kAccessDenied;
    }
    std::move(callback).Run(
        status, base::StrCat({"Authorization Request: error=", error}));
    return;
  }

  // Extract the parameter "code".
  val_or_err = ExtractParameter(query, "code");
  if (!val_or_err.has_value()) {
    std::move(callback).Run(
        StatusCode::kInvalidResponse,
        base::StrCat({"Authorization Request: ", val_or_err.error()}));
    return;
  }
  const std::string code = std::move(val_or_err.value());

  // Create and add a new session.
  if (sessions_.size() == kMaxNumberOfSessions) {
    // There are too many sessions. Remove the oldest one.
    auto sessions_callbacks = sessions_.front()->TakeWaitingList();
    sessions_.pop_front();
    for (auto& sessions_callback : sessions_callbacks) {
      std::move(sessions_callback)
          .Run(StatusCode::kTooManySessions, "The oldest session was closed");
    }
    // TODO(b:228876367) - revoke the token in AuthorizationServerSession
  }
  sessions_.push_back(std::make_unique<AuthorizationServerSession>(
      url_loader_factory_, server_data_.TokenEndpointURI(), std::move(scopes)));
  AuthorizationServerSession* session = sessions_.back().get();
  session->AddToWaitingList(base::BindOnce(&NoDataForOK, std::move(callback)));
  // We can use base::Unretained() here because:
  // * AuthorizationServerSession (and HttpExchange) guarantees that no calls
  //   will be returned after deletion of the object `session`.
  // * `this` owns `session`; it is guaranteed that deletion of `session` is
  //   performed before deletion of `this`.
  session->SendFirstTokenRequest(
      server_data_.ClientId(), code, code_verifier,
      base::BindOnce(&AuthorizationZoneImpl::OnSendTokenRequestCallback,
                     base::Unretained(this), base::Unretained(session)));
}

void AuthorizationZoneImpl::GetEndpointAccessToken(
    const chromeos::Uri& ipp_endpoint,
    const std::string& scope,
    StatusCallback callback) {
  // Try to find the IPP Endpoint.
  auto it = ipp_endpoints_.find(ipp_endpoint);

  if (it == ipp_endpoints_.end()) {
    // IPP Endpoint is not known. Create a new IppEndpointFetcher.
    auto ptr = std::make_unique<IppEndpointTokenFetcher>(
        url_loader_factory_, server_data_.TokenEndpointURI(), ipp_endpoint,
        ParseScope(scope));
    IppEndpointTokenFetcher* endpoint = ptr.get();
    it = ipp_endpoints_.emplace(ipp_endpoint, std::move(ptr)).first;
    endpoint->AddToWaitingList(std::move(callback));
    AttemptTokenExchange(endpoint);
    return;
  }

  IppEndpointTokenFetcher* endpoint = it->second.get();
  if (endpoint->endpoint_access_token().empty()) {
    // Endpoint Access Token is not ready yet.
    endpoint->AddToWaitingList(std::move(callback));
    return;
  }

  std::move(callback).Run(StatusCode::kOK, endpoint->endpoint_access_token());
}

void AuthorizationZoneImpl::MarkEndpointAccessTokenAsExpired(
    const chromeos::Uri& ipp_endpoint,
    const std::string& endpoint_access_token) {
  if (endpoint_access_token.empty()) {
    return;
  }
  auto it = ipp_endpoints_.find(ipp_endpoint);
  if (it == ipp_endpoints_.end()) {
    return;
  }
  IppEndpointTokenFetcher* endpoint = it->second.get();
  if (endpoint->endpoint_access_token() == endpoint_access_token) {
    ipp_endpoints_.erase(it);
  }
}

void AuthorizationZoneImpl::AuthorizationProcedure() {
  DCHECK_LE(pending_authorizations_.size(), kMaxNumberOfSessions);

  for (auto& wa : waiting_authorizations_) {
    // Remove the oldest pending authorization if there are too many of them.
    if (pending_authorizations_.size() == kMaxNumberOfSessions) {
      pending_authorizations_.pop_front();
    }
    // Create new pending authorization and call the callback with an
    // authorization URL to open in the browser.
    PendingAuthorization& pa = pending_authorizations_.emplace_back(
        std::move(wa.scopes), RandBase64String<kLengthOfState>(),
        RandBase64String<kLengthOfCodeVerifier>());
    std::string auth_url = GetAuthorizationURL(server_data_, pa.scopes,
                                               pa.state, pa.code_verifier);
    std::move(wa.callback).Run(StatusCode::kOK, std::move(auth_url));
  }
  waiting_authorizations_.clear();
}

void AuthorizationZoneImpl::MarkAuthorizationZoneAsUntrusted() {
  const std::string msg = "Authorization Server marked as untrusted";

  pending_authorizations_.clear();

  // This method will call all callbacks from `waiting_authorizations_` and
  // empty it.
  OnInitializeCallback(StatusCode::kUntrustedAuthorizationServer, msg);

  // Clear `sessions_`.
  for (std::unique_ptr<AuthorizationServerSession>& session : sessions_) {
    std::vector<StatusCallback> callbacks = session->TakeWaitingList();
    for (StatusCallback& callback : callbacks) {
      std::move(callback).Run(StatusCode::kUntrustedAuthorizationServer, msg);
    }
  }
  sessions_.clear();

  // Clear `ipp_endpoints_`.
  for (auto& [_, ipp_endpoint] : ipp_endpoints_) {
    std::vector<StatusCallback> callbacks = ipp_endpoint->TakeWaitingList();
    for (StatusCallback& callback : callbacks) {
      std::move(callback).Run(StatusCode::kUntrustedAuthorizationServer, msg);
    }
  }
  ipp_endpoints_.clear();
}

void AuthorizationZoneImpl::OnInitializeCallback(StatusCode status,
                                                 std::string data) {
  if (status == StatusCode::kOK) {
    AuthorizationProcedure();
    return;
  }
  // Something went wrong. Return error.
  for (auto& wa : waiting_authorizations_) {
    std::move(wa.callback).Run(status, data);
  }
  waiting_authorizations_.clear();
}

void AuthorizationZoneImpl::OnSendTokenRequestCallback(
    AuthorizationServerSession* session,
    StatusCode status,
    std::string data) {
  // Find the session for which the request was completed.
  auto it_session = base::ranges::find(
      sessions_, session, &std::unique_ptr<AuthorizationServerSession>::get);
  DCHECK(it_session != sessions_.end());

  // Get the list of callbacks to run and copy the data.
  std::vector<StatusCallback> callbacks = session->TakeWaitingList();
  // Erase the session if the request failed.
  if (status != StatusCode::kOK) {
    sessions_.erase(it_session);
  }
  // Run the callbacks.
  for (auto& callback : callbacks) {
    std::move(callback).Run(status, data);
  }
}

void AuthorizationZoneImpl::OnTokenExchangeRequestCallback(
    const chromeos::Uri& ipp_endpoint,
    StatusCode status,
    std::string data) {
  if (status == StatusCode::kInvalidAccessToken) {
    // The access token used by IppEndpointFetcher is invalid. Find the session
    // the token came from and ask it to refresh the token.
    for (std::unique_ptr<AuthorizationServerSession>& session : sessions_) {
      if (session->access_token() == data) {  // data == invalid access token
        // We can use base::Unretained() here because:
        // * AuthorizationServerSession (and HttpExchange) guarantees that no
        //   calls will be returned after deletion of the object `session`.
        // * `this` owns `session`; it is guaranteed that deletion of `session`
        //   is performed before deletion of `this`.
        session->SendNextTokenRequest(base::BindOnce(
            &AuthorizationZoneImpl::OnSendTokenRequestCallback,
            base::Unretained(this), base::Unretained(session.get())));
      }
    }

    // Find the corresponding IppEndpointTokenFetcher object.
    auto it_endpoint = ipp_endpoints_.find(ipp_endpoint);
    DCHECK(it_endpoint != ipp_endpoints_.end());
    IppEndpointTokenFetcher* endpoint = it_endpoint->second.get();

    // Try to find a new session for IPP endpoint and perform Token Exchange
    // again.
    AttemptTokenExchange(endpoint);
    return;
  }
  // For all other statuses just send back the result.
  ResultForIppEndpoint(ipp_endpoint, status, std::move(data));
}

void AuthorizationZoneImpl::ResultForIppEndpoint(
    const chromeos::Uri& ipp_endpoint,
    StatusCode status,
    std::string data) {
  auto it = ipp_endpoints_.find(ipp_endpoint);
  DCHECK(it != ipp_endpoints_.end());
  // The list of callbacks to run.
  std::vector<StatusCallback> callbacks = it->second->TakeWaitingList();
  // Erase the IPP Endpoint in case of an error.
  if (status != StatusCode::kOK) {
    ipp_endpoints_.erase(it);
  }
  // Run the callbacks.
  for (auto& callback : callbacks) {
    std::move(callback).Run(status, data);
  }
}

void AuthorizationZoneImpl::OnAccessTokenForEndpointCallback(
    const chromeos::Uri& ipp_endpoint,
    StatusCode status,
    std::string data) {
  auto it = ipp_endpoints_.find(ipp_endpoint);
  DCHECK(it != ipp_endpoints_.end());
  IppEndpointTokenFetcher* endpoint = it->second.get();

  switch (status) {
    case StatusCode::kOK:
      // We got a new access token (in `data`). Now, we can get a new endpoint
      // access token.
      // We can use base::Unretained() here because:
      // * IppEndpointTokenFetcher (and HttpExchange) guarantees that no
      //   calls will be returned after deletion of the object `endpoint`.
      // * `this` owns `endpoint`; it is guaranteed that deletion of `endpoint`
      //   is performed before deletion of `this`.
      endpoint->SendTokenExchangeRequest(
          data,
          base::BindOnce(&AuthorizationZoneImpl::OnTokenExchangeRequestCallback,
                         base::Unretained(this), ipp_endpoint));
      break;
    case StatusCode::kInvalidAccessToken:
    case StatusCode::kTooManySessions:
      // The session timed out. Try to find other session to get an access
      // token.
      AttemptTokenExchange(endpoint);
      break;
    default:
      // For all other statuses just send back the result.
      ResultForIppEndpoint(ipp_endpoint, status, std::move(data));
      break;
  }
}

void AuthorizationZoneImpl::AttemptTokenExchange(
    IppEndpointTokenFetcher* endpoint) {
  AuthorizationServerSession* auth_session = nullptr;
  // Try to match a session starting from the newest one.
  for (auto& session : base::Reversed(sessions_)) {
    if (session->ContainsAll(endpoint->scope())) {
      auth_session = session.get();
      break;
    }
  }
  if (!auth_session) {
    // No matching sessions. Inform the callers that a new session must be
    // created.
    ResultForIppEndpoint(endpoint->ipp_endpoint_uri(),
                         StatusCode::kAuthorizationNeeded, "");
    return;
  }

  // We found a session to use. Get its access token.
  const auto access_token = auth_session->access_token();
  if (access_token.empty()) {
    // Access token not ready. Add the IPP Endpoint to the waiting list.
    // We can use base::Unretained() here because:
    // * AuthorizationServerSession (and HttpExchange) guarantees that no
    //   calls will be returned after deletion of the object `auth_session`.
    // * `this` owns `auth_session`; it is guaranteed that deletion of
    //   `auth_session` is performed before deletion of `this`.
    auth_session->AddToWaitingList(
        base::BindOnce(&AuthorizationZoneImpl::OnAccessTokenForEndpointCallback,
                       base::Unretained(this), endpoint->ipp_endpoint_uri()));
    return;
  }

  // Try to use the access token to get a new endpoint access token.
  // We can use base::Unretained() here because:
  // * IppEndpointTokenFetcher (and HttpExchange) guarantees that no
  //   calls will be returned after deletion of the object `endpoint`.
  // * `this` owns `endpoint`; it is guaranteed that deletion of `endpoint`
  //   is performed before deletion of `this`.
  endpoint->SendTokenExchangeRequest(
      access_token,
      base::BindOnce(&AuthorizationZoneImpl::OnTokenExchangeRequestCallback,
                     base::Unretained(this), endpoint->ipp_endpoint_uri()));
}

bool AuthorizationZoneImpl::FindAndRemovePendingAuthorization(
    const std::string& state,
    base::flat_set<std::string>& scopes,
    std::string& code_verifier) {
  std::list<PendingAuthorization>::iterator it = base::ranges::find(
      pending_authorizations_, state, &PendingAuthorization::state);
  if (it == pending_authorizations_.end()) {
    return false;
  }
  scopes = std::move(it->scopes);
  code_verifier = std::move(it->code_verifier);
  pending_authorizations_.erase(it);
  return true;
}

std::unique_ptr<AuthorizationZone> AuthorizationZone::Create(
    scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory,
    const GURL& authorization_server_uri,
    ClientIdsDatabase* client_ids_database) {
  return std::make_unique<AuthorizationZoneImpl>(
      url_loader_factory, authorization_server_uri, client_ids_database);
}

}  // namespace oauth2
}  // namespace printing
}  // namespace ash


text:
package org.yellowbinary.server.preview.model;

import org.joda.time.DateTime;
import org.yellowbinary.server.backend.preview.Ticket;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;

@Entity
@Table(name = "ticket")
public class BasicTicket implements Ticket {

    public static final String TYPE = "yellowbinary.Ticket";

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;

    @NotNull
    private String userId;

    @NotNull
    private String token;

    @NotNull
    private long validUntil;

    @NotNull
    private long preview;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getUserId() {
        return userId;
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }

    public String getToken() {
        return token;
    }

    public void setToken(String token) {
        this.token = token;
    }

    public long getValidUntil() {
        return validUntil;
    }

    public void setValidUntil(long validUntil) {
        this.validUntil = validUntil;
    }

    public long getPreview() {
        return preview;
    }

    public void setPreview(long preview) {
        this.preview = preview;
    }

    public DateTime getValidUntilDateTime() {
        if (validUntil > 0) {
            return new DateTime().withMillis(validUntil);
        }
        return null;
    }

    public DateTime getPreviewDateTime() {
        if (preview > 0) {
            return new DateTime().withMillis(preview);
        }
        return null;
    }
}

redpajama_set_name: RedPajamaGithub


text:
import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Router } from '@angular/router';
import { BehaviorSubject, Observable } from 'rxjs';
import { catchError, map, mergeMap, tap } from 'rxjs/operators';
import { BaseService } from '../../helpers/base.service';
import { User } from '../entity';

@Injectable()
export class UserService extends BaseService {
    private _baseUrl = '/api/user';

    private _userInfoSubject = new BehaviorSubject(null);

    constructor(
        private _http: HttpClient,
        private _router: Router
    ) {
        super();
        // console.log('init user service: #' + (Math.random()* 1000));
        this.getUserInfo().subscribe(() => {});
    }

    get userInfo(): Observable<User> {
        return this._userInfoSubject.asObservable();
    }

    register(user: User): Observable<any> {
        return this._http.post<any>(`${this._baseUrl}/register`, user).pipe(
            catchError(this.handleError),);
    }

    login(user: User): Observable<any> {
        return this._http.post<any>(`${this._baseUrl}/login`, user).pipe(
            mergeMap(() => {
                return this.getUserInfo();
            }),
            catchError(this.handleError),);
    }

    logout(): Observable<any> {
        return this._http.post<any>(`${this._baseUrl}/logout`, null).pipe(
            tap(() => {
                this._router.navigateByUrl('/login');
                this._userInfoSubject.next(null);
            }),
            catchError(this.handleError),);
    }

    getUserInfo(): Observable<User> {
        return this._http.get<{data: User}>(`${this._baseUrl}/info`).pipe(
            map(res => res.data),
            tap(user => {
                this._userInfoSubject.next(user);
            }),
            catchError(this.handleError),);
    }

    updateEmail(email, current_pass): Observable<any> {
        return this._http.post<any>(`${this._baseUrl}/email`, {email: email, password: current_pass}).pipe(
            mergeMap(() => {
                return this.getUserInfo();
            }),
            catchError(this.handleError),);
    }

    updatePass(password, new_password, new_password_repeat): Observable<any> {
        return this._http.post<any>(`${this._baseUrl}/update-pass`, {
            new_password: new_password,
            new_password_repeat: new_password_repeat,
            password: password
        }).pipe(
            catchError(this.handleError),);
    }

    requestResetPass(email: string): Observable<any> {
        return this._http.post<any>(`${this._baseUrl}/request-reset-pass`,{email: email}).pipe(
            catchError(this.handleError),);
    }

    resetPassword(new_pass: string, new_pass_repeat: string, token: string): Observable<any> {
        return this._http.post<any>(`${this._baseUrl}/reset-pass`, {
            new_pass: new_pass,
            new_pass_repeat: new_pass_repeat,
            token: token
        }).pipe(
            catchError(this.handleError),);
    }

    resendMail(): Observable<any> {
        return this._http.post<any>(`${this._baseUrl}/email/resend`, null).pipe(
            catchError(this.handleError),);
    }
}


text:
```
$ cd mycoolsvnrepo/
mycoolsvnrepo$ cd trunk/src/main/java/
java (trunk)$ cd ../branches/feature-1/src/main/java/
java (feature-1)$
```

# INSTALL

Download [svn-prompt.sh](https://raw.githubusercontent.com/mcandre/svn-prompt/master/svn-prompt.sh) and place into `$HOME`:

```
$ wget -O $HOME/svn-prompt.sh https://raw.githubusercontent.com/mcandre/svn-prompt/master/svn-prompt.sh
```

Then configure your `$HOME/.bash_profile` or similar shell configuration to use svn-prompt:

```
# svn prompt
# See https://raw.githubusercontent.com/mcandre/svn-prompt/master/svn-prompt.sh
. $HOME/svn-prompt.sh

export PS1='\W$(parse_svn_branch)$ '
```

If you would like to use svn prompt with [git prompt](https://github.com/git/git/blob/master/contrib/completion/git-prompt.sh):

```
# git prompt
# See https://github.com/git/git/blob/master/contrib/completion/git-prompt.sh
. $HOME/git-prompt.sh

# svn prompt
# See https://raw.githubusercontent.com/mcandre/svn-prompt/master/svn-prompt.sh
. $HOME/svn-prompt.sh

export PS1='\W$(__git_ps1 " (%s)")$(parse_svn_branch)$ '
```

Then update your shell:

```
$ source $HOME/.bash_profile
```

Now `cd` around a Subversion repository to test your new shell prompt!

# CREDITS

Inspired by [git prompt](https://github.com/git/git/blob/master/contrib/completion/git-prompt.sh) and [hocuspokus](http://hocuspokus.net/2009/07/add-git-and-svn-branch-to-bash-prompt/).


text:
var labelType, useGradients, nativeTextSupport, animate;

(function() {
  var ua = navigator.userAgent,
      iStuff = ua.match(/iPhone/i) || ua.match(/iPad/i),
      typeOfCanvas = typeof HTMLCanvasElement,
      nativeCanvasSupport = (typeOfCanvas == 'object' || typeOfCanvas == 'function'),
      textSupport = nativeCanvasSupport
        && (typeof document.createElement('canvas').getContext('2d').fillText == 'function');
  //I'm setting this based on the fact that ExCanvas provides text support for IE
  //and that as of today iPhone/iPad current text support is lame
  labelType = (!nativeCanvasSupport || (textSupport && !iStuff))? 'Native' : 'HTML';
  nativeTextSupport = labelType == 'Native';
  useGradients = nativeCanvasSupport;
  animate = !(iStuff || !nativeCanvasSupport);
})();

var Log = {
  elem: false,
  write: function(text){
    if (!this.elem)
      this.elem = document.getElementById('log');
    this.elem.innerHTML = text;
    this.elem.style.left = (500 - this.elem.offsetWidth / 2) + 'px';
  }
};

function init(){
  // init data
  var json = {
    id: "190_0",
    name: "Pearl Jam",
    children: [
        {
          id: "306208_1",
          name: "Pearl Jam & Cypress Hill",
          data: {
            relation: "
Pearl Jam & Cypress Hill
Connections:

Pearl Jam
(relation: collaboration)

Cypress Hill
(relation: collaboration)

"
          },
          children: [
            {
              id: "84_2",
              name: "Cypress Hill",
              data: {
                relation: "
Cypress Hill
Connections:

Pearl Jam & Cypress Hill
(relation: collaboration)

"
              },
              children: []
            }
          ]
        },
        {
          id: "107877_3",
          name: "Neil Young & Pearl Jam",
          data: {
            relation: "
Neil Young & Pearl Jam
Connections:

Pearl Jam
(relation: collaboration)

Neil Young
(relation: collaboration)

"
          },
          children: [
            {
              id: "964_4",
              name: "Neil Young",
              data: {
                relation: "
Neil Young
Connections:

Neil Young & Pearl Jam
(relation: collaboration)

"
              },
              children: []
            }
          ]
        },
        {
          id: "236797_5",
          name: "Jeff Ament",
          data: {
            relation: "
Jeff Ament
Connections:

Pearl Jam
(relation: member of band)

Temple of the Dog
(relation: member of band)

Mother Love Bone
(relation: member of band)

Green River
(relation: member of band)

M.A.C.C.
(relation: collaboration)

Three Fish
(relation: member of band)

Gossman Project
(relation: member of band)

"
          },
          children: [
              {
                id: "1756_6",
                name: "Temple of the Dog",
                data: {
                  relation: "
Temple of the Dog
Connections:

Jeff Ament
(relation: member of band)

"
                },
                children: []
              },
              {
                id: "14581_7",
                name: "Mother Love Bone",
                data: {
                  relation: "
Mother Love Bone
Connections:

Jeff Ament
(relation: member of band)

"
                },
                children: []
              },
              {
                id: "50188_8",
                name: "Green River",
                data: {
                  relation: "
Green River
Connections:

Jeff Ament
(relation: member of band)

"
                },
                children: []
              },
              {
                id: "65452_9",
                name: "M.A.C.C.",
                data: {
                  relation: "
M.A.C.C.
Connections:

Jeff Ament
(relation: collaboration)

"
                },
                children: []
              },
              {
                id: "115632_10",
                name: "Three Fish",
                data: {
                  relation: "
Three Fish
Connections:

Jeff Ament
(relation: member of band)

"
                },
                children: []
              },
              {
                id: "346850_11",
                name: "Gossman Project",
                data: {
                  relation: "
Gossman Project
Connections:

Jeff Ament
(relation: member of band)

"
                },
                children: []
              }
          ]
        },
        {
          id: "41529_12",
          name: "Stone Gossard",
          data: {
            relation: "
Stone Gossard
Connections:

Pearl Jam
(relation: member of band)

Temple of the Dog
(relation: member of band)

Mother Love Bone
(relation: member of band)

Brad
(relation: member of band)

Green River
(relation: member of band)

Gossman Project
(relation: member of band)

"
          },
          children: [
              {
                id: "1756_13",
                name: "Temple of the Dog",
                data: {
                  relation: "
Temple of the Dog
Connections:

Stone Gossard
(relation: member of band)

"
                },
                children: []
              },
              {
                id: "14581_14",
                name: "Mother Love Bone",
                data: {
                  relation: "
Mother Love Bone
Connections:

Stone Gossard
(relation: member of band)

"
                },
                children: []
              },
              {
                id: "24119_15",
                name: "Brad",
                data: {
                  relation: "
Brad
Connections:

Stone Gossard
(relation: member of band)

"
                },
                children: []
              },
              {
                id: "50188_16",
                name: "Green River",
                data: {
                  relation: "
Green River
Connections:

Stone Gossard
(relation: member of band)

"
                },
                children: []
              },
              {
                id: "346850_17",
                name: "Gossman Project",
                data: {
                  relation: "
Gossman Project
Connections:

Stone Gossard
(relation: member of band)

"
                },
                children: []
              }
          ]
        },
        {
          id: "131161_18",
          name: "Eddie Vedder",
          data: {
            relation: "
Eddie Vedder
Connections:

Pearl Jam
(relation: member of band)

Temple of the Dog
(relation: member of band)

Eddie Vedder & Zeke
(relation: collaboration)

Bad Radio
(relation: member of band)

Beck & Eddie Vedder
(relation: collaboration)

"
          },
          children: [
              {
                id: "1756_19",
                name: "Temple of the Dog",
                data: {
                  relation: "
Temple of the Dog
Connections:

Eddie Vedder
(relation: member of band)

"
                },
                children: []
              },
              {
                id: "72007_20",
                name: "Eddie Vedder & Zeke",
                data: {
                  relation: "
Eddie Vedder & Zeke
Connections:

Eddie Vedder
(relation: collaboration)

"
                },
                children: []
              },
              {
                id: "236657_21",
                name: "Bad Radio",
                data: {
                  relation: "
Bad Radio
Connections:

Eddie Vedder
(relation: member of band)

"
                },
                children: []
              },
              {
                id: "432176_22",
                name: "Beck & Eddie Vedder",
                data: {
                  relation: "
Beck & Eddie Vedder
Connections:

Eddie Vedder
(relation: collaboration)

"
                },
                children: []
              }
          ]
        },
        {
          id: "236583_23",
          name: "Mike McCready",
          data: {
            relation: "
Mike McCready
Connections:

Pearl Jam
(relation: member of band)

Mad Season
(relation: member of band)

Temple of the Dog
(relation: member of band)

$10,000 Gold Chain
(relation: collaboration)

M.A.C.C.
(relation: collaboration)

The Rockfords
(relation: member of band)

Gossman Project
(relation: member of band)

"
          },
          children: [
              {
                id: "1744_24",
                name: "Mad Season",
                data: {
                  relation: "
Mad Season
Connections:

Mike McCready
(relation: member of band)

"
                },
                children: []
              },
              {
                id: "1756_25",
                name: "Temple of the Dog",
                data: {
                  relation: "
Temple of the Dog
Connections:

Mike McCready
(relation: member of band)

"
                },
                children: []
              },
              {
                id: "43661_26",
                name: "$10,000 Gold Chain",
                data: {
                  relation: "
$10,000 Gold Chain
Connections:

Mike McCready
(relation: collaboration)

"
                },
                children: []
              },
              {
                id: "65452_27",
                name: "M.A.C.C.",
                data: {
                  relation: "
M.A.C.C.
Connections:

Mike McCready
(relation: collaboration)

"
                },
                children: []
              },
              {
                id: "153766_28",
                name: "The Rockfords",
                data: {
                  relation: "
The Rockfords
Connections:

Mike McCready
(relation: member of band)

"
                },
                children: []
              },
              {
                id: "346850_29",
                name: "Gossman Project",
                data: {
                  relation: "
Gossman Project
Connections:

Mike McCready
(relation: member of band)

"
                },
                children: []
              }
          ]
        },
        {
          id: "236585_30",
          name: "Matt Cameron",
          data: {
            relation: "
Matt Cameron
Connections:

Pearl Jam
(relation: member of band)

Soundgarden
(relation: member of band)

Temple of the Dog
(relation: member of band)

Eleven
(relation: supporting musician)

Queens of the Stone Age
(relation: member of band)

Wellwater Conspiracy
(relation: member of band)

M.A.C.C.
(relation: collaboration)

Tone Dogs
(relation: member of band)

"
          },
          children: [
              {
                id: "1111_31",
                name: "Soundgarden",
                data: {
                  relation: "
Soundgarden
Connections:

Matt Cameron
(relation: member of band)

"
                },
                children: []
              },
              {
                id: "1756_32",
                name: "Temple of the Dog",
                data: {
                  relation: "
Temple of the Dog
Connections:

Matt Cameron
(relation: member of band)

"
                },
                children: []
              },
              {
                id: "9570_33",
                name: "Eleven",
                data: {
                  relation: "
Eleven
Connections:

Matt Cameron
(relation: supporting musician)

"
                },
                children: []
              },
              {
                id: "11783_34",
                name: "Queens of the Stone Age",
                data: {
                  relation: "
Queens of the Stone Age
Connections:

Matt Cameron
(relation: member of band)

"
                },
                children: []
              },
              {
                id: "61972_35",
                name: "Wellwater Conspiracy",
                data: {
                  relation: "
Wellwater Conspiracy
Connections:

Matt Cameron
(relation: member of band)

"
                },
                children: []
              },
              {
                id: "65452_36",
                name: "M.A.C.C.",
                data: {
                  relation: "
M.A.C.C.
Connections:

Matt Cameron
(relation: collaboration)

"
                },
                children: []
              },
              {
                id: "353097_37",
                name: "Tone Dogs",
                data: {
                  relation: "
Tone Dogs
Connections:

Matt Cameron
(relation: member of band)

"
                },
                children: []
              }
          ]
        },
        {
          id: "236594_38",
          name: "Dave Krusen",
          data: {
            relation: "
Dave Krusen
Connections:

Pearl Jam
(relation: member of band)

Candlebox
(relation: member of band)

"
          },
          children: [
            {
              id: "2092_39",
              name: "Candlebox",
              data: {
                relation: "
Candlebox
Connections:

Dave Krusen
(relation: member of band)

"
              },
              children: []
            }
          ]
        },
        {
          id: "236022_40",
          name: "Matt Chamberlain",
          data: {
            relation: "
Matt Chamberlain
Connections:

Pearl Jam
(relation: member of band)

Critters Buggin
(relation: member of band)

Edie Brickell and New Bohemians
(relation: member of band)

"
          },
          children: [
              {
                id: "54761_41",
                name: "Critters Buggin",
                data: {
                  relation: "
Critters Buggin
Connections:

Matt Chamberlain
(relation: member of band)

"
                },
                children: []
              },
              {
                id: "92043_42",
                name: "Edie Brickell and New Bohemians",
                data: {
                  relation: "
Edie Brickell and New Bohemians
Connections:

Matt Chamberlain
(relation: member of band)

"
                },
                children: []
              }
          ]
        },
        {
          id: "236611_43",
          name: "Dave Abbruzzese",
          data: {
            relation: "
Dave Abbruzzese
Connections:

Pearl Jam
(relation: member of band)

Green Romance Orchestra
(relation: member of band)

"
          },
          children: [
            {
              id: "276933_44",
              name: "Green Romance Orchestra",
              data: {
                relation: "
Green Romance Orchestra
Connections:

Dave Abbruzzese
(relation: member of band)

"
              },
              children: []
            }
          ]
        },
        {
          id: "236612_45",
          name: "Jack Irons",
          data: {
            relation: "
Jack Irons
Connections:

Pearl Jam
(relation: member of band)

Redd Kross
(relation: member of band)

Eleven
(relation: member of band)

Red Hot Chili Peppers
(relation: member of band)

Anthym
(relation: member of band)

What Is This?
(relation: member of band)

"
          },
          children: [
              {
                id: "4619_46",
                name: "Redd Kross",
                data: {
                  relation: "
Redd Kross
Connections:

Jack Irons
(relation: member of band)

"
                },
                children: []
              },
              {
                id: "9570_47",
                name: "Eleven",
                data: {
                  relation: "
Eleven
Connections:

Jack Irons
(relation: member of band)

"
                },
                children: []
              },
              {
                id: "12389_48",
                name: "Red Hot Chili Peppers",
                data: {
                  relation: "
Red Hot Chili Peppers
Connections:

Jack Irons
(relation: member of band)

"
                },
                children: []
              },
              {
                id: "114288_49",
                name: "Anthym",
                data: {
                  relation: "
Anthym
Connections:

Jack Irons
(relation: member of band)

"
                },
                children: []
              },
              {
                id: "240013_50",
                name: "What Is This?",
                data: {
                  relation: "
What Is This?
Connections:

Jack Irons
(relation: member of band)

"
                },
                children: []
              }
          ]
        }
    ],
    data: {
      relation: "
Pearl Jam
Connections:

Pearl Jam & Cypress Hill
(relation: collaboration)

Neil Young & Pearl Jam
(relation: collaboration)

Jeff Ament
(relation: member of band)

Stone Gossard
(relation: member of band)

Eddie Vedder
(relation: member of band)

Mike McCready
(relation: member of band)

Matt Cameron
(relation: member of band)

Dave Krusen
(relation: member of band)

Matt Chamberlain
(relation: member of band)

Dave Abbruzzese
(relation: member of band)

Jack Irons
(relation: member of band)

"
    }
  };
  // end
  // init RGraph
  var rgraph = new $jit.RGraph({
    // Where to append the visualization
    injectInto: 'infovis',
    // Optional: create a background canvas and plot
    // concentric circles in it.
    background: {
      CanvasStyles: {
        strokeStyle: '#555',
        shadowBlur: 10,
        shadowColor: '#ccc'
      }
    },
    // Set Edge and Node styles
    Node: {
      overridable: true,
      color: '#ccddee',
      dim: 12
    },
    Edge: {
      overridable: true,
      color: '#C17878',
      lineWidth: 1.5
    },
    // Use native canvas text
    Label: {
      type: labelType,
      size: 11,
      family: 'Verdana',
      color: '#fff'
    },
    //Add events for Dragging and dropping nodes
    Events: {
      enable: true,
      type: 'Native',
      onMouseEnter: function(node, eventInfo, e){
        rgraph.canvas.getElement().style.cursor = 'move';
      },
      onMouseLeave: function(node, eventInfo, e){
        rgraph.canvas.getElement().style.cursor = '';
      },
      onDragMove: function(node, eventInfo, e){
        var pos = eventInfo.getPos();
        node.pos.setc(pos.x, pos.y);
        rgraph.plot();
      },
      onDragEnd: function(node, eventInfo, e){
        rgraph.compute('end');
        rgraph.fx.animate( {
          modes: [
            'linear'
          ],
          duration: 700,
          transition: $jit.Trans.Elastic.easeOut
        });
      },
      //touch events
      onTouchStart: function(node, eventInfo, e) {
        //stop the default event
        $jit.util.event.stop(e);
      },
      onTouchMove: function(node, eventInfo, e){
        //stop the default event
        $jit.util.event.stop(e);
        var pos = eventInfo.getPos();
        node.pos.setc(pos.x, pos.y);
        rgraph.plot();
      },
      onTouchEnd: function(node, eventInfo, e){
        //stop the default event
        $jit.util.event.stop(e);
        rgraph.compute('end');
        rgraph.fx.animate( {
          modes: [
            'linear'
          ],
          duration: 700,
          transition: $jit.Trans.Elastic.easeOut
        });
      }
    },
    //Add the name of the node in the correponding label
    //and a click handler to move the graph.
    //This method is called once, on label creation.
    onCreateLabel: function(domElement, node){
      domElement.innerHTML = node.name;
    },
    //Change some label dom properties.
    //This method is called each time a label is plotted.
    onPlaceLabel: function(domElement, node){
        var style = domElement.style;
        style.display = '';
        style.cursor = 'pointer';

        if (node._depth <= 1) {
            style.fontSize = "0.8em";
            style.color = "#ccc";

        } else if(node._depth == 2){
            style.fontSize = "0.7em";
            style.color = "#494949";

        } else {
            style.display = 'none';
        }

        var left = parseInt(style.left);
        var w = domElement.offsetWidth;
        style.left = (left - w / 2) + 'px';
    }
  });
  // load JSON data
  rgraph.loadJSON(json);
  // compute positions and make the first plot
  rgraph.refresh();
  // end
}


text:
@extends('devise::layouts.email')

@section('content')

Welcome to Devise!

A user account was successfully created for the email address:
<?= $user->email ?>. To complete the activation process, please click on the button below:

										<a href="<?= URL::route('dvs-user-activate', [$user->id, urlencode($user->activate_code)]) ?>" style="display:block;width:80%;max-width:220px;margin:auto;padding:25px 20px;font-weight:500;color:#59babe;text-decoration:none;background-color:transparent;border:2px solid #59babe;border-radius:4px;cursor:pointer;">Activate User Account

@stop


text:
<?php
namespace QTU\TkbBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;

class SwiftMailerController extends Controller
{
    public function indexAction()
    {
        $em = $this->getDoctrine()->getManager();

        //get Faculties
        $faculties = $em->getRepository('QTUTkbBundle:Faculty')->findBy(array('isStudentManagement'=>true));
        //get Classes
        $classes = $em->getRepository('QTUTkbBundle:ClassP')->findBy(array('stillStudy'=>true));
        //get Users
        $users = $em->getRepository('ApplicationSonataUserBundle:User')->findBy(array('enabled'=>true));
        //get Week data
        return $this->render('QTUTkbBundle:SwiftMailer:index.html.twig', array(
            'classes' => $classes,
        ));
    }

    public function sendMailAction()
    {
        $message = \Swift_Message::newInstance()
            ->setSubject('SwiftMailer Test')
            ->setFrom('tkb@quangtrung.edu.vn')
            ->setTo('phvilien@gmail.com')
            ->setBody($this->renderView('QTUTkbBundle:SwiftMailer:index.html.twig'))
        ;
        $this->get('mailer')->send($message);

        return $this->render('QTUTkbBundle:SwiftMailer:index.html.twig');
    }
}


text:
<query xmlns="http://labkey.org/data/xml/query">
    <metadata>
        <tables xmlns="http://labkey.org/data/xml">
            <table tableName="Assignment" tableDbType="TABLE" useColumnOrder="true">
                <columns>
                    <column columnName="Id"/>
                    <column columnName="project">
                        <fk>
                            <fkDbSchema>ehrLinked</fkDbSchema> <!--linked schema ehrLinked is expected in Private folder. Use ehrLinked.template.xml to create this linked schema-->
                            <fkTable>project</fkTable>
                            <fkColumnName>project</fkColumnName>
                        </fk>
                    </column>
                </columns>
            </table>
        </tables>
    </metadata>
</query>


text:
var POST_BUCKET = 'constellational-posts';
var USER_BUCKET = 'constellational-users';
var META_BUCKET = 'constellational-users-meta';

var Promise = require('bluebird');
var AWS = require('aws-sdk');
var s3 = new AWS.S3();
Promise.promisifyAll(Object.getPrototypeOf(s3));

function getUser(key) {
  console.log("Going to get " + key + " from " + USER_BUCKET);
  return s3.getObjectAsync({Bucket: USER_BUCKET, Key: key}).then(function(data) {
    var s = new Buffer(data.Body).toString();
    return JSON.parse(s);
  }).catch(function() {
    return {};
  });
}

function list(username) {
  console.log("Going to list posts for " + username);
  var prefix = username + '/';
  return getUser(username).then(function(user) {
    return s3.listObjectVersionsAsync({Bucket: POST_BUCKET, Prefix: prefix}).then(function(data) {
      var latest = data.Versions.filter(function(o) {
        // After deleting objects, there seems to be a obj with size 0
        return (o.IsLatest && (o.Key !== prefix));
      });
      user.posts = latest.map(function(o) {
        return o.Key.substring(prefix.length) + '?VersionId=' + o.VersionId;
      });
      user.posts.reverse();
      return user;
    });
  });
}

function storeStaticFile(key, json) {
  console.log("Going to put " + key + " in " + USER_BUCKET);
  return s3.putObjectAsync({
    Bucket: USER_BUCKET,
    Key: key,
    Body: JSON.stringify(json),
    ContentType: 'application/json',
    ACL: 'public-read'
  });
}

exports.handler = function(event, context) {
  console.log("Starting");

  var key = event.Records[0].s3.object.key;
  console.log("The key is: "+key);
  var splitKey = key.split('/');
  var username = splitKey[0];
  if (splitKey.length < 2) context.fail("Not a post");
  else list(username).then(function(data) {
    console.log("Going to store static file");
    return storeStaticFile(username, data);
  }).then(context.succeed).catch(context.fail);
};


text:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using AppOverlay;

namespace WebApplication3
{
    public partial class ImportarTareaDS : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (DBUtility.connect())
            {
                Console.WriteLine("[Success] Connected to the database. ");
            }
            Xml1.DocumentSource = Server.MapPath("app_data/" + DropDownList1.SelectedValue + ".xml");
            Xml1.TransformSource = Server.MapPath("app_data/XSLTFile.xsl");
        }
        protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
        {

            Xml1.DocumentSource = Server.MapPath("app_data/" + DropDownList1.SelectedValue + ".xml");
            Xml1.TransformSource = Server.MapPath("app_data/XSLTFile.xsl");
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            try
            {
                DataSet dSet = new DataSet();
                SqlCommand command = new SqlCommand("SELECT * FROM TareasGenericas", DBUtility.connection);
                SqlDataAdapter dAdapter = new SqlDataAdapter(command);
                SqlCommandBuilder commandBuilder = new SqlCommandBuilder(dAdapter);

                dSet.ReadXml(Server.MapPath("app_data/" + DropDownList1.SelectedValue + ".xml"));
                dSet.Tables[0].Columns.Add("CodAsig");

                foreach (DataRow dRow in dSet.Tables[0].Rows)
                {
                    dRow["CodAsig"] = DropDownList1.SelectedValue;
                }

                dAdapter.Update(dSet.Tables[0]);
                Label1.ForeColor = System.Drawing.Color.Green;
                Label1.Text = "Introducido correctamente.";
            }
            catch (Exception ex)
            {
                Label1.ForeColor = System.Drawing.Color.Red;
                Label1.Text = "Ha ocurrido un error importando las tareas a la BD";
            }
        }
        protected void Page_Unload(object sender, EventArgs e)
        {
            DBUtility.close();
        }
    }
}


text:
package org.ovirt.engine.core.common.businessentities.pm;

import static org.junit.Assert.assertEquals;

import org.junit.Test;
import org.ovirt.engine.core.common.businessentities.pm.FenceOperationResult.Status;

public class FenceOperationResultTest {
    /**
     * Test result value for successful status action of host powered on
     */
    @Test
    public void successfulStatusOn() {
        FenceOperationResult result = new FenceOperationResult(
                FenceActionType.STATUS,
                0,
                null,
                "on",
                null);

        assertEquals(Status.SUCCESS, result.getStatus());
        assertEquals(PowerStatus.ON, result.getPowerStatus());
    }

    /**
     * Test result value for successful status action of host powered off
     */
    @Test
    public void successfulStatusOff() {
        FenceOperationResult result = new FenceOperationResult(
                FenceActionType.STATUS,
                0,
                null,
                "off",
                null);

        assertEquals(Status.SUCCESS, result.getStatus());
        assertEquals(PowerStatus.OFF, result.getPowerStatus());
    }

    /**
     * Test result value for failed status action
     */
    @Test
    public void failedStatus() {
        FenceOperationResult result = new FenceOperationResult(
                FenceActionType.STATUS,
                1,
                null,
                "unknown",
                null);

        assertEquals(Status.ERROR, result.getStatus());
        assertEquals(PowerStatus.UNKNOWN, result.getPowerStatus());
    }

    /**
     * Test result value for successful stop action
     */
    @Test
    public void successfulStop() {
        FenceOperationResult result = new FenceOperationResult(
                FenceActionType.STOP,
                0,
                null,
                null,
                "initiated");

        assertEquals(Status.SUCCESS, result.getStatus());
        assertEquals(PowerStatus.UNKNOWN, result.getPowerStatus());
    }

    /**
     * Test result value for failed stop action
     */
    @Test
    public void failedStop() {
        FenceOperationResult result = new FenceOperationResult(
                FenceActionType.STOP,
                1,
                null,
                null,
                "initiated");

        assertEquals(Status.ERROR, result.getStatus());
        assertEquals(PowerStatus.UNKNOWN, result.getPowerStatus());
    }

    /**
     * Test result value for skipped stop action due to fencing policy
     */
    @Test
    public void skippedDueToPolicyStop() {
        FenceOperationResult result = new FenceOperationResult(
                FenceActionType.STOP,
                0,
                null,
                null,
                "skipped");

        assertEquals(Status.SKIPPED_DUE_TO_POLICY, result.getStatus());
        assertEquals(PowerStatus.UNKNOWN, result.getPowerStatus());
    }
}


text:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.11"/>
<title>DashingPlatforms: Main Page</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>

<link href="doxygen.css" rel="stylesheet" type="text/css" />

DashingPlatforms
    1.0

Main Page

Classes

Files

DashingPlatforms Documentation

<address class="footer">
Generated by

 1.8.11
</address>


text:
A pure function is a function that always returns the same result when given the same arguments, without side effects.

Example:

```javascript
function double(x){
  return x * 2;
}
// Will always return 4 when x is 2.
// Will always return 8 when x is 4, etc...
```

```javascript
function randomise(y){
  return y * Math.random();
}
// Not a pure function because Math.random() always returns a different number.
```