You can also import symbols in any scope, the import will only be looked up when the scope is needed (i.e. compiled) and the imported names will only be exposed in the imported scope. Most commonly the scope for local imports are functions, structs and classes.
void main()
{
import std.stdio:...
A local name for an import can be given, through which all references to the module's symbols must be qualified with:
import io = std.stdio;
void main()
{
io.writeln("Hello world");
std.stdio.writeln("hello!"); // error, std is undefined
writeln("hello!&qu...
Modules have a one-to-one correspondence with source files. The module name is, by default, the file name with the path and extension stripped off, and can be set explicitly with the module declaration.
The ModuleDeclaration sets the name of the module and what package it belongs to. If absent, the...
You can move a container instead of copying it:
void print(const std::vector<int>& vec) {
for (auto&& val : vec) {
std::cout << val << ", ";
}
std::cout << std::endl;
}
int main() {
// initialize vec1 with 1, 2, 3, 4 and...
You can re-use a moved object:
void consumingFunction(std::vector<int> vec) {
// Some operations
}
int main() {
// initialize vec with 1, 2, 3, 4
std::vector<int> vec{1, 2, 3, 4};
// Send the vector by move
consumingFunction(std::move(vec));
// Here...
Suppose, that we have three users :
The Administrator of the database > admin
The application with a full access for her data > read_write
The read only access > read_only
--ACCESS DB
REVOKE CONNECT ON DATABASE nova FROM PUBLIC;
GRANT CONNECT ON DATABASE nova TO user;
With th...
Converting a time to a string is a pretty common thing to do in Ruby. strftime is the method one would use to convert time to a string.
Here are some examples:
Time.now.strftime("%Y-%m-d %H:%M:S") #=> "2016-07-27 08:45:42"
This can be simplified even further
Time.now.str...
A simple cursor syntax, operating on a few example test rows:
/* Prepare test data */
DECLARE @test_table TABLE
(
Id INT,
Val VARCHAR(100)
);
INSERT INTO @test_table(Id, Val)
VALUES
(1, 'Foo'),
(2, 'Bar'),
(3, 'Baz');
/* Test data prepared */
/* Iterator variabl...
COPY is PostgreSQL's bulk-insert mechanism. It's a convenient way to transfer data between files and tables, but it's also far faster than INSERT when adding more than a few thousand rows at a time.
Let's begin by creating sample data file.
cat > samplet_data.csv
1,Yogesh
2,Raunak
3,Varun
...
What is a Stack?
In Java, Stacks are a LIFO (Last In, First Out) Data structure for objects.
Stack API
Java contains a Stack API with the following methods
Stack() //Creates an empty Stack
isEmpty() //Is the Stack Empty? Return Type: Boolean
push(Item item) /...
Media queries allow one to apply CSS rules based on the type of device / media (e.g. screen, print or handheld) called media type, additional aspects of the device are described with media features such as the availability of color or viewport dimensions.
General Structure of a Media Query
@media ...
By default, the caret ^ metacharacter matches the position before the first
character in the string.
Given the string "charsequence" applied
against the following patterns: /^char/ & /^sequence/, the engine will try to match as follows:
/^char/
^ - charsequence
c - charsequ...
Proper indentation gives not only the aesthetic look but also increases the readability of the code.
For example, consider the following code:
%no need to understand the code, just give it a look
n = 2;
bf = false;
while n>1
for ii = 1:n
for jj = 1:n
if ii+jj>30
bf = true;
break
end...
Assertions are used not to perform testing of input parameters, but to verify that program flow is corect -- i.e., that you can make certain assumptions about your code at a certain point in time. In other words: a test done with Debug.Assert should always assume that the value tested is true.
Debu...
For multiple quotechars use regex in place of sep:
df = pd.read_csv(log_file,
sep=r'\s(?=(?:[^"]*"[^"]*")*[^"]*$)(?![^\[]*\])',
engine='python',
usecols=[0, 3, 4, 5, 6, 7, 8],
names=['ip', 'time', 'request', 'statu...
Any loop may be terminated or continued early at any point by using the Exit or Continue statements.
Exiting
You can stop any loop by exiting early. To do this, you can use the keyword Exit along with the name of the loop.
LoopExit StatementForExit ForFor EachExit ForDo WhileExit DoWhileExit Whil...
You can set a setUp and tearDown function.
A setUp function prepares your environment to tests.
A tearDown function does a rollback.
This is a good option when you can't modify your database and you need to create an object that simulate an object brought of database or need to init a configu...