Skip to content

Instantly share code, notes, and snippets.

@scmrus
scmrus / md5_file_large.php
Created May 6, 2023 15:12
MD5 hash for a large file in PHP
<?php
function md5_file_large($file_path) {
if (!file_exists($file_path)) {
return false;
}
$chunk_size = 1024 * 1024; // 1MB
$md5_hash = hash_init('md5');
$file = fopen($file_path, 'rb');
@scmrus
scmrus / get-public-ip.md
Created December 2, 2022 16:22 — forked from rkalkani/get-public-ip.md
Get public IP address used by your machine to connect to the internet

Get Public IP

DNS

Google

dig o-o.myaddr.l.google.com txt @ns1.google.com +short
# OR
nslookup -type=txt o-o.myaddr.l.google.com ns1.google.com
@scmrus
scmrus / xdebug-code-coverage.php
Last active December 9, 2021 19:38
xdebug-code-coverage (global)
<?php
$_xdebug_code_coverage = new class {
private $coverage;
private $covFile;
public function __construct()
{
require_once __DIR__ . '/../vendor/autoload.php';
$uid = uniqid();
$ composer licenses -f summary
-------------- ------------------------
License Number of dependencies
-------------- ------------------------
MIT 113
BSD-3-Clause 30
Apache-2.0 5
LGPL-3.0 2
LGPL-2.1 1
BSD-2-Clause 1
netsh wlan show profiles
netsh wlan show profile "name=wifiname" key=clear
@scmrus
scmrus / install-docker.md
Created March 8, 2021 01:26 — forked from npearce/install-docker.md
Amazon Linux 2 - install docker & docker-compose using 'sudo amazon-linux-extras' command

UPDATE (March 2020, thanks @ic): I don't know the exact AMI version but yum install docker now works on the latest Amazon Linux 2. The instructions below may still be relevant depending on the vintage AMI you are using.

Amazon changed the install in Linux 2. One no-longer using 'yum' See: https://aws.amazon.com/amazon-linux-2/release-notes/

Docker CE Install

sudo amazon-linux-extras install docker
sudo service docker start
Saving output from 'text to speech' to a file on Mac OS X
```
say -o hello.flac -v 'Alex' 'Hello, my name is Alex'
```
<?php
/**
* @mixin \Illuminate\Support\Collection
*
* @psalm-suppress UndefinedMethod
* @psalm-suppress UndefinedThisPropertyFetch
* @psalm-suppress UndefinedThisPropertyAssignment
*/
class CollectionMixin
<?php
$redis = new \Predis\Client('tcp://'.env('REDIS_HOST', '127.0.0.1').':'.env('REDIS_PORT', 6379));
libxml_set_external_entity_loader(
function ($public, $system, $context) use($redis) {
if(is_file($system)){
return $system;
}
// cache
@scmrus
scmrus / schematest.php
Created January 24, 2020 20:14 — forked from hakre/schematest.php
Speeding up XML schema validations of a batch of XML files against the same XML schema (XSD)
<?php
/**
* @link http://stackoverflow.com/questions/13865149/speeding-up-xml-schema-validations-of-a-batch-of-xml-files-against-the-same-xml
*/
$mapping = [
'http://www.w3.org/2002/08/xhtml/xhtml1-transitional.xsd' => 'schema/xhtml1-transitional.xsd',
'http://www.w3.org/2001/xml.xsd' => 'schema/xml.xsd',
];