Tutorial by Examples: v

Flash dispatches Events for most of its objects. One of the most basic event is ENTER_FRAME, which is dispatched (at the framerate of the SWF) on every display list object. import flash.display.Sprite; import flash.events.Event; var s:Sprite = new Sprite(); s.addEventListener(Event.ENTER_FRAME...
You can create your own events and dispatch them, by extending the Event class. import flash.events.Event; class MyEvent extends Event { var data: String; static public var MY_EVENT_TYPE = "my_event_my_event_code"; public function MyEvent(type: String, data: Str...
Template JS code Template.templateName.onCreated(function(){ this.subscribe('subsription1'); this.subscribe('subscription2'); }); Template HTML code <template name="templateName"> {{#if Template.subscriptionsReady }} //your actual view with data. it can ...
Concept Use an Event to synchronize the scheduling of multiple coroutines. Put simply, an event is like the gun shot at a running race: it lets the runners off the starting blocks. Example import asyncio # event trigger function def trigger(event): print('EVENT SET') event.set() #...
Defining our terms By array here we mean a Lua table used as a sequence. For example: -- Create a table to store the types of pets we like. local pets = {"dogs", "cats", "birds"} We're using this table as a sequence: a group of items keyed by integers. Many langua...
Given that the function has a proper prototype, integers are widened for calls to functions according to the rules of integer conversion, C11 6.3.1.3. 6.3.1.3 Signed and unsigned integers When a value with integer type is converted to another integer type other than _Bool, if the value can be r...
Pointer conversions to void* are implicit, but any other pointer conversion must be explicit. While the compiler allows an explicit conversion from any pointer-to-data type to any other pointer-to-data type, accessing an object through a wrongly typed pointer is erroneous and leads to undefined beh...
Customer[] customers = Customers.ToArray(); Purchase[] purchases = Purchases.ToArray(); var groupJoinQuery = from c in customers join p in purchases on c.ID equals p.CustomerID into custPurchases select new { CustName = c.Name, custPurchases }; ...
Streams of elements usually do not allow access to the index value of the current item. To iterate over an array or ArrayList while having access to indexes, use IntStream.range(start, endExclusive). String[] names = { "Jon", "Darin", "Bauke", "Hans", "M...
An interesting thing to note which may help optimize your applications is that primitives are actually also refcounted under the hood. Let's take a look at numbers; for all integers between -5 and 256, Python always reuses the same object: >>> import sys >>> sys.getrefcount(1) 7...
>>> import sys >>> a = object() >>> sys.getrefcount(a) 2 >>> b = a >>> sys.getrefcount(a) 3 >>> del b >>> sys.getrefcount(a) 2
Conversion operations change the type of input objects. AsEnumerable Returns the input typed as IEnumerable. Method Syntax // AsEnumerable int[] numbers = { 1, 2, 3, 4, 5 }; var nums = numbers.AsEnumerable(); // nums: static type is IEnumerable<int> Query Syntax // Not app...
<svg> element is the root element, or the canvas as we are drawing charts on it. SVG elements can be nested inside each other, and in this way, SVG shapes can be grouped together, meanwhile, all shapes nested inside an element will be positioned relative to its enclosing element. One thing...
When you bind a service to your application credentials become available through the VCAP_SERVICES environment variable. This environment variable contains JSON containing the credentials for all bound services. Example VCAP_SERVICES environment variable { "push-reappt": [ { ...
app.js angular.module('myApp', ['ui.router']) .controller('controllerOne', function() { this.message = 'Hello world from Controller One!'; }) .controller('controllerTwo', function() { this.message = 'Hello world from Controller Two!'; }) .controller('controllerThree', funct...
You can add your own validations adding new classes inheriting from ActiveModel::Validator or from ActiveModel::EachValidator. Both methods are similar but they work in a slightly different ways: ActiveModel::Validator and validates_with Implement the validate method which takes a record as an arg...
Date always have a different format, they can be parsed using a specific parse_dates function. This input.csv: 2016 06 10 20:30:00 foo 2016 07 11 19:45:30 bar 2013 10 12 4:30:00 foo Can be parsed like this : mydateparser = lambda x: pd.datetime.strptime(x, "%Y %m %d %H:%M:%S...
Navigator is React Native's default navigator. A Navigator component manages a stack of route objects, and provides methods for managing that stack. <Navigator ref={(navigator) => { this.navigator = navigator }} initialRoute={{ id: 'route1', title: 'Route 1' }} renderScene={this.ren...
One of the major benefit of Fourier Transform is its ability to inverse back in to the Time Domain without losing information. Let us consider the same Signal we used in the previous example: A1=10; % Amplitude 1 A2=10; % Amplitude 2 w1=2*pi*0.2; % Angular f...
Beware that numbers can accidentally be converted to strings or NaN (Not a Number). JavaScript is loosely typed. A variable can contain different data types, and a variable can change its data type: var x = "Hello"; // typeof x is a string x = 5; // changes typeof x to...

Page 66 of 296