In [188]: s = pd.Series(["a","b","c","a","c"], dtype="category")
In [189]: s
Out[189]:
0 a
1 b
2 c
3 a
4 c
dtype: category
Categories (3, object): [a, b, c]
In [190]: df = pd.DataFrame({"A":["a&q...
package com.example.my.package;
The package declaration should not be line wrapped, regardless of whether it exceeds the recommended maximum length of a line.
Indentation level is four spaces.
Only space characters may be used for indentation. No tabs.
Empty lines must not be indented. (This is implied by the no trailing white space rule.)
case lines should be indented with four spaces, and statements within the case should be indented with another f...
If a line approaches the maximum character limit, always consider breaking it down into multiple statements / expressions instead of wrapping the line.
Break before operators.
Break before the . in chained method calls.
popupMsg("Inbox notification: You have "
+ newMsgs + &...
One variable per declaration (and at most one declaration per line)
Square brackets of arrays should be at the type (String[] args) and not on the variable (String args[]).
Declare a local variable right before it is first used, and initialize it as close to the declaration as possible.
Declaration annotations should be put on a separate line from the declaration being annotated.
@SuppressWarnings("unchecked")
public T[] toArray(T[] typeHolder) {
...
}
However, few or short annotations annotating a single-line method may be put on the same line as the method if...
Runnable r = () -> System.out.println("Hello World");
Supplier<String> c = () -> "Hello World";
// Collection::contains is a simple unary method and its behavior is
// clear from the context. A method reference is preferred here.
appendFilter(goodStrings::cont...
First, here's what can happen when text/template is used for HTML. Note Harry's FirstName property).
package main
import (
"fmt"
"html/template"
"os"
)
type Person struct {
FirstName string
LastName string
Street string
Cit...
Using regular recursion, each recursive call pushes another entry onto the call stack. When the recursion is completed, the application has to pop each entry off all the way back down. If there are much recursive function calls it can end up with a huge stack.
Scala automatically removes the recurs...
for /L %%A in (1,2,40) do echo %%A
This line will iterate from 1 to 39, increasing by 2 each time.
The first parameter, 1, is the starting number.
The second parameter, 2, is the increment.
The third parameter, 40, is the maximum.
import std.stdio;
T min(T)(in T arg1, in T arg2) {
return arg1 < arg2 ? arg1 : arg2;
}
void main() {
//Automatic type inference
writeln(min(1, 2));
//Explicit type
writeln(min!(ubyte)(1, 2));
//With single type, the parenthesis might be ommited
...
You can check for syntax errors and referenced files in an NGINX configuration file before running it with:
nginx -t
Alternatively you can run service script
service nginx configtest
While both of these commands will tell you if your new nginx configuration is ok [without killing your curren...
Enabling gzip compression can reduce the size of the transferred response by up to 90%, which can significantly reduce the amount of time to download the resource, reduce data usage for the client, and improve the time to first render of your pages. — PageSpeed Insights
Compression can be ena...
template< class Iterator >
bool next_permutation( Iterator first, Iterator last );
template< class Iterator, class Compare >
bool next_permutation( Iterator first, Iterator last, Compare cmpFun );
Effects:
Sift the data sequence of the range [first, last) into the next lexicograph...
A condition variable is a primitive used in conjunction with a mutex to orchestrate communication between threads. While it is neither the exclusive or most efficient way to accomplish this, it can be among the simplest to those familiar with the pattern.
One waits on a std::condition_variable with...