Tutorial by Examples: sin

from scipy.sparse import csr_matrix A = csr_matrix([[1,0,2],[0,3,0]]) >>>A <2x3 sparse matrix of type '<type 'numpy.int64'>' with 3 stored elements in Compressed Sparse Row format> >>> A.todense() matrix([[1, 0, 2], [0, 3, 0]]) >>&g...
You can create an IEnumerable of Task by passing AddressOf AsyncMethod to the LINQ Select method and then start and wait all the results with Task.WhenAll If your method has parameters matching the previous LINQ chain call, they will be automatically mapped. Public Sub Main() Dim tasks = Enum...
Example: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title></title> </head> <body> <textarea id="content"></textarea> <input type="button" id="copy...
C++11 introduced core language and standard library support for moving an object. The idea is that when an object o is a temporary and one wants a logical copy, then its safe to just pilfer o's resources, such as a dynamically allocated buffer, leaving o logically empty but still destructible and co...
Suppose we want to count how many counties are there in Texas: var counties = dbContext.States.Single(s => s.Code == "tx").Counties.Count(); The query is correct, but inefficient. States.Single(…) loads a state from the database. Next, Counties loads all 254 counties with all of the...
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...
Android Studio can configure Kotlin automatically in an Android project. Install the plugin To install the Kotlin plugin, go to File > Settings > Editor > Plugins > Install JetBrains Plugin... > Kotlin > Install, then restart Android Studio when prompted. Configure a project Cr...
public class MyObject{ public DateTime? TestDate { get; set; } public Func<MyObject, bool> DateIsValid = myObject => myObject.TestDate.HasValue && myObject.TestDate > DateTime.Now; public void DoSomething(){ //We can do this: if(this.TestDate....
The "factory default" number of worksheets created in a new Excel workbook is generally set to three. Your VBA code can explicitly set the number of worksheets in a new workbook. '--- save the current Excel global setting With Application Dim oldSheetsCount As Integer oldSheets...
In many environments, you have access to a global console object that contains some basic methods for communicating with standard output devices. Most commonly, this will be the browser's JavaScript console (see Chrome, Firefox, Safari, and Edge for more information). // At its simplest, you can 'l...
Modules can be used to add new functions to existing Modules and Types. namespace FSharp.Collections module List = let pair item1 item2 = [ item1; item2 ] The new function can then be called as if it was an original member of List. open FSharp.Collections module Testing = le...
from struct import pack print(pack('I3c', 123, b'a', b'b', b'c')) # b'{\x00\x00\x00abc'
Download and install Xamarin Studio Community. Open Xamarin Studio. Click File → New → Solution. Click .NET → Console Project and choose C#. Click Next to proceed. Enter the Project Name and Browse... for a Location to Save and then click Create. The newly created project w...
For the example, lets say that we have a List of type String that contains four elements: "hello, ", "how ", "are ", "you?" The best way to iterate over each element is by using a for-each loop: public void printEachElement(List<String> list){ for...
Batch execution using java.sql.PreparedStatement allows you to execute a single DML statement with multiple sets of values for its parameters. This example demonstrates how to prepare an insert statement and use it to insert multiple rows in a batch. Connection connection = ...; // obtained earl...
Batch execution using java.sql.Statement allows you to execute multiple DML statements (update, insert, delete) at once. This is achieved by creating a single statement object, adding the statements to execute, and then execute the batch as one. Connection connection = ...; // obtained earlier c...
If you have a vector in polar form (direction & distance) you will want to convert it to a cartesian vector with a x and y component. For referance the screen coordinate system has directions as 0 deg points from left to right, 90 (PI/2) point down the screen, and so on in a clock wise direction...
Math.sin and Math.cos are cyclic with a period of 2*PI radians (360 deg) they output a wave with an amplitude of 2 in the range -1 to 1. Graph of sine and cosine function: (courtesy Wikipedia) They are both very handy for many types of periodic calculations, from creating sound waves, to animati...

Page 44 of 161