1. Character Class
Character class is denoted by []. Content inside a character class is treated as single character separately. e.g. suppose we use
[12345]
In the example above, it means match 1 or 2 or 3 or 4 or 5 . In simple words, it can be understood as or condition for single characters (...
Pure JavaScript
It's possible to add, remove or change CSS property values with JavaScript through an element's style property.
var el = document.getElementById("element");
el.style.opacity = 0.5;
el.style.fontFamily = 'sans-serif';
Note that style properties are named in lower came...
This is a normal function call:
console.log("Hello World!");
When you call a normal function, it does its job and then returns control back to the caller.
However, sometimes a function needs to return control back to the caller in order to do its job:
[1,2,3].map(function double(x) {...
A Bag/ultiset stores each object in the collection together with a count of occurrences. Extra methods on the interface allow multiple copies of an object to be added or removed at once. JDK analog is HashMap<T, Integer>, when values is count of copies this key.
TypeGuavaApache Commons Collec...
astype() method changes the dtype of a Series and returns a new Series.
In [1]: df = pd.DataFrame({'A': [1, 2, 3], 'B': [1.0, 2.0, 3.0],
'C': ['1.1.2010', '2.1.2011', '3.1.2011'],
'D': ['1 days', '2 days', '3 days'],
...
In order to include plots created with matplotlib in TeX documents, they should be saved as pdf or eps files. In this way, any text in the plot (including TeX formulae) is rendered as text in the final document.
import matplotlib.pyplot as plt
plt.rc(usetex=True)
x = range(0, 10)
y = [t**2 for t...
The "factory default" number of worksheets created in a new Excel workbook is generally set to three. Your VBA code can explicitly set the number of worksheets in a new workbook.
'--- save the current Excel global setting
With Application
Dim oldSheetsCount As Integer
oldSheets...
Stackage is a repository for Haskell packages. We can add these packages to a stack project.
Adding lens to a project.
In a stack project, there is a file called stack.yaml. In stack.yaml there is a segment that looks like:
resolver: lts-6.8
Stackage keeps a list of packages for every revision...
Example. It will be replacing the word email to a name in a text file index.txt with simple RegExp replace(/email/gim, 'name')
var fs = require('fs');
fs.readFile('index.txt', 'utf-8', function(err, data) {
if (err) throw err;
var newValue = data.replace(/email/gim, 'name');
...
The implementation of INotifyPropertyChange can be error-prone, as the interface requires specifying property name as a string. In order to make the implementation more robust, an attribute CallerMemberName can be used.
class C : INotifyPropertyChanged
{
// backing field
int offset;
...
There are many cases when one has created an NSDate from only an hour and minute format, i.e: 08:12 that returns from a server as a String and you initiate an NSDate instance by these values only.
The downside for this situation is that your NSDate is almost completely "naked" and what yo...
C-style bit-manipulation
// Bit n will be set if x is 1 and cleared if x is 0.
number ^= (-x ^ number) & (1LL << n);
Using std::bitset
set(n,val) - sets bit n to the value val.
std::bitset<5> num(std::string("00100"));
num.set(0,true); // num is now 00101
num.set(...
// A fixed size raw array matrix (that is, a 2D raw array).
#include <iostream>
#include <iomanip>
using namespace std;
auto main() -> int
{
int const n_rows = 3;
int const n_cols = 7;
int const m[n_rows][n_cols] = // A raw array matrix.
...