text:
/**
 * MobileServicePush.java
 */
package com.microsoft.windowsazure.mobileservices.notifications;

import android.content.Context;
import android.net.Uri;
import android.util.Pair;

import com.google.common.util.concurrent.FutureCallback;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.SettableFuture;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.microsoft.windowsazure.mobileservices.MobileServiceApplication;
import com.microsoft.windowsazure.mobileservices.MobileServiceClient;
import com.microsoft.windowsazure.mobileservices.MobileServiceFeatures;
import com.microsoft.windowsazure.mobileservices.http.HttpConstants;
import com.microsoft.windowsazure.mobileservices.http.MobileServiceConnection;
import com.microsoft.windowsazure.mobileservices.http.MobileServiceHttpClient;
import com.microsoft.windowsazure.mobileservices.http.ServiceFilterResponse;

import java.util.ArrayList;
import java.util.EnumSet;
import java.util.List;
import java.util.Map;

/**
 * MobileServicePush instance facilitates creation/deletion of notification registrations
 */
public class MobileServicePush {

    /**
     * Push registration path
     */
    private static final String PNS_API_URL = "push";

    /**
     * The class used to make HTTP clients associated with this instance
     */
    private MobileServiceHttpClient mHttpClient;

    /**
     * Creates a new NotificationHub client
     *
     * @param client  The MobileServiceClient used to invoke the push operations
     * @param context Android context used to access SharedPreferences
     */
    public MobileServicePush(MobileServiceClient client, Context context) {

        mHttpClient = new MobileServiceHttpClient(client);

        if (context == null) {
            throw new IllegalArgumentException("context");
        }
    }

    private static boolean isNullOrWhiteSpace(String str) {
        return str == null || str.trim().equals("");
    }

    /**
     * Registers the client for native notifications
     *
     * @param pnsHandle PNS specific identifier
     * @return Future with Registration Information
     */
    public ListenableFuture<Void> register(String pnsHandle) {
        return register(pnsHandle, (JsonObject) null);
    }

    /**
     * Registers the client for template notifications
     *
     * @param pnsHandle PNS specific identifier
     * @param templates Template to be used for registration
     * @return Future with TemplateRegistration Information
     */
    public ListenableFuture<Void> register(String pnsHandle, JsonObject templates) {

        final SettableFuture<Void> resultFuture = SettableFuture.create();

        if (isNullOrWhiteSpace(pnsHandle)) {
            resultFuture.setException(new IllegalArgumentException("pnsHandle"));
            return resultFuture;
        }

        if (templates != null) {
            for (Map.Entry<String, JsonElement> entry : templates.entrySet()) {
                if (entry.getValue() != null && entry.getValue().isJsonObject()) {
                    JsonObject template = entry.getValue().getAsJsonObject();
                    if (template.get("body") != null && template.get("body").isJsonObject()) {
                        JsonObject templateBody = template.get("body").getAsJsonObject();
                        template.addProperty("body", templateBody.toString());
                    }
                }
            }
        }

        ListenableFuture<Void> registerInternalFuture = createOrUpdateInstallation(pnsHandle, templates);

        Futures.addCallback(registerInternalFuture, new FutureCallback<Void>() {
            @Override
            public void onFailure(Throwable exception) {
                resultFuture.setException(exception);
            }

            @Override
            public void onSuccess(Void v) {
                resultFuture.set(v);
            }
        });

        return resultFuture;
    }

    /**
     * Registers the client for native notifications
     *
     * @param pnsHandle PNS specific identifier
     * @param callback  The callback to invoke after the Push
     * @deprecated use {@link #register(String pnsHandle)} instead
     */
    public void register(String pnsHandle, final RegistrationCallback callback) {
        ListenableFuture<Void> registerFuture = register(pnsHandle);

        Futures.addCallback(registerFuture, new FutureCallback<Void>() {
            @Override
            public void onFailure(Throwable exception) {
                if (exception instanceof Exception) {
                    callback.onRegister((Exception) exception);
                }
            }

            @Override
            public void onSuccess(Void v) {
                callback.onRegister(null);
            }
        });
    }

    /**
     * Registers the client for template notifications
     *
     * @param pnsHandle    PNS specific identifier
     * @param templateName The template name
     * @param templateBody The template body
     * @return Future with TemplateRegistration Information
     */
    public ListenableFuture<Void> registerTemplate(String pnsHandle, String templateName, String templateBody) {

        final SettableFuture<Void> resultFuture = SettableFuture.create();

        if (isNullOrWhiteSpace(pnsHandle)) {
            resultFuture.setException(new IllegalArgumentException("pnsHandle"));
            return resultFuture;
        }

        if (isNullOrWhiteSpace(templateName)) {
            resultFuture.setException(new IllegalArgumentException("templateName"));
            return resultFuture;
        }

        if (isNullOrWhiteSpace(templateBody)) {
            resultFuture.setException(new IllegalArgumentException("body"));
            return resultFuture;
        }

        JsonObject templateObject = GetTemplateObject(templateName, templateBody);

        ListenableFuture<Void> registerInternalFuture = createOrUpdateInstallation(pnsHandle, templateObject);

        Futures.addCallback(registerInternalFuture, new FutureCallback<Void>() {
            @Override
            public void onFailure(Throwable exception) {
                resultFuture.setException(exception);
            }

            @Override
            public void onSuccess(Void v) {
                resultFuture.set(v);
            }
        });

        return resultFuture;
    }

    private JsonObject GetTemplateObject(String templateName, String templateBody) {
        JsonObject templateDetailObject = new JsonObject();
        templateDetailObject.addProperty("body", templateBody);

        JsonObject templateObject = new JsonObject();
        templateObject.add(templateName, templateDetailObject);

        return templateObject;
    }

    /**
     * Registers the client for template notifications
     *
     * @param pnsHandle    PNS specific identifier
     * @param templateName The template name
     * @param template     The template body
     * @param callback     The operation callback
     * @deprecated use {@link #registerTemplate(String pnsHandle, String templateName, String template)} instead
     */
    public void registerTemplate(String pnsHandle, String templateName, String template, final RegistrationCallback callback) {
        ListenableFuture<Void> registerFuture = registerTemplate(pnsHandle, templateName, template);

        Futures.addCallback(registerFuture, new FutureCallback<Void>() {
            @Override
            public void onFailure(Throwable exception) {
                if (exception instanceof Exception) {
                    callback.onRegister((Exception) exception);
                }
            }

            @Override
            public void onSuccess(Void v) {
                callback.onRegister(null);
            }
        });
    }

    /**
     * Unregisters the client for native notifications
     *
     * @return Future with TemplateRegistration Information
     */
    public ListenableFuture<Void> unregister() {
        return deleteInstallation();
    }

    /**
     * Unregisters the client for native notifications
     *
     * @param callback The operation callback
     * @deprecated use {@link #unregister()} instead
     */
    public void unregister(final UnregisterCallback callback) {
        ListenableFuture<Void> deleteInstallationFuture = deleteInstallation();

        Futures.addCallback(deleteInstallationFuture, new FutureCallback<Void>() {
            @Override
            public void onFailure(Throwable exception) {
                if (exception instanceof Exception) {
                    callback.onUnregister((Exception) exception);
                }
            }

            @Override
            public void onSuccess(Void v) {
                callback.onUnregister(null);
            }
        });
    }

    private ListenableFuture<Void> deleteInstallation() {
        final SettableFuture<Void> resultFuture = SettableFuture.create();

        String installationId = MobileServiceApplication.getInstallationId(mHttpClient.getClient().getContext());

        String path = PNS_API_URL + "/installations/" + Uri.encode(installationId);

        ListenableFuture<ServiceFilterResponse> serviceFilterFuture = mHttpClient.request(path, null, HttpConstants.DeleteMethod, null, null);

        Futures.addCallback(serviceFilterFuture, new FutureCallback<ServiceFilterResponse>() {
            @Override
            public void onFailure(Throwable exception) {
                resultFuture.setException(exception);
            }

            @Override
            public void onSuccess(ServiceFilterResponse response) {

                resultFuture.set(null);
            }
        });

        return resultFuture;
    }

    private ListenableFuture<Void> createOrUpdateInstallation(String pnsHandle) {
        return createOrUpdateInstallation(pnsHandle, null);
    }

    private ListenableFuture<Void> createOrUpdateInstallation(String pnsHandle, JsonElement templates) {
        JsonObject installation = new JsonObject();
        installation.addProperty("pushChannel", pnsHandle);
        installation.addProperty("platform", "gcm");

        if (templates != null) {
            installation.add("templates", templates);
        }

        final SettableFuture<Void> resultFuture = SettableFuture.create();

        String installationId = MobileServiceApplication.getInstallationId(mHttpClient.getClient().getContext());

        String path = PNS_API_URL + "/installations/" + Uri.encode(installationId);

        List<Pair<String, String>> requestHeaders = new ArrayList<Pair<String, String>>();

        requestHeaders.add(new Pair<>(HttpConstants.ContentType, MobileServiceConnection.JSON_CONTENTTYPE));

        ListenableFuture<ServiceFilterResponse> serviceFilterFuture = mHttpClient.request(path, installation.toString(), HttpConstants.PutMethod, requestHeaders, null, EnumSet.noneOf(MobileServiceFeatures.class));

        Futures.addCallback(serviceFilterFuture, new FutureCallback<ServiceFilterResponse>() {
            @Override
            public void onFailure(Throwable exception) {

                resultFuture.setException(exception);
            }

            @Override
            public void onSuccess(ServiceFilterResponse response) {

                resultFuture.set(null);
            }
        });

        return resultFuture;
    }

}


text:
/**
 *
 * Created by thrawn on 17/01/16.
 */

import React, { Component } from 'react';
import {
  Button,
  ListGroup,
  ListGroupItem,
  Image,
  Input,
  Grid,
  Row,
  Col,
  PageHeader,
  Panel,
  Navbar,
  Nav,
  Fade
} from 'react-bootstrap';

import { login } from '../actions';

class Login extends Component {
  constructor(props) {
    super(props);
    this.state = { showAlert: false };
    this.handleSubmit = this.handleSubmit.bind(this);
  }
  componentWillReceiveProps() {
    clearTimeout(this.timeout);
    this.timeout = setTimeout(() => {this.setState({ showAlert: false })}, 5000);
  }
  componentWillUnmount() {
    clearTimeout(this.timeout)
  }
  handleSubmit(e) {
    e.preventDefault();
    this.setState({ showAlert: true });
    const email = this.refs.email.getInputDOMNode().value;
    const password = this.refs.password.getInputDOMNode().value;
    this.props.dispatch(login(email, password, location.pathname))
  }
  render() {
    return (
      <form onSubmit={this.handleSubmit}>
        <Navbar.Form pullRight>
            <Input type="text" ref="email" placeholder="email" />{' '}
            <Input type="password" ref="password" placeholder="password" />{' '}
            <Button type="submit">Login</Button>
        </Navbar.Form>
        <Fade in={this.state.showAlert}>
          <Navbar.Text pullRight>
            {this.props.statusText}
          </Navbar.Text>
        </Fade>
      </form>
    );
  }
}

Login.propTypes = {};

export default Login;

redpajama_set_name: RedPajamaGithub


text:
package api

import (
	"bytes"
	"encoding/json"
	"net/http"
	"net/http/httptest"
	"testing"

	"github.com/brocaar/lora-app-server/internal/handler"
	"github.com/brocaar/lora-app-server/internal/test/testhandler"

	"github.com/brocaar/lora-app-server/internal/common"
	"github.com/brocaar/lora-app-server/internal/storage"
	"github.com/brocaar/lora-app-server/internal/test"
	"github.com/brocaar/lorawan"
	"github.com/brocaar/lorawan/backend"
	. "github.com/smartystreets/goconvey/convey"
)

func TestJoinServerAPI(t *testing.T) {
	conf := test.GetConfig()
	db, err := storage.OpenDatabase(conf.PostgresDSN)
	if err != nil {
		t.Fatal(err)
	}
	common.DB = db

	Convey("Given a clean database with a device", t, func() {
		test.MustResetDB(common.DB)

		nsClient := test.NewNetworkServerClient()
		common.NetworkServerPool = test.NewNetworkServerPool(nsClient)

		h := testhandler.NewTestHandler()
		common.Handler = h

		org := storage.Organization{
			Name: "test-org",
		}
		So(storage.CreateOrganization(common.DB, &org), ShouldBeNil)

		n := storage.NetworkServer{
			Name:   "test-ns",
			Server: "test-ns:1234",
		}
		So(storage.CreateNetworkServer(common.DB, &n), ShouldBeNil)

		sp := storage.ServiceProfile{
			OrganizationID:  org.ID,
			NetworkServerID: n.ID,
			Name:            "test-sp",
			ServiceProfile:  backend.ServiceProfile{},
		}
		So(storage.CreateServiceProfile(common.DB, &sp), ShouldBeNil)

		dp := storage.DeviceProfile{
			OrganizationID:  org.ID,
			NetworkServerID: n.ID,
			Name:            "test-dp",
			DeviceProfile:   backend.DeviceProfile{},
		}
		So(storage.CreateDeviceProfile(common.DB, &dp), ShouldBeNil)

		app := storage.Application{
			OrganizationID:   org.ID,
			ServiceProfileID: sp.ServiceProfile.ServiceProfileID,
			Name:             "test-app",
		}
		So(storage.CreateApplication(common.DB, &app), ShouldBeNil)

		d := storage.Device{
			ApplicationID:   app.ID,
			Name:            "test-device",
			DevEUI:          lorawan.EUI64{1, 2, 3, 4, 5, 6, 7, 8},
			DeviceProfileID: dp.DeviceProfile.DeviceProfileID,
		}
		So(storage.CreateDevice(common.DB, &d), ShouldBeNil)

		dk := storage.DeviceKeys{
			DevEUI: d.DevEUI,
			AppKey: lorawan.AES128Key{1, 2, 3, 4, 5, 6, 7, 8, 1, 2, 3, 4, 5, 6, 7, 8},
		}
		So(storage.CreateDeviceKeys(common.DB, &dk), ShouldBeNil)

		Convey("Given a test-server", func() {
			api := JoinServerAPI{}
			server := httptest.NewServer(&api)
			defer server.Close()

			Convey("When making a JoinReq call", func() {
				jrPHY := lorawan.PHYPayload{
					MHDR: lorawan.MHDR{
						MType: lorawan.JoinRequest,
						Major: lorawan.LoRaWANR1,
					},
					MACPayload: &lorawan.JoinRequestPayload{
						DevEUI:   d.DevEUI,
						AppEUI:   lorawan.EUI64{8, 7, 6, 5, 4, 3, 2, 1},
						DevNonce: lorawan.DevNonce{1, 2},
					},
				}
				So(jrPHY.SetMIC(dk.AppKey), ShouldBeNil)
				jrPHYBytes, err := jrPHY.MarshalBinary()
				So(err, ShouldBeNil)

				jaPHY := lorawan.PHYPayload{
					MHDR: lorawan.MHDR{
						MType: lorawan.JoinAccept,
						Major: lorawan.LoRaWANR1,
					},
					MACPayload: &lorawan.JoinAcceptPayload{
						AppNonce: lorawan.AppNonce{1, 0, 0},
						NetID:    lorawan.NetID{1, 2, 3},
						DevAddr:  lorawan.DevAddr{1, 2, 3, 4},
						DLSettings: lorawan.DLSettings{
							RX2DataRate: 5,
							RX1DROffset: 1,
						},
						RXDelay: 1,
						CFList:  &lorawan.CFList{868700000, 868900000},
					},
				}
				So(jaPHY.SetMIC(dk.AppKey), ShouldBeNil)
				So(jaPHY.EncryptJoinAcceptPayload(dk.AppKey), ShouldBeNil)
				jaPHYBytes, err := jaPHY.MarshalBinary()
				So(err, ShouldBeNil)

				joinReqPayload := backend.JoinReqPayload{
					BasePayload: backend.BasePayload{
						ProtocolVersion: backend.ProtocolVersion1_0,
						SenderID:        "010203",
						ReceiverID:      "0807060504030201",
						TransactionID:   1234,
						MessageType:     backend.JoinReq,
					},
					MACVersion: "1.0.2",
					PHYPayload: backend.HEXBytes(jrPHYBytes),
					DevEUI:     d.DevEUI,
					DevAddr:    lorawan.DevAddr{1, 2, 3, 4},
					DLSettings: lorawan.DLSettings{
						RX2DataRate: 5,
						RX1DROffset: 1,
					},
					RxDelay: 1,
					CFList:  &lorawan.CFList{868700000, 868900000},
				}
				joinReqPayloadJSON, err := json.Marshal(joinReqPayload)
				So(err, ShouldBeNil)

				req, err := http.NewRequest("POST", server.URL, bytes.NewReader(joinReqPayloadJSON))
				So(err, ShouldBeNil)

				resp, err := http.DefaultClient.Do(req)
				So(err, ShouldBeNil)
				So(resp.StatusCode, ShouldEqual, http.StatusOK)

				Convey("Then the expected response is returned", func() {
					var joinAnsPayload backend.JoinAnsPayload
					So(json.NewDecoder(resp.Body).Decode(&joinAnsPayload), ShouldBeNil)
					So(joinAnsPayload, ShouldResemble, backend.JoinAnsPayload{
						BasePayload: backend.BasePayload{
							ProtocolVersion: backend.ProtocolVersion1_0,
							SenderID:        "0807060504030201",
							ReceiverID:      "010203",
							TransactionID:   1234,
							MessageType:     backend.JoinAns,
						},
						Result: backend.Result{
							ResultCode: backend.Success,
						},
						PHYPayload: backend.HEXBytes(jaPHYBytes),
						NwkSKey: &backend.KeyEnvelope{
							AESKey: lorawan.AES128Key{223, 83, 195, 95, 48, 52, 204, 206, 208, 255, 53, 76, 112, 222, 4, 223},
						},
					})
				})

				Convey("Then a join notification was sent", func() {
					So(h.SendJoinNotificationChan, ShouldHaveLength, 1)
					So(<-h.SendJoinNotificationChan, ShouldResemble, handler.JoinNotification{
						ApplicationID:   app.ID,
						ApplicationName: app.Name,
						DeviceName:      d.Name,
						DevEUI:          d.DevEUI,
						DevAddr:         lorawan.DevAddr{1, 2, 3, 4},
					})
				})
			})
		})
	})
}


text:
<TITLE>Review for Beloved (1998)</TITLE>
<LINK REL="STYLESHEET" TYPE="text/css" HREF="/ramr.css">

Beloved (1998)

reviewed by
Craig Roush

BELOVED

** (out of 4) - a fair movie

Release Date: October 16, 1998
Starring: Oprah Winfrey, Danny Glover, Thandie Newton, Kimberly Elise,
Beah Richards
Directed by: Jonathan Demme
Distributed by: Buena Vista Pictures
MPAA Rating: R (violent images, sexuality, nudity)
URL: http://www.execpc.com/~kinnopio/reviews/1998/beloved.htm

It's possible to classify cinema based on literature as an entirely
seperate genre aside from action, comedy, drama, and the usual
categories. Those movies which are based on books are almost always a
testament to their source - the author wrote such a visually or mentally
outstanding novel that it begged to be brought to life on the screen -
but as cinema alone they are often disappointing ventures. The most
disappointing transplant within the last few years was James Patterson's
KISS THE GIRLS: although the novel was tense and a very exciting read,
the movie was lackluster and far from noteworthy. The latest product of
this movement, Toni Morrison's BELOVED, does not stoop to such levels,
but it is a rather disappointing movie.

With all of the talent involved - both in front of the camera, behind
it, and in the script - BELOVED was almost a surefire lock for the
Oscars in March of next year. (It still may harbor such chances, as both
the Academy and several signifcant film writers tend to prefer deep but
cinematically boring films for their ballots.) It's directed by Jonathan
Demme, who won an Academy Award for his direction in SILENCE OF THE
LAMBS. The script is written by Akosua Busia, who wrote the energetic
segregation tale ROSEWOOD, and it's is based on the Pulitzer
Prize-winning novel by Toni Morrison. Finally, the two top-billed
actors, Oprah Winfrey and Danny Glover, have respectable if not
excellent track records in Hollywood. For all of these ingredients, a
very engaging motion picture experience is surely not unreasonable.

The results are quite the opposite. BELOVED is a three-hour long movie
which lacks anything substantial to power it through such an unlikely
length. Demme and Busia have chosen faithfulness to the novel over basic
principles of filmmaking, and in doing so they deep-six any chances the
movie has for widespread appeal. Herein lies the story of Sethe
(Winfrey) an ex-slave living in post-Civil War Cincinnati. For her, the
year 1873 sees the arrival of friend from the past and soon-to-be-lover
Paul D (Glover). Although Sethe agrees with Paul D's presence in her
household, her daughter Denver (Kimberly Elise) does not. Not long after
Paul D comes to stay with Sethe and Denver do we see the entrance of
Beloved, a strange and sometimes horrific young woman who may or may not
be the reincarnation of a daughter Sethe once had. Sethe and Denver are
enchanted with her, but Paul D knows there's something not right and so
he departs for parts unknown while the plot escalates to its climax.

And the climax cannot come soon enough. Both 1997 and 1998 have seen the
advent of several movies which push the envelope in terms of running
time, and only those films which have some sort of continual motion will
survive at such an extended duration. Anything which takes the better
part of three hours cannot simply rely on solid acting or tidbits of
tension, as in BELOVED. For therein lies the chief reason for the
disappointing outcome of the movie: although Winfrey and Glover give
outstanding performances, there is nothing here that we haven't seen
between AMISTAD and ROSEWOOD - and those were certainly more watchable
films. The only thing that BELOVED has going for it are the hints of a
ghost story, which, sadly, are dropped without realization very early in
the movie. Although some viewers may find this an outstanding and very
memorable film, it is not a mainstream product; and in the end, that is
what mars what might have been a truly fine movie.

--
Craig Roush
kinnopio@execpc.com
--
Kinnopio's Movie Reviews
http://www.execpc.com/~kinnopio

The review above was posted to the
rec.arts.movies.reviews newsgroup (de.rec.film.kritiken for German reviews).

The Internet Movie Database accepts no responsibility for the contents of the
review and has no editorial control. Unless stated otherwise, the copyright
belongs to the author.

Please direct comments/criticisms of the review to relevant newsgroups.

Broken URLs inthe reviews are the responsibility of the author.

The formatting of the review is likely to differ from the original due
to ASCII to HTML conversion.

Related links: index of all rec.arts.movies.reviews reviews


text:
require([ "jquery", "lib/analytics/analytics" ], function($, Analytics) {

  "use strict";

  var analytics = new Analytics();
  if (window.lp.hasOwnProperty("tracking") && window.lp.tracking.hasOwnProperty("eVar12") && window.lp.tracking.eVar12 !== "dest essential information") {
    analytics.trackView();
  }

  // Set up Omniture event handlers

  var windowUnloadedFromSubmitClick = false;

  // If the user clicks anywhere else on the page, reset the click tracker
  $(document).on("click", function() {
    windowUnloadedFromSubmitClick = false;
  });

  // When the user clicks on the submit button, track that it's what
  // is causing the onbeforeunload event to fire (below)
  $(document).on("click", "button.cta-button-primary", function(e) {
    windowUnloadedFromSubmitClick = true;
    e.stopPropagation();
  });

  // Before redirection (which the WN widget does, it's not a form submit)
  // if the user clicked on the submit button, track click with Omniture
  window.onbeforeunload = function() {
    if (windowUnloadedFromSubmitClick) {
      window.s.events = "event42";
      window.s.t();
    }
  };
});


text:
package editor.run;

/**
 */
public abstract class AbstractRunConfig<T extends AbstractRunConfigParameters<T>> implements IRunConfig<T>
{
  private T _params;

  public AbstractRunConfig( T params )
  {
    _params = params;
  }

  // this if for reading from json
  protected AbstractRunConfig()
  {
  }

  @Override
  public T getParams()
  {
    return _params;
  }
  public void setParams( T params )
  {
    _params = params;
  }

  @Override
  public boolean equals( Object o )
  {
    if( this == o )
    {
      return true;
    }
    if( !(o instanceof AbstractRunConfig) )
    {
      return false;
    }

    AbstractRunConfig that = (AbstractRunConfig)o;

    return _params.equals( that._params );
  }

  @Override
  public int hashCode()
  {
    int result = _params.hashCode();
    result = 31 * result + _params.hashCode();
    return result;
  }
}


text:
<?hh //strict
class Server{
  public resource $Socket;
  public function __construct(public string $Address, public int $Port){
    $Socket = $this->Socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
    register_shutdown_function(function() use ($Socket){
      if(is_resource($Socket)) fclose($Socket);
    });
  }
  public function Close():void{
    fclose($this->Socket);
  }
  public async function Listen((function(resource):Awaitable<void>) $Callback):Awaitable<void>{
    if(!is_resource($this->Socket)){
      // It's closed...
      return ;
    }
    socket_bind($this->Socket, $this->Address, $this->Port);
    socket_listen($this->Socket, 100);
    $Handles = Vector{};
    while(is_resource($this->Socket)){
      try {
        $Handles->add($Callback(socket_accept($this->Socket))->getWaitHandle());
        if($Handles->count() === 2){
          await GenVectorWaitHandle::create($Handles);
          $Handles->clear();
        }
      } catch(Exception $e){} // Let the server run!
    }
  }
  public static async function OnResponse(resource $Socket, (function(string, resource):Awaitable<void>) $Callback):Awaitable<void>{
    while (is_resource($Socket) && !feof($Socket)){
      $select = await stream_await($Socket, STREAM_AWAIT_READ, 5);
      switch ($select) {
        case STREAM_AWAIT_READY:
          $Data = stream_get_contents($Socket);
          if(!is_bool($Data)){
            await $Callback($Data, $Socket);
          }
          break;
        case STREAM_AWAIT_CLOSED:
        return ;
        // Do nothing for timeouts
        default:
      }
    }
  }
  public async function ListenInCoop((function(resource):Awaitable<void>) $First, (function(Server):Awaitable<void>) $Second):Awaitable<void>{
    await GenArrayWaitHandle::create([$Second($this), $this->Listen($First)]);
  }
}


text:
import java.util.function.Supplier;

class Test {
  String str = ((Supplier<String>) () -> {
    String s = "";
    return s;
  }).g<caret>et();
}


text:
//
//  PlivoRest.h
//  PlivoEndpoint
//
//  Copyright (c) 2013 Plivo Inc. All rights reserved.
//  Use of this software is subject to the
//  terms mentioned here, http://plivo.com/terms/

@protocol PlivoRestDelegate<NSObject>

/* This delegate gets called on a successful response, along with the identifier of the API used.
 */
- (void)successWithResponse:(NSDictionary *)response andIdentifier:(NSString *)identifier;

- (void)failureWithError:(NSError *)error andIdentifier:(NSString *)identifier;

@end

@interface PlivoRest : NSObject

@property (nonatomic, assign) id delegate;
@property (readonly, copy) NSString *authID;

- (id)initWithAuthId:(NSString *)authID andAuthToken:(NSString *)authToken;

- (void)account;

- (void)accountUpdate:(NSDictionary *)params;

- (void)subaccountCreate:(NSDictionary *)params;

- (void)subaccount;
- (void)subaccount:(NSString *)subaccountID;

- (void)subaccountUpdate:(NSString *)subaccountID withParams:(NSDictionary *)params;

- (void)subaccountDelete:(NSString *)subaccountID;
- (void)subaccountDelete:(NSString *)subaccountID withParams:(NSDictionary *)params;

- (void)endpoint;
- (void)endpoint:(NSString *)endpointID;
- (void)endpoint:(NSString *)endpointID withParams:(NSDictionary *)params;

- (void)endpointCreate:(NSDictionary *)params;

- (void)endpointDelete:(NSString *)endpointID;
- (void)endpointDelete:(NSString *)endpointID withParams:(NSDictionary *)params;

- (void)endpointUpdate:(NSString *)endpointID withParams:(NSDictionary *)params;

- (void)application;
- (void)application:(NSString *)appID;

- (void)applicationCreate:(NSDictionary *)params;
- (void)applicationUpdate:(NSString *)appID withParams:(NSDictionary *)params;

- (void)applicationDelete:(NSString *)appID;

- (void)number;
- (void)number:(NSString *)number;

- (void)numberUpdate:(NSString *)number withParams:(NSDictionary *)params;

- (void)numberUnrent:(NSString *)number;
- (void)numberUnrent:(NSString *)number withParams:(NSDictionary *)params;

- (void)numberSearch:(NSString *)countryISO;
- (void)numberSearch:(NSString *)countryISO withParams:(NSDictionary *)params;

- (void)numberRent:(NSString *)groupID;
- (void)numberRent:(NSString *)groupID withParams:(NSDictionary *)params;

- (void)conference;
- (void)conference:(NSString *)conferenceName;

- (void)conferenceHangup;
- (void)conferenceHangup:(NSString *)conferenceName;

- (void)conferenceHangupMember:(NSString *)conferenceName andMemberID:(NSString *)memberID;
- (void)conferenceKickMember:(NSString *)conferenceName andMemberID:(NSString *)memberID;
- (void)conferenceMuteMember:(NSString *)conferenceName andMemberID:(NSString *)memberID;

- (void)conferenceUnmuteMember:(NSString *)conferenceName andMemberID:(NSString *)memberID;
- (void)conferencePlaySound:(NSString *)conferenceName andMemberID:(NSString *)memberID withParams:(NSDictionary *)params;
- (void)conferenceStopSound:(NSString *)conferenceName andMemberID:(NSString *)memberID;

- (void)conferencePlaySpeak:(NSString *)conferenceName andMemberID:(NSString *)memberID andText:(NSString *)text withParams:(NSDictionary *)params;
- (void)conferenceStopSpeak:(NSString *)conferenceName andMemberID:(NSString *)memberID;

- (void)conferenceDeafMember:(NSString *)conferenceName andMemberID:(NSString *)memberID;
- (void)conferenceUndeafMember:(NSString *)conferenceName andMemberID:(NSString *)memberID;

- (void)conferenceRecordStart:(NSString *)conferenceName;
- (void)conferenceRecordStart:(NSString *)conferenceName withParams:(NSDictionary *)params;

- (void)conferenceRecordStop:(NSString *)conferenceName;
- (void)conferenceRecordStop:(NSString *)conferenceName withParams:(NSDictionary *)params;

- (void)messageSend:(NSDictionary *)params;
- (void)messageDetails;
- (void)messageDetails:(NSString *)messageUUID;

- (void)recordings;
- (void)recordings:(NSDictionary *)params;

- (void)recording:(NSString *)recordingID;
- (void)recording:(NSString *)recordingID withParams:(NSDictionary *)params;

- (void)callOutbound:(NSDictionary *)params;

- (void)callDetails;
- (void)callDetails:(NSDictionary *)params;

- (void)callDetail:(NSString *)callUUID;
- (void)callDetail:(NSString *)callUUID withParams:(NSDictionary *)params;

- (void)callLiveDetails;

- (void)callLiveDetail:(NSString *)callUUID;

- (void)callHangup:(NSString *)callUUID;
- (void)callTransfer:(NSString *)callUUID;
- (void)callTransfer:(NSString *)callUUID withParams:(NSDictionary *)params;

- (void)callRecord:(NSString *)callUUID;
- (void)callRecord:(NSString *)callUUID withParams:(NSDictionary *)params;

- (void)callRecordStop:(NSString *)callUUID;
- (void)callRecordStop:(NSString *)callUUID withParams:(NSDictionary *)params;

- (void)callPlay:(NSString *)callUUID andUrl:(NSString *)url;
- (void)callPlay:(NSString *)callUUID andUrl:(NSString *)url withParams:(NSDictionary *)params;

- (void)callPlayStop:(NSString *)callUUID;
- (void)callPlayStop:(NSString *)callUUID withParams:(NSDictionary *)params;

- (void)callSpeak:(NSString *)callUUID andText:(NSString *)text;
- (void)callSpeak:(NSString *)callUUID andText:(NSString *)text withParams:(NSDictionary *)params;

- (void)callSpeakStop:(NSString *)callUUID;
- (void)callSpeakStop:(NSString *)callUUID withParams:(NSDictionary *)params;

- (void)dtmfSend:(NSString *)callUUID andDigits:(NSString *)digits;
- (void)dtmfSend:(NSString *)callUUID andDigits:(NSString *)digits withParams:(NSString *)params;

- (void)cancelRequest:(NSString *)requestUUID;
- (void)cancelRequest:(NSString *)requestUUID withParams:(NSString *)params;

@end


text:
module Diff.Display (packageChanges) where

import Data.Char (isDigit)
import qualified Data.Map as Map
import Text.PrettyPrint ((<+>), (<>))
import qualified Text.PrettyPrint as P

import qualified Elm.Compiler.Type as Type
import qualified Diff.Compare as D

packageChanges :: D.PackageChanges -> String
packageChanges pkgChanges@(D.PackageChanges added changed removed) =
    "This is a " ++ show (D.packageChangeMagnitude pkgChanges) ++ " change.\n\n"
    ++ showAdded
    ++ showRemoved
    ++ showChanged
  where
    showRemoved
        | null removed = ""
        | otherwise =
            "------ Removed modules - MAJOR ------\n"
            ++ concatMap ("\n    " ++) removed
            ++ "\n\n\n"

    showAdded
        | null added = ""
        | otherwise =
            "------ Added modules - MINOR ------\n"
            ++ concatMap ("\n    " ++) added
            ++ "\n\n\n"

    showChanged
        | Map.null changed = ""
        | otherwise =
            concatMap moduleChanges (Map.toList changed)

moduleChanges :: (String, D.ModuleChanges) -> String
moduleChanges (name, changes) =
    "------ Changes to module " ++ name ++ " - " ++ show magnitude ++ " ------"
    ++ display "Added" adtAdd aliasAdd valueAdd
    ++ display "Removed" adtRemove aliasRemove valueRemove
    ++ display "Changed" adtChange aliasChange valueChange
    ++ "\n\n\n"
  where
    magnitude =
        D.moduleChangeMagnitude changes

    (adtAdd, adtChange, adtRemove) =
        changesToDocs adtDoc (D.adtChanges changes)

    (aliasAdd, aliasChange, aliasRemove) =
        changesToDocs aliasDoc (D.aliasChanges changes)

    (valueAdd, valueChange, valueRemove) =
        changesToDocs valueDoc (D.valueChanges changes)

changesToDocs :: (k -> v -> P.Doc) -> D.Changes k v -> ([P.Doc], [P.Doc], [P.Doc])
changesToDocs toDoc (D.Changes added changed removed) =
    ( map indented (Map.toList added)
    , map diffed   (Map.toList changed)
    , map indented (Map.toList removed)
    )
  where
    indented (name, value) =
        P.text "        " <> toDoc name value

    diffed (name, (oldValue, newValue)) =
        P.vcat
        [ P.text "      - " <> toDoc name oldValue
        , P.text "      + " <> toDoc name newValue
        , P.text ""
        ]

display :: String -> [P.Doc] -> [P.Doc] -> [P.Doc] -> String
display categoryName adts aliases values
    | null (adts ++ aliases ++ values) = ""
    | otherwise =
        P.renderStyle (P.style { P.lineLength = 80 }) $
        P.vcat $
            P.text "" : P.text category : adts ++ aliases ++ values
    where
      category =
          "\n    " ++ categoryName ++ ":"

-- PRETTY PRINTING

adtDoc :: String -> ([String], Map.Map String [Type.Type]) -> P.Doc
adtDoc name (tvars, ctors) =
    P.hang setup 4 (P.sep (zipWith (<+>) separators ctorDocs))
  where
    setup =
        P.text "type" <+> P.text name <+> P.hsep (map P.text tvars)

    separators =
        map P.text ("=" : repeat "|")

    ctorDocs =
        map ctorDoc (Map.toList ctors)

    ctorDoc (ctor, tipes) =
        P.hsep (P.text ctor : map parenDoc tipes)

aliasDoc :: String -> ([String], Type.Type) -> P.Doc
aliasDoc name (tvars, tipe) =
    P.hang (setup <+> P.equals) 4 (typeDoc tipe)
  where
    setup =
        P.text "type" <+> P.text "alias" <+> P.text name <+> P.hsep (map P.text tvars)

valueDoc :: String -> Type.Type -> P.Doc
valueDoc name tipe =
    P.text name <+> P.colon <+> typeDoc tipe

parenDoc = generalTypeDoc True
typeDoc = generalTypeDoc False

generalTypeDoc :: Bool -> Type.Type -> P.Doc
generalTypeDoc parens tipe =
    case tipe of
      Type.Var x -> P.text x

      Type.Type name -> P.text name

      Type.Lambda t t' ->
          let (args, result) = collectLambdas [t] t'
          in
              (if parens then P.parens else id) $
              foldr arrow (typeDoc result) args

      Type.App t ts ->
          case t : ts of
            [ Type.Type name, tipe ]
              | name == "_List" ->
                  P.lbrack <> typeDoc tipe <> P.rbrack

            Type.Type name : types
              | take 6 name == "_Tuple" && all isDigit (drop 6 name) ->
                  P.parens (P.hsep (P.punctuate P.comma (map typeDoc types)))

            types ->
                (if parens then P.parens else id) $
                P.hsep (map parenDoc types)

      Type.Record fields maybeExt ->
          P.sep [ P.hang start 2 fieldDocs, P.rbrace ]
        where
          start =
              case maybeExt of
                Nothing -> P.lbrace
                Just ext -> P.lbrace <+> typeDoc ext <+> P.text "|"

          fieldDocs =
              P.sep (P.punctuate P.comma (map fieldDoc fields))

          fieldDoc (name, tipe) =
              P.text name <+> P.colon <+> typeDoc tipe

arrow :: Type.Type -> P.Doc -> P.Doc
arrow arg result =
    argDoc <+> P.text "->" <+> result
  where
    argDoc =
        case arg of
          Type.Lambda _ _ -> P.parens (typeDoc arg)
          _ -> typeDoc arg

collectLambdas :: [Type.Type] -> Type.Type -> ([Type.Type], Type.Type)
collectLambdas args result =
    case result of
      Type.Lambda t t' -> collectLambdas (t:args) t'
      _ -> (reverse args, result)


text:
cask "sunloginclient" do
  version "12.5.0.45236"
  sha256 "a7cfd675da269712f85b996283cd40bde9259ee1d227d37a51884984ea0b3ec7"

  url "https://down.oray.com/sunlogin/mac/SunloginClient#{version}.dmg"
  name "Sunlogin Client"
  name "向日葵个人版"
  desc "Remote desktop control and monitoring tool"
  homepage "https://sunlogin.oray.com/"

  livecheck do
    url "https://sunlogin.oray.com/zh_CN/download/download?id=89"
    strategy :header_match
    regex(/SunloginClient[._-]?(\d+(?:\.\d+)+)\.dmg/i)
  end

  pkg "SunloginClient.pkg"

  uninstall quit:      "com.oray.sunlogin.macclient",
            pkgutil:   "com.oray.sunlogin.macclient",
            launchctl: [
              "com.oray.sunlogin ()",
              "com.oray.sunlogin.agent",
              "com.oray.sunlogin.desktopagent",
              "com.oray.sunlogin.helper",
              "com.oray.sunlogin.service",
              "com.oray.sunlogin.startup",
            ]
end


text:
<?php

/* @var $this yii\web\View */

use yii\helpers\Html;

$this->title = 'About';
$this->params['breadcrumbs'][] = $this->title;
?>

David Cruz

Hobbies

Zombie

ipsum

reversus

cerebro

apocalypsi

Biography

				Zombie ipsum reversus ab viral inferno, nam rick grimes malum cerebro.
				De carne lumbering animata corpora quaeritis. Summus brains sit,
				morbo vel maleficia? De apocalypsi gorger omero undead survivor dictum mauris.
				Hi mindless mortuis soulless creaturas, imo evil stalking monstra adventus resi
				dentevil vultus comedat cerebella viventium. Qui animated corpse,
				cricket bat max brucks terribilem incessu zomby.

Share this site...


text:
package org.glob3.mobile.generated;
//
//  LayoutImageBuilder.cpp
//  G3MiOSSDK
//
//  Created by Diego Gomez Deck on 2/11/15.
//
//

//
//  LayoutImageBuilder.hpp
//  G3MiOSSDK
//
//  Created by Diego Gomez Deck on 2/11/15.
//
//

public abstract class LayoutImageBuilder extends AbstractImageBuilder
{

  protected static class ChildResult
  {
    public final IImage _image;
    public final String _imageName;
    public final String _error;

    public ChildResult(IImage image, String imageName)
    {
       _image = image;
       _imageName = imageName;
       _error = "";
    }

    public ChildResult(String error)
    {
       _image = null;
       _imageName = "";
       _error = error;
    }

    public void dispose()
    {
      if (_image != null)
         _image.dispose();
    }
  }

  protected static class ChildrenResult extends RCObject
  {
    private LayoutImageBuilder _layoutImageBuilder;
    private final G3MContext _context;
    private IImageBuilderListener _listener;
    private boolean _deleteListener;

    private int _childrenResultPendingCounter;

    public void dispose()
    {
      super.dispose();
    }

    public java.util.ArrayList<ChildResult> _childrenResult = new java.util.ArrayList<ChildResult>();

    public ChildrenResult(LayoutImageBuilder layoutImageBuilder, int childrenSize, G3MContext context, IImageBuilderListener listener, boolean deleteListener)
    {
       _layoutImageBuilder = layoutImageBuilder;
       _context = context;
       _listener = listener;
       _deleteListener = deleteListener;
      _childrenResultPendingCounter = childrenSize;
      for (int i = 0; i < childrenSize; i++)
      {
        _childrenResult.add(null); // make space for the result
      }
    }

    public final void childImageCreated(IImage image, String imageName, int childIndex)
    {
      if (_childrenResult.get(childIndex) != null)
      {
        throw new RuntimeException("Logic error");
      }

      _childrenResult.set(childIndex, new ChildResult(image, imageName));
      if (--_childrenResultPendingCounter == 0)
      {
        _layoutImageBuilder.doLayout(_context, _listener, _deleteListener, _childrenResult);
      }
    }

    public final void childError(String error, int childIndex)
    {
      if (_childrenResult.get(childIndex) != null)
      {
        throw new RuntimeException("Logic error");
      }

      _childrenResult.set(childIndex, new ChildResult(error));
      if (--_childrenResultPendingCounter == 0)
      {
        _layoutImageBuilder.doLayout(_context, _listener, _deleteListener, _childrenResult);
      }
    }
  }

  protected static class LayoutImageBuilderChildListener implements IImageBuilderListener
  {
    private ChildrenResult _childrenResult;
    private final int _childIndex;

    public LayoutImageBuilderChildListener(ChildrenResult childrenResult, int childIndex)
    {
       _childrenResult = childrenResult;
       _childIndex = childIndex;
      _childrenResult._retain();
    }

    public void dispose()
    {
      _childrenResult._release();
    }

    public final void imageCreated(IImage image, String imageName)
    {
      _childrenResult.childImageCreated(image, imageName, _childIndex);
    }

    public final void onError(String error)
    {
      _childrenResult.childError(error, _childIndex);
    }
  }

  protected java.util.ArrayList<IImageBuilder> _children = new java.util.ArrayList<IImageBuilder>();

  protected final int _margin;

  protected final float _borderWidth;
  protected final Color _borderColor ;

  protected final int _padding;

  protected final Color _backgroundColor ;
  protected final float _cornerRadius;

  protected final int _childrenSeparation;

  /*
   | margin
   |   border
   |     padding
   |       content
   */

  protected LayoutImageBuilder(java.util.ArrayList<IImageBuilder> children, int margin, float borderWidth, Color borderColor, int padding, Color backgroundColor, float cornerRadius, int childrenSeparation)
  {
     _children = children;
     _margin = margin;
     _borderWidth = borderWidth;
     _borderColor = new Color(borderColor);
     _padding = padding;
     _backgroundColor = new Color(backgroundColor);
     _cornerRadius = cornerRadius;
     _childrenSeparation = childrenSeparation;
  }

  protected LayoutImageBuilder(IImageBuilder child0, IImageBuilder child1, int margin, float borderWidth, Color borderColor, int padding, Color backgroundColor, float cornerRadius, int childrenSeparation)
  {
     _margin = margin;
     _borderWidth = borderWidth;
     _borderColor = new Color(borderColor);
     _padding = padding;
     _backgroundColor = new Color(backgroundColor);
     _cornerRadius = cornerRadius;
     _childrenSeparation = childrenSeparation;
    _children.add(child0);
    _children.add(child1);
  }

  protected abstract void doLayout(G3MContext context, IImageBuilderListener listener, boolean deleteListener, java.util.ArrayList<ChildResult> results);

  public void dispose()
  {
    final int childrenSize = _children.size();
    for (int i = 0; i < childrenSize; i++)
    {
      IImageBuilder child = _children.get(i);
      if (child != null)
         child.dispose();
    }
  }

  public final boolean isMutable()
  {
    //TODO: #warning TODO: make mutable if any children is
    return false;
  }

  public final void build(G3MContext context, IImageBuilderListener listener, boolean deleteListener)
  {
    final int childrenSize = _children.size();
    ChildrenResult childrenResult = new ChildrenResult(this, childrenSize, context, listener, deleteListener);
    for (int i = 0; i < childrenSize; i++)
    {
      IImageBuilder child = _children.get(i);

      child.build(context, new LayoutImageBuilderChildListener(childrenResult, i), true);
    }

    childrenResult._release();
  }

}


text:
layout: post
title:  "Risc-V Brasil"
categories: developers
link-telegram: https://t.me/riscvbr
---
Colaboração: Matheus Catarino (@kassane)


text:
package de.saviodimatteo.madnetsim.simulation;

import java.util.List;
import java.util.Vector;

import de.saviodimatteo.madnetsim.actors.AccessPoint;
import de.saviodimatteo.madnetsim.actors.Node;
import de.saviodimatteo.madnetsim.data.Content;
import de.saviodimatteo.madnetsim.data.Point;
import de.saviodimatteo.madnetsim.utils.Pair;

public class EventQueue{
	Vector<Event> iEventList;

	EventQueue() {
		iEventList = new Vector<Event>();
	}

	void add(Event aEvent) {
		add(aEvent,false); // Add always as late as possible: elements are always queued
	}
	void add(Event aEvent, boolean firstEvent) {
		int eventListSize = iEventList.size();
		int examinedElementPos = 0;
		boolean gotDataEvent = ( aEvent.getKind() == EEventKind.NODE_GOTDATA ? true : false );
		if (firstEvent) {
			while (examinedElementPos < eventListSize && iEventList.get(examinedElementPos).getTime() < aEvent.getTime()) {
				examinedElementPos++;
			}
		} else {
			while (examinedElementPos < eventListSize && iEventList.get(examinedElementPos).getTime() <= aEvent.getTime()) {
				if (gotDataEvent) {
					Event evt = iEventList.get(examinedElementPos);
					if (evt.getNode() == aEvent.getNode() &&
						evt.getKind() == EEventKind.NODE_REQ_EXPIRED) {
						if ( !(((Pair<Node,Object>)aEvent.getEventData()).snd instanceof List))
							System.out.println("T:" + Simulator.time + " Node: " + evt.getNode().getId() + " GOTDATA after DISCONNECTION! distance " + (aEvent.getTime() - evt.getTime()));
						else
							System.out.println("Was An AP LIST (Will be ignored)");
					}
				}
				examinedElementPos++;
			}
		}
		iEventList.add(examinedElementPos,aEvent);
	}

	public int getHeadTime() {
		if (iEventList.size() > 0)
			return iEventList.get(0).getTime();
		else
			return -1;
	}
	public Event pop() {
		if (iEventList.size() > 0) {
			Event evt = iEventList.remove(0);
			return evt;
		}
		return null;
	}

	public void print() {
		for (int k=0; k < iEventList.size(); k++) {
			Event e = iEventList.get(k);
			e.print();
			System.out.println();
		}
	}

	public int size() {
		return iEventList.size();
	}
	public Event get(int aIndex) {
		return iEventList.get(aIndex);
	}

	public boolean isNodeGotDataArleadyQueued(Node aNode) {
		boolean exists = false;
	    int eventListSize = this.size();
	    for (int ee=0; ee<eventListSize; ee++) {
	    	Event nodeEvent = this.get(ee);
	    	if (nodeEvent.getKind() == EEventKind.NODE_GOTDATA) {      // consider NODE_GOTDATA events only
		    	Pair<Node,Object> nodeEventParams = ((Pair<Node, Object>) nodeEvent.getEventData());
		    	Node node = nodeEventParams.fst;
		    	Object second = nodeEventParams.snd;
		    	if ( node == aNode &&                                  // related to that node
		    		second instanceof Pair &&                          // containing the data
		    		(((Pair<Object,Long>) second).fst instanceof AccessPoint)
		    	)
		    	{
		    		exists = true;
		    		break;
		    	}
	    	}
	    }
	    return exists;
	}
	public Event getNextNodeMoveEvent(Node aNode) {
		Event result = null;
		int eventListSize = this.size();
	    for (int ee=0; ee<eventListSize; ee++) {
	    	Event nodeEvent = this.get(ee);
	    	if (nodeEvent.getKind() == EEventKind.NODE_MOVE) {      // consider NODE_GOTDATA events only

	    		Node node = null;
		    	// Extract node from event data
		    	Object eventData = nodeEvent.getEventData();
		    	if (eventData instanceof Node) {
			    	node = (Node) eventData;
		    	} else if (eventData instanceof Pair) {
		    		Pair <Node, Point> nodePosition = (Pair<Node,Point>) eventData;
		    		node = nodePosition.fst;
		    	}
	    		if (node != null && node == aNode) {
	    			result = nodeEvent;
		    		break;
	    		}
	    	}
	    }
	    return result;
	}
	public boolean isNodeMoveArleadyQueued(Node aNode) {
		boolean exists = false;
	    int eventListSize = this.size();
	    for (int ee=0; ee<eventListSize; ee++) {
	    	Event nodeEvent = this.get(ee);
	    	if (nodeEvent.getKind() == EEventKind.NODE_MOVE) {      // consider NODE_GOTDATA events only
		    	Node node = null;

		    	// Extract node from event data
		    	Object eventData = nodeEvent.getEventData();
		    	if (eventData instanceof Node) {
			    	node = (Node) eventData;
		    	} else if (eventData instanceof Pair) {
		    		Pair <Node, Point> nodePosition = (Pair<Node,Point>) eventData;
		    		node = nodePosition.fst;
		    	}

		    	if ( node != null && node == aNode )                                  // related to that node
		    	{
		    		exists = true;
		    		break;
		    	}
	    	}
	    }
	    return exists;
	}
	public boolean isNodeConnectedArleadyQueued(Node aNode) {
		boolean exists = false;
	    int eventListSize = this.size();
	    for (int ee=0; ee<eventListSize; ee++) {
	    	Event nodeEvent = this.get(ee);
	    	if (nodeEvent.getKind() == EEventKind.NODE_CONNECTED) {      // consider NODE_GOTDATA events only
		    	Pair<Node,AccessPoint> nodeAp = (Pair<Node,AccessPoint>) nodeEvent.getEventData();
		    	Node node = nodeAp.fst;
		    	if ( node == aNode )                                  // related to that node
		    	{
		    		exists = true;
		    		break;
		    	}
	    	}
	    }
	    return exists;
	}

	public boolean isApGotDataScheduled(AccessPoint aAccessPoint, Content aApContent) {
		boolean exists = false;
	    int eventListSize = this.size();
	    for (int ee=0; ee<eventListSize; ee++) {
	    	Event nodeEvent = this.get(ee);
	    	if (nodeEvent.getKind() == EEventKind.AP_GOTDATA) {      // consider AP_GOTDATA events only
		    	Pair<AccessPoint,Content> apContent = (Pair<AccessPoint,Content>) nodeEvent.getEventData();
		    	if ( apContent.snd.getId().equals(aApContent.getId()) && apContent.fst == aAccessPoint)
		    	{
		    		exists = true;
		    		break;
		    	}
	    	}
	    }
	    return exists;
	}

	public int getNextConnectTime() {
		int result = -1;
		int eventListSize = this.size();
	    for (int ee=0; ee<eventListSize; ee++) {
	    	Event nodeEvent = this.get(ee);
	    	if (nodeEvent.getKind() == EEventKind.NODE_CONNECTED) {      // consider NODE_GOTDATA events only
		    	result = nodeEvent.getTime();
	    		break;
	    	}
	    }
	    return result;
	}

	public boolean isNodeRequestExpiryAreadyQueued(Node node) {
		boolean exists = false;
	    int eventListSize = this.size();
	    for (int ee=0; ee < eventListSize; ee++) {
	    	Event nodeEvent = this.get(ee);
	    	if (nodeEvent.getKind() == EEventKind.NODE_REQ_EXPIRED) {      // consider AP_GOTDATA events only
		    	if ( nodeEvent.getNode() == node )
		    	{
		    		exists = true;
		    		break;
		    	}
	    	}
	    }
	    return exists;
	}

	public boolean isNodeRequestAreadyQueued(Node node) {
		boolean exists = false;
	    int eventListSize = this.size();
	    for (int ee=0; ee < eventListSize; ee++) {
	    	Event nodeEvent = this.get(ee);
	    	if (nodeEvent.getKind() == EEventKind.NODE_REQ) {      // consider AP_GOTDATA events only
		    	if ( nodeEvent.getNode() == node )
		    	{
		    		exists = true;
		    		break;
		    	}
	    	}
	    }
	    return exists;
	}

	public Event getNextRequestExpiry(Node node) {
		Event result = null;
	    int eventListSize = this.size();
	    for (int ee=0; ee < eventListSize; ee++) {
	    	Event nodeEvent = this.get(ee);
	    	if (nodeEvent.getKind() == EEventKind.NODE_REQ_EXPIRED) {
		    	if ( nodeEvent.getNode() == node )
		    	{
		    		result = nodeEvent;
		    		break;
		    	}
	    	}
	    }
	    return result;
	}
}


text:
<?php

class base_render{

    var $pagedata = array();
    var $force_compile = 0;
    var $_tag_stack = array();
    private $_compiler;
    static $_vars = array();
    var $_files = array();
    var $_tpl_key_prefix = array();
    var $_ignore_pre_display = false;

    function __construct(&$app){
        $this->app = $app;
        $this->params = kernel::request()->request_params;
        $this->pagedata = &base_render::$_vars;
    }

    function display($tmpl_file, $app_id=null, $fetch=false, $is_theme=false){
        array_unshift($this->_files,$tmpl_file);
        $this->_vars = $this->pagedata;

        if($p = strpos($tmpl_file,':')){
            $object = kernel::service('tpl_source.'.substr($tmpl_file,0,$p));
            if($object){
                $tmpl_file_path = substr($tmpl_file,$p+1);
                $last_modified = $object->last_modified($tmpl_file_path);
            }
        }else{
            if(defined('CUSTOM_CORE_DIR') && file_exists(CUSTOM_CORE_DIR.'/'.($app_id?$app_id:$this->app->app_id).'/view/'.$tmpl_file)){
                 $tmpl_file = CUSTOM_CORE_DIR.'/'.($app_id?$app_id:$this->app->app_id).'/view/'.$tmpl_file;
            }else{
				 if (!$is_theme)
					$tmpl_file = realpath(APP_DIR.'/'.($app_id?$app_id:$this->app->app_id).'/view/'.$tmpl_file);
				 else
					$tmpl_file = realpath(THEME_DIR.'/'.$tmpl_file);
            }
            $last_modified = filemtime($tmpl_file);
        }

        if(!$last_modified){
            //无文件
        }

        $this->tmpl_cachekey('__temp_lang', kernel::get_lang());  //设置模版所属语言包
        $this->tmpl_cachekey('__temp_app_id', $app_id?$app_id:$this->app->app_id);
        $compile_id = $this->compile_id($tmpl_file);

        #if($this->force_compile || base_kvstore::instance('cache/template')->fetch($compile_id, $compile_code, $last_modified) === false){
        if($this->force_compile || !cachemgr::get($compile_id.$last_modified, $compile_code)){
            if($object){
                $compile_code = $this->_compiler()->compile($object->get_file_contents($tmpl_file_path));
            }else{
                $compile_code = $this->_compiler()->compile_file($tmpl_file);
            }
            if($compile_code!==false){
                #base_kvstore::instance('cache/template')->store($compile_id,$compile_code);
                cachemgr::co_start();
                cachemgr::set($compile_id.$last_modified, $compile_code, cachemgr::co_end());
            }
        }

        ob_start();
        eval('?>'.$compile_code);
        $content = ob_get_contents();
        ob_end_clean();
        array_shift($this->_files);

        $this->pre_display($content);

        if($fetch === true){
            return $content;
        }else{
            echo $content;
        }
    }

    public function pre_display(&$content)
    {
        if($this->_ignore_pre_display === false){
            foreach(kernel::serviceList('base_render_pre_display') AS $service){
                if(method_exists($service, 'pre_display')){
                    $service->pre_display($content);
                }
            }
        }
    }//End Function

    public function _compiler(){
        return $this->single('base_component_compiler');
    }

    private function single($classname){
        if(!isset($this->_object[$classname])){
            $this->_object[$classname] = new $classname($this);
        }
        return $this->_object[$classname];
    }

    function fetch($tmpl_file,$app_id=null,$is_theme=false){

        return $this->display($tmpl_file, $app_id, true, $is_theme);
    }

    public function tmpl_cachekey($key,$value){
        $this->_tpl_key_prefix[$key] = $value;
    }

    function &ui(){
        return $this->single('base_component_ui');
    }

    function _fetch_compile_include($app_id,$tmpl_file, $vars=null, $is_theme=false){
        $_tmp_pagedata = $this->pagedata;
        $_tmp_vars = $this->_vars;
        if(is_null($vars) || empty($vars)){
             $this->pagedata = $this->_vars;
        }else{
             $this->pagedata = (array)$vars;
        }
        $this->_ignore_pre_display = true;
        $include = $this->fetch($tmpl_file,$app_id,$is_theme);
        $this->_ignore_pre_display = false;     //todo: fetch include的模板时不需要执行pre_display过滤,主模板会最终执行一次
        $this->pagedata = $_tmp_pagedata;
        $this->_vars = $_tmp_vars;
        return $include;
    }

    function compile_id($path){
        ksort($this->_tpl_key_prefix);
        return md5($path.serialize($this->_tpl_key_prefix));
    }

}