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...
var pattern = createPattern(imageObject,repeat)
Creates a reusable pattern (object).
The object can be assigned to any strokeStyle and/or fillStyle.
Then stroke() or fill() will paint the Path with the pattern of the object.
Arguments:
imageObject is an image that will be used as a patter...
context.stroke()
Causes the perimeter of the Path to be stroked according to the current context.strokeStyle and the stroked Path is visually drawn onto the canvas.
Prior to executing context.stroke (or context.fill) the Path exists in memory and is not yet visually drawn on the canvas.
The unu...
context.fill()
Causes the inside of the Path to be filled according to the current context.fillStyle and the filled Path is visually drawn onto the canvas.
Prior to executing context.fill (or context.stroke) the Path exists in memory and is not yet visually drawn on the canvas.
Example code usi...
context.clip
Limits any future drawings to display only inside the current Path.
Example: Clip this image into a triangular Path
<!doctype html>
<html>
<head>
<style>
body{ background-color:white; }
#canvas{border:1px solid red; }
</style>
<sc...
This function executes an AJAX request using the HEAD method allowing us to check whether a file exists in the directory given as an argument. It also enables us to launch a callback for each case (success, failure).
function fileExists(dir, successCallback, errorCallback) {
var xhttp = new XM...
You can also perform this task recursively, but I have chosen in this example to use an iterative approach. This task is useful if you are inserting all of your nodes at the beginning of a linked list. Here is an example:
#include <stdio.h>
#include <stdlib.h>
#define NUM_ITEMS 10...
The Python interpreter compiles code to bytecode before executing it on the Python's virtual machine (see also What is python bytecode?.
Here's how to view the bytecode of a Python function
import dis
def fib(n):
if n <= 2: return 1
return fib(n-1) + fib(n-2)
# Display the disas...
CPython allows access to the code object for a function object.
The __code__object contains the raw bytecode (co_code) of the function as well as other information such as constants and variable names.
def fib(n):
if n <= 2: return 1
return fib(n-1) + fib(n-2)
dir(fib.__code__)
de...
This example goes over how to set up CoreNLP from the GitHub repo. The GitHub code has newer features than the official release, but may be unstable. This example will take you through downloading, building, and running a simple command-line invocation of CoreNLP.
Prerequisites:
Java 8 or newer....