Tutorial by Examples: l

1. $_ : The default input and pattern-searching space. Example 1: my @array_variable = (1 2 3 4); foreach (@array_variable){ print $_."\n"; # $_ will get the value 1,2,3,4 in loop, if no other variable is supplied. } Example 2: while (<FH>){ chomp($_); # $_ re...
By default communication over the channcels is sync; when you send some value there must be a receiver. Otherwise you will get fatal error: all goroutines are asleep - deadlock! as follows: package main import "fmt" func main() { msg := make(chan string) msg <- "He...
<mvc:View controllerName="sap.m.sample.ListCounter.List" xmlns:mvc="sap.ui.core.mvc" xmlns="sap.m"> <List headerText="Fruits" items="{path:'products>/Products', sorter:{path:'Name'}, filter:{path:'Type', o...
import AVFoundation class QRScannerViewController: UIViewController, AVCaptureMetadataOutputObjectsDelegate { func viewDidLoad() { self.initCaptureSession() } private func initCaptureSession() { let captureDevice = AVCaptureDevice .defa...
Use the quotestar register to copy/paste between Vim and system clipboard "*yy copies the current line into the system clipboard "*p pastes the content of the system clipboard into Vim
Method Overriding and Overloading are two forms of polymorphism supported by Java. Method Overloading Method overloading (also known as static Polymorphism) is a way you can have two (or more) methods (functions) with same name in a single class. Yes its as simple as that. public class Shape{ ...
Floyd-Warshall's algorithm is for finding shortest paths in a weighted graph with positive or negative edge weights. A single execution of the algorithm will find the lengths (summed weights) of the shortest paths between all pair of vertices. With a little variation, it can print the shortest path ...
One of the most important implementations of Dynamic Programming is finding out the Longest Common Subsequence. Let's define some of the basic terminologies first. Subsequence: A subsequence is a sequence that can be derived from another sequence by deleting some elements without changing the orde...
Weighted Job Scheduling Algorithm can also be denoted as Weighted Activity Selection Algorithm. The problem is, given certain jobs with their start time and end time, and a profit you make when you finish the job, what is the maximum profit you can make given no two jobs can be executed in parallel...
Detailed instructions on getting azure-documentdb set up or installed.
Suppose you are asked, given the total weight you can carry on your knapsack and some items with their weight and values, how can you take those items in such a way that the sum of their values are maximum, but the sum of their weights don't exceed the total weight you can carry? The 0-1 indicates e...
The mellium.im/xmpp/jid package implements operations on JIDs. To split a JID string into its component parts the SplitString function may be used: lp, dp, rp, err := SplitString("[email protected]") No validation is performed by the function and the parts are not guaranteed to be vali...
The DirectX SDK is included within the Windows SDK, in all versions past Windows SDK v8. Normally, the Windows SDK is installed with Visual Studio (any version past Visual Studio 2012), however, it can be installed separately. Previously, the DirectX SDK was available as a separate installation, the...
Problem ConcurrentDictionary shines when it comes to instantly returning of existing keys from cache, mostly lock free, and contending on a granular level. But what if the object creation is really expensive, outweighing the cost of context switching, and some cache misses occur? If the same key ...
int x, y; bool ready = false; void init() { x = 2; y = 3; ready = true; } void use() { if (ready) std::cout << x + y; } One thread calls the init() function while another thread (or signal handler) calls the use() function. One might expect that the use() function ...
The example above can also be implemented with fences and relaxed atomic operations: int x, y; std::atomic<bool> ready{false}; void init() { x = 2; y = 3; atomic_thread_fence(std::memory_order_release); ready.store(true, std::memory_order_relaxed); } void use() { if (re...
One of the best features of async/await syntax is that standard try-catch coding style is possible, just like you were writing synchronous code. const myFunc = async (req, res) => { try { const result = await somePromise(); } catch (err) { // handle errors here } }); Here'...
Here is how to create a custom calendar. The example given is a french calendar -- so it provides many examples. from pandas.tseries.holiday import AbstractHolidayCalendar, Holiday, EasterMonday, Easter from pandas.tseries.offsets import Day, CustomBusinessDay class FrBusinessCalendar(AbstractH...
Here is how to use the custom calendar. Get the holidays between two dates import pandas as pd from datetime import date # Creating some boundaries year = 2016 start = date(year, 1, 1) end = start + pd.offsets.MonthEnd(12) # Creating a custom calendar cal = FrBusinessCalendar() # Getti...

Page 658 of 861