Tutorial by Examples: c

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...
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...
Dictionaries map keys to values. car = {} car["wheels"] = 4 car["color"] = "Red" car["model"] = "Corvette" Dictionary values can be accessed by their keys. print "Little " + car["color"] + " " + car["model&q...
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....
To install NLTK with Continuum's anaconda / conda. If you are using Anaconda, most probably nltk would be already downloaded in the root (though you may still need to download various packages manually). Using conda: conda install nltk To upgrade nltk using conda: conda update nltk With a...
There are many compilers that support different versions of the OpenMP specification. OpenMP maintains a list here with the compiler that support it and the supported version. In general, to compile (and link) an application with OpenMP support you need only to add a compile flag and if you use the ...
Get current date and time lib.date = TEXT lib.date { data = date:U strftime = %d.%m.%Y %H:%M:%S wrap = Today is | } Get last login time and date from fe_users lib.date = TEXT lib.date { data = TSFE:fe_user|user|lastlogin strftime = %d.%m.%Y %H:%M:%S wrap = Last logi...
Given this setup code: var dict = new Dictionary<int, string>() { { 1, "First" }, { 2, "Second" }, { 3, "Third" } }; Use the Remove method to remove a key and its associated value. bool wasRemoved = dict.Remove(2); Executing this code remo...
The while loop runs its body as long as the condition holds. For instance, the following code computes and prints the Collatz sequence from a given number: function collatz(n) while n ≠ 1 println(n) n = iseven(n) ? n ÷ 2 : 3n + 1 end println("1... and 4, 2, 1, ...
In some situations, one might want to return from a function before finishing an entire loop. The return statement can be used for this. function primefactor(n) for i in 2:n if n % i == 0 return i end end @assert false # unreachable end Usage: jul...
Julia provides macros to simplify distributing computation across multiple machines or workers. For instance, the following computes the sum of some number of squares, possibly in parallel. function sumofsquares(A) @parallel (+) for i in A i ^ 2 end end Usage: julia> sumo...
pushunique!(A, x) = x in A ? A : push!(A, x) The ternary conditional operator is a less wordy if...else expression. The syntax specifically is: [condition] ? [execute if true] : [execute if false] In this example, we add x to the collection A only if x is not already in A. Otherwise, we jus...

Page 365 of 826