Tutorial by Examples: n

The even? method can be used to determine if a number is even 4.even? # => true 5.even? # => false The odd? method can be used to determine if a number is odd 4.odd? # => false 5.odd? # => true
The round method will round a number up if the first digit after its decimal place is 5 or higher and round down if that digit is 4 or lower. This takes in an optional argument for the precision you're looking for. 4.89.round # => 5 4.25.round # => 4 3.141526.round(1) # => ...
If you need to clamp a number to keep it inside a specific range boundary function clamp(min, max, val) { return Math.min(Math.max(min, +val), max); } console.log(clamp(-10, 10, "4.30")); // 4.3 console.log(clamp(-10, 10, -8)); // -8 console.log(clamp(-10, 10, 12)); // ...
Detailed instructions on getting netty set up or installed.
Invented by John McCarthy around 1958, Lisp (List Processor) has continued to grow into an entire family of languages. Since StackOverflow is more about practical programming problems, typically problems will involve actual Lisp dialects or derived languages and their implementations. Problems that...
A common and task of someone using the Linux Command Line (shell) is to search for files/directories with a certain name or containing certain text. There are 2 commands you should familiarise yourself with in order to accomplish this: Find files by name find /var/www -name '*.css' This will...
th elements are very commonly used to indicate headings for table rows and columns, like so: <table> <thead> <tr> <td></td> <th>Column Heading 1</th> <th>Column Heading 2</th> </tr...
To make long text at most N characters long but leave last word intact, use .{0,N}\b pattern: ^(.{0,N})\b.*
Before making a pull request, it is useful to make sure that compile is successful and tests are passing for each commit in the branch. We can do that automatically using -x parameter. For example: git rebase -i -x make will perform the interactive rebase and stop after each commit to execute mak...
import tensorflow as tf dims, layers = 32, 2 # Creating the forward and backwards cells lstm_fw_cell = tf.nn.rnn_cell.BasicLSTMCell(dims, forget_bias=1.0) lstm_bw_cell = tf.nn.rnn_cell.BasicLSTMCell(dims, forget_bias=1.0) # Pass lstm_fw_cell / lstm_bw_cell directly to tf.nn.bidrectional_rnn ...
go run will run a program without creating an executable file. Mostly useful for development. run will only execute packages whose package name is main. To demonstrate, we will use a simple Hello World example main.go: package main import fmt func main() { fmt.Println("Hello, World...
go clean will clean up any temporary files created when invoking go build on a program. It will also clean files left over from Makefiles.
A panic halts normal execution flow and exits the current function. Any deferred calls will then be executed before control is passed to the next higher function on the stack. Each stack's function will exit and run deferred calls until the panic is handled using a deferred recover(), or until the...
Let's take a sample class: public class Transaction { public string Category { get; set; } public DateTime Date { get; set; } public decimal Amount { get; set; } } Now, let us consider a list of transactions: var transactions = new List<Transaction> { new Transaction...
Most analysis customization is in the createComponents class, where the Tokenizer and TokenFilters are defined. CharFilters can be added in the initReader method. Analyzer analyzer = new Analyzer() { @Override protected Reader initReader(String fieldName, Reader reader) { retu...
TokenStream stream = myAnalyzer.tokenStream("myField", textToAnalyze); stream.addAttribute(CharTermAttribute.class); stream.reset(); while(stream.incrementToken()) { CharTermAttribute token = stream.getAttribute(CharTermAttribute.class); System.out.println(token.toString()); ...
public class NullableTypesExample { static int? _testValue; public static void Main() { if(_testValue == null) Console.WriteLine("null"); else Console.WriteLine(_testValue.ToString()); } } Output: null
Without timezone, with microseconds from datetime import datetime datetime.now().isoformat() # Out: '2016-07-31T23:08:20.886783' With timezone, with microseconds from datetime import datetime from dateutil.tz import tzlocal datetime.now(tzlocal()).isoformat() # Out: '2016-07-31T23:09:4...
int signed_integer = -1; // The right shift operation exhibits implementation-defined behavior: int result = signed_integer >> 1;
// Supposing SCHAR_MAX, the maximum value that can be represented by a signed char, is // 127, the behavior of this assignment is implementation-defined: signed char integer; integer = 128;

Page 536 of 1088