Tutorial by Examples: c

s/foo/bar/; # replace "foo" with "bar" in $_ my $foo = "foo"; $foo =~ s/foo/bar/; # do the above on a different variable using the binding operator =~ s~ foo ~ bar ~; # using ~ as a delimiter $foo = s/foo/bar/r; # non-destructive r flag: returns the repl...
This writeup walks though steps to configure Tomcat to request CAC certificates from the client. It is focused on setting up a development environment, so some features that should be considered for production are not here. (For example it shows using a self-signed certificate for https and it does...
This example uses the map format introduced in Erlang/OTP 18.0. %% A module implementing a supervisor usually has a name ending with `_sup`. -module(my_sup). -behaviour(supervisor). %% API exports -export([start_link/0]). %% Behaviour exports -export([init/1]). start_link() -> ...
We initialize the data: [X,Y] = meshgrid(1:2:10); Z = X.*cos(Y) - Y.*sin(X); The surface looks like the following. Now we set the points where we want to interpolate: [Vx,Vy] = meshgrid(1:0.25:10); We now can perform nearest interpolation, Vz = interp2(X,Y,Z,Vx,Vy,'nearest'); line...
We will use the following data: x = 1:5:50; y = randi([-10 10],1,10); Hereby x and y are the coordinates of the data points and z are the points we need information about. z = 0:0.25:50; One way to find the y-values of z is piecewise linear interpolation. z_y = interp1(x,y,z,'linear'); ...
Inline assembly will only be supported in nightly versions of Rust until it is stabilized. To enable usage of the asm! macro, use the following feature attribute at the top of the main file (a feature gate): #![feature(asm)] Then use the asm! macro in any unsafe block: fn do_nothing() { u...
Use conditional compilation to ensure that code only compiles for the intended instruction set (such as x86). Otherwise code could become invalid if the program is compiled for another architecture, such as ARM processors. #![feature(asm)] // Any valid x86 code is valid for x86_64 as well. Be ca...
The export tool exports a set of files from HDFS back to an RDBMS. The target table must already exist in the database. The input files are read and parsed into a set of records according to the user-specified delimiters. Example : sqoop export \ --connect="jdbc:<databaseconnector>&quo...
Send a Razor part to a @helper, for example a HTML div. @helper WrapInBox(Func<Object, HelperResult> content) { <div class="box">@content(null) </div> } //call @WrapInBox(@<div> I'm a inner div </div>)
@Helpers could be shared between views. They should be created in the folder App_Code @helper CreatePrimaryBootstrapButton(string label) { <button type="button" class="btn btn-primary">@label</button> } //call @MenuHelpers.CreatePrimaryBootstrapButton...
Sometimes it may be required to find out which directory consuming how much disk space especially when you are used df -h and realized your available disk space is low. du: du command summarizes disk usage of the set of FILEs, recursively for directories. It's often uses with -sh option: -s, --s...
First, ensure you have installed mongodb and express via npm. Then, in a file conventionally titled db.js, use the following code: var MongoClient = require('mongodb').MongoClient var state = { db: null, } exports.connect = function(url, done) { if (state.db) return done() M...
The following example is high level coverage of the key concepts and basic skeletal setup:- Collects credentials from the user (Usually from a login screen you've created) Authenticates the credentials with the server (stores custom authentication) Stores the credentials on the device Exte...
A frequent reason why your read operation may not work is because your security rules reject the operation, for example because you're not authenticated (by default a database can only be accessed by an authenticated user). You can see these security rule violations in the JavaScript console of you...
It's easiest to show a binary search on numbers using pseudo-code int array[1000] = { sorted list of numbers }; int N = 100; // number of entries in search space; int high, low, mid; // our temporaries int x; // value to search for low = 0; high = N -1; while(low < high) { mid = (...
In this iText 5 example, we'll create a text field and we'll add it to a PDF: public void manipulatePdf(String src, String dest) throws DocumentException, IOException { PdfReader reader = new PdfReader(src); PdfStamper stamper = new PdfStamper(reader, new FileOutputStream(dest)); T...
In this iText 7 example, we'll create a text field and we'll add it to a PDF: public void manipulatePdf(String src, String dest) throws IOException { PdfReader reader = new PdfReader(src); PdfDocument pdf = new PdfDocument(reader, new PdfWriter(dest)); PdfAcroForm form = PdfAcroFor...
Rounding Values midway between two integers go toward the nearest even value. - round(4.5); val it = 4 : int - round(3.5); val it = 4 : int Truncation val it = 4 : int - trunc(4.5); val it = 4 : int - trunc(3.5); val it = 3 : int Floor and Ceiling - ceil(4.5); val it = 5 : int - f...
Cannot add Integer and Real* - 5 + 1.0; stdIn:1.2-10.4 Error: operator and operand don't agree [overload conflict] operator domain: [+ ty] * [+ ty] operand: [+ ty] * real in expression: 5 + 1.0
- real(6); val it = 6.0 : real

Page 588 of 826