Tutorial by Examples: ee

So let's suppose you want to iterate only between some specific lines of a file You can make use of itertools for that import itertools with open('myfile.txt', 'r') as f: for line in itertools.islice(f, 12, 30): # do something here This will read through the lines 13 to 20 as i...
Returns a random integer between min and max: function randomBetween(min, max) { return Math.floor(Math.random() * (max - min + 1) + min); } Examples: // randomBetween(0, 10); Math.floor(Math.random() * 11); // randomBetween(1, 10); Math.floor(Math.random() * 10) + 1; // randomBet...
public void iterateAndFilter() throws IOException { Path dir = Paths.get("C:/foo/bar"); PathMatcher imageFileMatcher = FileSystems.getDefault().getPathMatcher( "regex:.*(?i:jpg|jpeg|png|gif|bmp|jpe|jfif)"); try (Direc...
git config --global merge.conflictstyle diff3 Sets the diff3 style as default: instead of the usual format in conflicted sections, showing the two files: <<<<<<< HEAD left ======= right >>>>>>> master it will include an additional section containi...
Description When working with a team who uses different operating systems (OS) across the project, sometimes you may run into trouble when dealing with line endings. Microsoft Windows When working on Microsoft Windows operating system (OS), the line endings are normally of form - carriage return ...
The following code will show week of the year number on the left side of the datepicker. By default the week start on Monday, but it can be customized using firstDay option. The first week of the year contains the first Thursday of the year, following the ISO 8601 definition. <input type="t...
jquery-ui-rotatable is a plugin for jQuery UI that works in a similar way to Draggable and Resizable, without being as full-featured. By default, it puts a small rotation icon in the bottom left of whatever element you want to make rotatable. <html> <head> <title>My Ro...
with pd.ExcelFile('path_to_file.xls) as xl: d = {sheet_name: xl.parse(sheet_name) for sheet_name in xl.sheet_names}
pd.read_excel('path_to_file.xls', sheetname='Sheet1') There are many parsing options for read_excel (similar to the options in read_csv. pd.read_excel('path_to_file.xls', sheetname='Sheet1', header=[0, 1, 2], skiprows=3, index_col=0) # etc.
Assuming a source file of hello_world.v and a top level module of hello_world. The code can be run using various simulators. Most simulators are compiled simulators. They require multiple steps to compile and execute. Generally the First step is to compile the Verilog design. Second step is to ...
The syntax for Java generics bounded wildcards, representing the unknown type by ? is: ? extends T represents an upper bounded wildcard. The unknown type represents a type that must be a subtype of T, or type T itself. ? super T represents a lower bounded wildcard. The unknown type repres...
Using a Template Engine The following code will setup Jade as template engine. (Note: Jade has been renamed to pug as of December 2015.) const express = require('express'); //Imports the express module const app = express(); //Creates an instance of the express module const PORT = 3000; //Ra...
Matplotlib axes are two-dimensional by default. In order to create three-dimensional plots, we need to import the Axes3D class from the mplot3d toolkit, that will enable a new kind of projection for an axes, namely '3d': import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D fi...
When you use or, it will either return the first value in the expression if it's true, else it will blindly return the second value. I.e. or is equivalent to: def or_(a, b): if a: return a else: return b For and, it will return its first value if it's false, else it r...
<?php use yii\db\Migration; class m150101_185401_create_news_table extends Migration { public function up() { } public function down() { echo "m101129_185401_create_news_table cannot be reverted.\n"; return false; } /* // Use safeUp/safeDown to run migra...
BeautifulSoup has a limited support for CSS selectors, but covers most commonly used ones. Use select() method to find multiple elements and select_one() to find a single element. Basic example: from bs4 import BeautifulSoup data = """ <ul> <li class="item&quo...
Sometimes it is appropriate to use an immutable empty collection. The Collections class provides methods to get such collections in an efficient way: List<String> anEmptyList = Collections.emptyList(); Map<Integer, Date> anEmptyMap = Collections.emptyMap(); Set<Number> anEmptySe...
If a type wishes to have value semantics, and it needs to store objects that are dynamically allocated, then on copy operations, the type will need to allocate new copies of those objects. It must also do this for copy assignment. This kind of copying is called a "deep copy". It effective...
Given any value of type Int or Long to render a human readable string: fun Long.humanReadable(): String { if (this <= 0) return "0" val units = arrayOf("B", "KB", "MB", "GB", "TB", "EB") val digitGroups = (Mat...
A common use case for extension methods is to improve an existing API. Here are examples of adding exist, notExists and deleteRecursively to the Java 7+ Path class: fun Path.exists(): Boolean = Files.exists(this) fun Path.notExists(): Boolean = !this.exists() fun Path.deleteRecursively(): Bool...

Page 8 of 54