Tutorial by Examples: is

You can create shallow copies of lists using slices. >>> l1 = [1,2,3] >>> l2 = l1[:] # Perform the shallow copy. >>> l2 [1,2,3] >>> l1 is l2 False
UITextView has extra paddings by default. Sometimes it's annoying especially if you want to measure some text without view instance and place them at some area precisely. Do this to remove such paddings. messageTextView.textContainerInset = UIEdgeInsetsZero messageTextView.textContainer.lineFragm...
Anonymous class listener Before Java 8, it’s very common that an anonymous class is used to handle click event of a JButton, as shown in the following code. This example shows how to implement an anonymous listener within the scope of btn.addActionListener. JButton btn = new JButton("My Butto...
add_action( 'pre_get_posts', 'single_category_exclude' ); function single_category_exclude( $query ) { if( !$query->is_main_query() || is_admin() ) return; $query->set( 'cat', '-1' ); return; }
Let's say you need to check if an email address appears in a long list of email addresses. Use the MATCH function to return the row number on which the email address can be found. If there is no match, the function returns an #N/A error. =MATCH(F2,$D$2:$D$200,0) The value you're retrieving ...
$q is a built-in service which helps in executing asynchronous functions and using their return values(or exception) when they are finished with processing. $q is integrated with the $rootScope.Scope model observation mechanism, which means faster propagation of resolution or rejection into your m...
In Insert mode, press <C-r> and then % to insert the filename. This technique is applicable to all registers. For e.g. if in insert mode, you want to paste the current search pattern, you can type <C-r> and then /.
It is good practice to combine JS files together and minify them. For larger project there could be hundreds of JS files and it adds unnecessary latency to load each file separately from the server. For angular minification it is required to to have all functions annotated. That in necessary for An...
Sometimes it's useful to be able to extend a class with new functions. For example let's suppose that a string should be converted to a camel case string. So we need to tell TypeScript, that String contains a function called toCamelCase, which returns a string. interface String { toCamelCase()...
console.dir(object) displays an interactive list of the properties of the specified JavaScript object. The output is presented as a hierarchical listing with disclosure triangles that let you see the contents of child objects. var myObject = { "foo":{ "bar":"d...
Server Syntax var io = require('socket.io')(80); io.on('connection', function (mysocket) { //custom event called `private message` mysocket.on('private message', function (from, msg) { console.log('I received a private message by ', from, ' saying ', msg); }); //internal `di...
$conn = sqlsrv_connect($dbServer, $connectionInfo); $query = "SELECT * FROM [users] WHERE [name] = ? AND [password] = ?"; $params = array("joebloggs", "pa55w0rd"); $stmt = sqlsrv_query($conn, $query, $params); If you plan on using the same query statement more...
Go to the project.json directory and publish: dotnet publish It will print the output directory of the operation, enter the directory and run the published project: dotnet <project output>.dll The default folder will be: <project root>/bin/<configuration>/<target framewo...
Prolog tries alternative clauses for a predicate in the order of appearance: likes(alice, music). likes(bob, hiking). // Either alice likes music, or bob likes hiking will succeed. The disjunction (OR) operator ; can be used to express this in one rule: likes(P,Q) :- ( P = alice , Q = ...
We can always use ListView or RecyclerView for selection from list of items, but if we have small amount of choices and among those choices we want user to select one, we can use AlertDialog.Builder setAdapter. private void showDialog() { AlertDialog.Builder builder = new AlertDia...
When this program #include <stdio.h> #include <string.h> int main(void) { int num = 0; char str[128], *lf; scanf("%d", &num); fgets(str, sizeof(str), stdin); if ((lf = strchr(str, '\n')) != NULL) *lf = '\0'; printf("%d \"%s\&...
Say you want to add a foreign key company_id to the users table, and you want to have a NOT NULL constraint on it. If you already have data in users, you will have to do this in multiple steps. class AddCompanyIdToUsers < ActiveRecord::Migration def up # add the column with NULL allowed ...
POSIX stands for "Portable Operating System Interface" and defines a set of standards to provide compatibility between different computing platforms. The current version of the standard is IEEE 1003.1 2016 and can be accessed from the OpenGroup POSIX specification. Previous versions incl...
When deploying RethinkDB in production, you want to either turn off or lock down the WebUI. This will only respond to localhost to access the WebUI allowing you to SSH Tunnel to the host machine and access it for diagnostics and troubleshooting. docker run -d \ -v host_data_path:/data \ ret...
To raise a number x to a power y, use either the POW() or POWER() functions SELECT POW(2,2); => 4 SELECT POW(4,2); => 16

Page 49 of 109