Tutorial by Examples

import pygame import time pygame.mixer.init() pygame.display.init() screen = pygame.display.set_mode ( ( 420 , 240 ) ) playlist = list() playlist.append ( "music3.mp3" ) playlist.append ( "music2.mp3" ) playlist.append ( "music1.mp3" ) pygame.mixer.musi...
By default, PHP Curl supports GET and POST requests. It is possible to also send custom requests, such as DELETE, PUT or PATCH (or even non-standard methods) using the CURLOPT_CUSTOMREQUEST parameter. $method = 'DELETE'; // Create a DELETE request $ch = curl_init($url); curl_setopt($ch, CURLOPT...
To install PHP on Ubuntu, first install the Redis server: sudo apt install redis-server then install the PHP module: sudo apt install php-redis And restart the Apache server: sudo service apache2 restart
Assuming a default server running on localhost with the default port, the command to connect to that Redis server would be: $redis = new Redis(); $redis->connect('127.0.0.1', 6379);
The Redis PHP module gives access to the same commands as the Redis CLI client so it is quite straightforward to use. The syntax is as follow: // Creates two new keys: $redis->set('mykey-1', 123); $redis->set('mykey-2', 'abcd'); // Gets one key (prints '123') var_dump($redis->get('m...
Preparing data: create table wf_example(i int, t text,ts timestamptz,b boolean); insert into wf_example select 1,'a','1970.01.01',true; insert into wf_example select 1,'a','1970.01.01',false; insert into wf_example select 1,'b','1970.01.01',false; insert into wf_example select 2,'b','1970.01.01...
Maya supports 3 main programming environments. Each has different setup requirements. MEL MEL scripting language is included with the Maya application. Enabled by default, users can test MEL in the script listener window in a running copy of Maya. MEL files are text files with the extension .mel...
The partition of an integer is a way of writing it as a sum of positive integers. For example, the partitions of the number 5 are: 5 4 + 1 3 + 2 2 + 2 + 1 2 + 1 + 1 + 1 1 + 1 + 1 + 1 + 1 Notice that changing the order of the summands will not create a different partition. The partition f...
public class IntegerPartition { public static int[,] Result = new int[100,100]; private static int Partition(int targetNumber, int largestNumber) { for (int i = 1; i <= targetNumber; i++) { for (int j = 1; j <= largestNumber; j++) ...
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...

Page 986 of 1336