Tutorial by Examples: ai

Sometimes developers write some code that desires access to stage, or Flash stage, to add listeners. It can work for the first time, then all of a sudden fail to work and produce the error 1009. The code in question can even be on the timeline, as it's the first initiative to add code there, and man...
You need to set who you are *before* creating any commit. That will allow commits to have the right author name and email associated to them. It has nothing to do with authentication when pushing to a remote repository (e.g. when pushing to a remote repository using your GitHub, BitBucket, or Gi...
Simple constraint: interface IRunnable { run(): void; } interface IRunner<T extends IRunnable> { runSafe(runnable: T): void; } More complex constraint: interface IRunnble<U> { run(): U; } interface IRunner<T extends IRunnable<U>, U> { runSafe...
This query will return all COLUMNS and their associated TABLES for a given column name. It is designed to show you what tables (unknown) contain a specified column (known) SELECT c.name AS ColName, t.name AS TableName FROM sys.columns c JOIN sys.tables t ON c.object_id = t.o...
Given a file file.txt with the following content: line 1 line 2 line 3 You can delete a line from file content with the d command. The pattern to match is surrounded with default / delimiter and the d command follows the pattern: sed '/line 2/d' file.txt The above command will output: l...
With TypeScript 1.8 it becomes possible for a type parameter constraint to reference type parameters from the same type parameter list. Previously this was an error. function assign<T extends U, U>(target: T, source: U): T { for (let id in source) { target[id] = source[id]; ...
let x = true match x with | true -> printfn "x is true" yields a warning C:\Program Files (x86)\Microsoft VS Code\Untitled-1(2,7): warning FS0025: Incomplete pattern matches on this expression. For example, the value 'false' may indicate a case not covered by the pattern(s). ...
If you have a string that contains Python literals, such as strings, floats etc, you can use ast.literal_eval to evaluate its value instead of eval. This has the added feature of allowing only certain syntax. >>> import ast >>> code = """(1, 2, {'foo': 'bar'})&quot...
To make a custom pipe available application wide, During application bootstrap, extending PLATFORM_PIPES. import { bootstrap } from '@angular/platform-browser-dynamic'; import { provide, PLATFORM_PIPES } from '@angular/core'; import { AppComponent } from './app.component'; import { MyPipe }...
CLP(FD) constraints are provided by all serious Prolog implementations. They allow us to reason about integers in a pure way. ?- X #= 1 + 2. X = 3. ?- 5 #= Y + 2. Y = 3.
CLP(FD) constraints are completely pure relations. They can be used in all directions for declarative integer arithmetic: ?- X #= 1+2. X = 3. ?- 3 #= Y+2. Y = 1.
This is the most basic version of a trait in Scala. trait Identifiable { def getIdentifier: String def printIndentification(): Unit = println(getIdentifier) } case class Puppy(id: String, name: String) extends Identifiable { def getIdentifier: String = s"$name has id $id" } ...
Commands have one input (STDIN) and two kinds of outputs, standard output (STDOUT) and standard error (STDERR). For example: STDIN root@server~# read Type some text here Standard input is used to provide input to a program. (Here we're using the read builtin to read a line from STDIN.) STDO...
import pandas as pd df = pd.DataFrame({'gender': ["male", "female","female"], 'id': [1, 2, 3] }) >>> df gender id 0 male 1 1 female 2 2 female 3 To encode the male to 0 and female to 1: df.loc[df["gender&quot...
Remove all characters except letters, digits and !#$%&'*+-=?^_`{|}~@.[]. var_dump(filter_var('[email protected]', FILTER_SANITIZE_EMAIL)); var_dump(filter_var("!#$%&'*+-=?^_`{|}~.[]@example.com", FILTER_SANITIZE_EMAIL)); var_dump(filter_var('john/@example.com', FILTER_SANITIZE_EM...
If IPython (or Jupyter) are installed, the debugger can be invoked using: import ipdb ipdb.set_trace() When reached, the code will exit and print: /home/usr/ook.py(3)<module>() 1 import ipdb 2 ipdb.set_trace() ----> 3 print("Hello world!") ipdb> Clea...
We can use the Service Container as a Dependency Injection Container by binding the creation process of objects with their dependencies in one point of the application Let's suppose that the creation of a PdfCreator needs two objects as dependencies; every time we need to build an instance of PdfCr...
TCO is only available in strict mode As always check browser and Javascript implementations for support of any language features, and as with any javascript feature or syntax, it may change in the future. It provides a way to optimise recursive and deeply nested function calls by eliminating the n...
Consider the following example assuming that you have a ';'-delimited CSV to load into your database. 1;max;male;manager;12-7-1985 2;jack;male;executive;21-8-1990 . . . 1000000;marta;female;accountant;15-6-1992 Create the table for insertion. CREATE TABLE `employee` ( `id` INT NOT NULL , ...
When using async await in loops, you might encounter some of these problems. If you just try to use await inside forEach, this will throw an Unexpected token error. (async() => { data = [1, 2, 3, 4, 5]; data.forEach(e => { const i = await somePromiseFn(e); console.log(i); }); ...

Page 10 of 47