Skip to content

Instantly share code, notes, and snippets.

View jawira's full-sized avatar
👨‍💻
Portugal. the dev

Jawira Portugal jawira

👨‍💻
Portugal. the dev
View GitHub Profile
@jawira
jawira / recursivity.php
Created September 23, 2020 09:04
Recursivity with anonymous function
<?php
namespace Jawira\Tests;
use function sleep;
function write($message): void
{
echo $message;
}
@jawira
jawira / phive-install.php
Created September 3, 2019 18:17
Download and install Phive without wget nor curl
<?php
/**
* Download and install Phive without wget nor curl
*
* Very useful for CI when using alpine images. However you will need to run
* `apk add ncurses` in order to execute Phive.
*
* If you want to run this with "php -r" you should first escape all '$' signs.
*
* @author Jawira Portugal <dev@tugal.be>
@jawira
jawira / division-multiplication.php
Created January 21, 2018 09:29
Prints basic multiplication and division, answer is introduced by user.
#!/usr/bin/env php
<?php
declare(strict_types=1);
try {
assert_options(ASSERT_ACTIVE, true);
assert_options(ASSERT_BAIL, true);
main();
} catch (Exception $e) {
die($e->getMessage());
@jawira
jawira / namespaces_and_constants.php
Last active March 15, 2016 09:25
Simple use of constants within a namespace.
<?php
/**
* Created by PhpStorm.
* User: jawira
* Date: 15.03.16
* Time: 10:03
*/
namespace Dummy\MyTime;
const MONTHS = 12;
@jawira
jawira / enable_logfile.sql
Created November 5, 2015 17:31
How to show the last queries executed on MySQL?
-- Source: http://stackoverflow.com/questions/650238/how-to-show-the-last-queries-executed-on-mysql
SET GLOBAL log_output = "FILE";
SET GLOBAL general_log_file = "/path/to/your/logfile.log";
SET GLOBAL general_log = 'ON';
@jawira
jawira / fibonacci.php
Last active June 20, 2019 08:27
Testing PHP7 features with Fibonacci sequence function
<?php
/**
* Succinct Fibonacci function
*
* Returns the first N Fibonacci numbers specified as parameter.
*
* This function has not been written for efficiency nor readabilty, instead it has
* been created for fun and for testing the latest PHP features (E.g.: generators,
* literal dereferencing, type hinting, short array syntax, ...).
*
@jawira
jawira / 0_reuse_code.js
Last active August 29, 2015 14:23
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console