Tutorial by Examples: v

Variable tensors are used when the values require updating within a session. It is the type of tensor that would be used for the weights matrix when creating neural networks, since these values will be updated as the model is being trained. Declaring a variable tensor can be done using the tf.Varia...
A Bag/ultiset stores each object in the collection together with a count of occurrences. Extra methods on the interface allow multiple copies of an object to be added or removed at once. JDK analog is HashMap<T, Integer>, when values is count of copies this key. TypeGuavaApache Commons Collec...
This multimap allows duplicate key-value pairs. JDK analogs are HashMap<K, List>, HashMap<K, Set> and so on. Key's orderValue's orderDuplicateAnalog keyAnalog valueGuavaApacheEclipse (GS) CollectionsJDKnot definedInsertion-orderyesHashMapArrayListArrayListMultimapMultiValueMapFastListMu...
In PaaS sites such as Heroku, it is usual to receive the database information as a single URL environment variable, instead of several parameters (host, port, user, password...). There is a module, dj_database_url which automatically extracts the DATABASE_URL environment variable to a Python dictio...
When you create a function in TypeScript you can specify the data type of the function's arguments and the data type for the return value Example: function sum(x: number, y: number): number { return x + y; } Here the syntax x: number, y: number means that the function can accept two argum...
Example: function hello(name: string): string { return `Hello ${name}!`; } Here the syntax name: string means that the function can accept one name argument and this argument can only be string and (...): string { means that the return value can only be a string Usage: hello('StackOverfl...
In order to include plots created with matplotlib in TeX documents, they should be saved as pdf or eps files. In this way, any text in the plot (including TeX formulae) is rendered as text in the final document. import matplotlib.pyplot as plt plt.rc(usetex=True) x = range(0, 10) y = [t**2 for t...
Dart has a robust async library, with Future, Stream, and more. However, sometimes you might run into an asynchronous API that uses callbacks instead of Futures. To bridge the gap between callbacks and Futures, Dart offers the Completer class. You can use a Completer to convert a callback into a Fut...
The following example creates a canvas with 2 points and 1 line in between. You will be able to move the point and the line around. from kivy.app import App from kivy.graphics import Ellipse, Line from kivy.uix.boxlayout import BoxLayout class CustomLayout(BoxLayout): def __init__(se...
It's a VBA Best Practice to always specify which workbook your VBA code refers. If this specification is omitted, then VBA assumes the code is directed at the currently active workbook (ActiveWorkbook). '--- the currently active workbook (and worksheet) is implied Range("A1").value = 3.1...
If you want to access a workbook that's already open, then getting the assignment from the Workbooks collection is straightforward: dim myWB as Workbook Set myWB = Workbooks("UsuallyFullPathnameOfWorkbook.xlsx") If you want to create a new workbook, then use the Workbooks collection o...
Often saving new data in an existing workbook using VBA will cause a pop-up question noting that the file already exists. To prevent this pop-up question, you have to suppress these types of alerts. Application.DisplayAlerts = False 'disable user prompt to overwrite file myWB.SaveAs FileNa...
Stackage is a repository for Haskell packages. We can add these packages to a stack project. Adding lens to a project. In a stack project, there is a file called stack.yaml. In stack.yaml there is a segment that looks like: resolver: lts-6.8 Stackage keeps a list of packages for every revision...
Example uses of $(document).ready(): Attaching event handlers Attach jQuery event handlers $(document).ready(function() { $("button").click(function() { // Code for the click function }); }); Run jQuery code after the page structure is created jQuery(function($) ...
When building a webserver with Express it's often required to serve a combination of dynamic content and static files. For example, you may have index.html and script.js which are static files kept in the file system. It is common to use folder named 'public' to have static files. In this case th...
A basic example of HTTP server. write following code in http_server.js file: var http = require('http'); var httpPort = 80; http.createServer(handler).listen(httpPort, start_callback); function handler(req, res) { var clientIP = req.connection.remoteAddress; var connectUsi...
Production deployments will vary in many ways, but a standard convention when deploying in production is to define an environment variable called NODE_ENV and set its value to "production". Runtime flags Any code running in your application (including external modules) can check the valu...
NodeJS executes the module only the first time you require it. Any further require functions will re-use the same Object, thus not executing the code in the module another time. Also Node caches the modules first time they are loaded using require. This reduces the number of file reads and helps to...
The following example shows how to merge two arrays into one associative array, where the key values will be the items of the first array, and the values will be from the second: $array_one = ['key1', 'key2', 'key3']; $array_two = ['value1', 'value2', 'value3']; $array_three = array_combine($ar...
If you want to hide a keyboard by tap outside of it, it's possible to use this hacky trick (works only with Objective-C): - (void)viewDidLoad { [super viewDidLoad]; // dismiss keyboard when tap outside a text field UITapGestureRecognizer *tapGestureRecognizer = [[UITapGestureRecogn...

Page 79 of 296