Tutorial by Examples: c

Sometimes we need cross domain request for our API's in laravel. We need to add appropriate headers to complete the cross domain request successfully. So we need to make sure that whatever headers we are adding should be accurate otherwise our API's become vulnerable. In order to add headers we nee...
<?php namespace laravel\Http\Middleware; class CorsHeaders { /** * This must be executed _before_ the controller action since _after_ middleware isn't executed when exceptions are thrown and caught by global handlers. * * @param $request * @param \Closure $next * @pa...
This is an example of using until/retries/delay to implement an alive check for a webapp that is starting up. It assumes that there will be some period of time (up to 3 minutes) where the webapp is refusing socket connections. After that, it checks the /alive page for the word "OK". It als...
For small functions that get called often, the overhead associated with the function call can be a significant fraction of the total execution time of that function. One way of improving performance, then, is to eliminate the overhead. In this example we use four functions (plus main()) in three so...
Go to the [https://developers.facebook.com/](https://developers.facebook.com/) and create your app. Click Add product and choose Facebook Login
Before install this extension, you must install yii2-app. In this example, I use yii2-basic template. Guide for installation in here. Run composer require --prefer-dist yiisoft/yii2-authclient or add "yiisoft/yii2-authclient": "~2.1.0" to the require section of your comp...
Add button Login as facebook account to your login view: Edit site/login.php in views folder, add theses line to content of page login: <?= yii\authclient\widgets\AuthChoice::widget([ 'baseAuthUrl' => ['site/auth'], 'popupMode' => false, ]) ?> Above, we set that aut...
If you enable prettyUrl in your yii2-app, your redirect_uri will be: http://<base_url>/web/site/auth And disable pretty url: http://<base_url>/web/index.php?r=site%2Fauth Example:
/** * @param $client ClientInterface */ public function onAuthSuccess($client) { //Get user info /** @var array $attributes */ $attributes = $client->getUserAttributes(); $email = ArrayHelper::getValue($attributes, 'email'); //email info $id = ArrayHelper::getValue(...
Persistence is created in docker containers using volumes. Let's create a Limesurvey container and persist the database, uploaded content and configuration in a named volume: docker volume create --name mysql docker volume create --name upload docker run -d --name limesurvey -v mysql:/var/lib/m...
We need to create a container to mount the volume. Then archive it and download the archive to our host. Let's create first a data volume with some data: docker volume create --name=data echo "Hello World" | docker run -i --rm=true -v data:/data ubuntu:trusty tee /data/hello.txt Let...
This document explains how to get Google Access tokens and use them to get Google Analytics data to be displayed in our websites. Example: A live example is available in https://newtonjoshua.com note: Use the same gmail account for all the below steps. STEP 1: Set Up Google Analytics Foll...
Parameters of these operators are lhs and rhs operator== tests if both elements on lhs and rhs pair are equal. The return value is true if both lhs.first == rhs.first AND lhs.second == rhs.second, otherwise false std::pair<int, int> p1 = std::make_pair(1, 2); std::pair<int, int> ...
When calling driver.Navigate().GoToUrl(url);, the code execution stops until the page is fully loaded. This is sometimes unnecessary when you just want to extract data. Note: The code samples below could be considered hacks. There is no "official" way of doing this. Create a new thread...
SELECT string_agg(<TABLE_NAME>.<COLUMN_NAME>, ',') FROM <SCHEMA_NAME>.<TABLE_NAME> T
DELETE FROM <SCHEMA_NAME>.<Table_NAME> WHERE ctid NOT IN ( SELECT MAX(ctid) FROM <SCHEMA_NAME>.<TABLE_NAME> GROUP BY <SCHEMA_NAME>.<TABLE_NAME>.* ) ;
If the Control has rows. TextBox tb = GridView1.Rows[i].FindControl("TextBox1") as TextBox; Or if it has items. TextBox tb = Repeater1.Items[i].FindControl("TextBox1") as TextBox;
inline int add(int x, int y) { return x + y; }
// header (.hpp) struct A { void i_am_inlined() { } }; struct B { void i_am_NOT_inlined(); }; // source (.cpp) void B::i_am_NOT_inlined() { }

Page 614 of 826